fabgonber

New_Highs_New_Lows_Percentual

Aug 27th, 2026
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.74 KB | Source Code | 0 0
  1. # New_Highs_New_Lows_Percentual
  2. #
  3. # Muestra el porcentaje de nuevos máximos de 52 semanas menos nuevos mínimos de 52 semanas por día para la bolsa
  4. # seleccionada. Si el número de mínimos es mayor que el de máximos, el valor será negativo. Si los máximos son
  5. # mayores, el porcentaje será positivo. Bolsa = "ETF" muestra la diferencia neta entre máximos y mínimos para todos los ETF
  6. # cotizadosen las 4 bolsas.
  7. #
  8. # Los símbolos de TOS no parecen funcionar como se espera cuando el período de agregación es SEMANAL, por lo que este
  9. # estudio es solo para gráficos diarios.
  10. #
  11. # Interpretación: si ve fondo rojo, la amplitud de mercado está mal, si ve fondo verde hay amplitud de mercado
  12. # ¿Cómo lo uso yo? 1) sobre NYSE,  2) si se pone verde largo en SPX, 3) si se pone rojo voy a liquidez.
  13. #
  14. # Shows the percentage of new 52-week highs - new 52-week lows by day for the selected exchange. If the
  15. # number of lows is greater than the number of highs, the value will be negative. If highs are
  16. # greater, the number will be positive. Exchange = "ETF" shows net highs - lows for all ETFs listed
  17. # on the 4 exchanges.
  18. #
  19. # The TOS symbols don't appear to work at expected when the aggregation period is WEEK so this
  20. # study is only for daily charts.
  21. #
  22.  
  23. declare lower;
  24. declare hide_on_intraday ; # most functions are only relevant for daily aggregation
  25. input exchange = {default "ALL STOCKS","NYSE+NASDAQ", "NYSE", "NASDAQ", "AMEX", "ARCA", "ETF"};
  26.  
  27. def diff;
  28.  
  29. def nydiff = (close("$NYHGH") - close("$NYLOW"))/(close("$NYHGH") + close("$NYLOW"));
  30. def nadiff = (close("$NAHGH") - close("$NALOW"))/(close("$NAHGH") + close("$NALOW"));
  31.  
  32. def nyse_y_nasdaq = ((close("$NYHGH")+close("$NAHGH"))-(close("$NYLOW")+close("$NALOW"))) / (close("$NYHGH")+close("$NAHGH")+close("$NYLOW")+close("$NALOW"));
  33.  
  34. def amdiff = (close("$AMHGH") - close("$AMLOW"))/(close("$AMHGH") + close("$AMLOW"));
  35. def ardiff = (close("$ARHGH") - close("$ARLOW"))/(close("$ARHGH") + close("$ARLOW"));
  36.  
  37.  
  38. def alldiff =     ((close("$NYHGH") - close("$NYLOW")) + (close("$NAHGH") - close("$NALOW"))
  39.                 + (close("$AMHGH") - close("$AMLOW")) + (close("$ARHGH") - close("$ARLOW")))
  40.                  / ((close("$NYHGH") + close("$NYLOW")) + (close("$NAHGH") + close("$NALOW"))
  41.                 + (close("$AMHGH") + close("$AMLOW")) + (close("$ARHGH") + close("$ARLOW")))
  42. ;
  43.  
  44. # nydiff+nadiff+amdiff+ardiff;
  45.  
  46.  
  47. def etfdiff = (close("$ETFHIGH") - close("$ETFLOW"))/(close("$ETFHIGH") + close("$ETFLOW"));
  48.  
  49. switch (exchange){
  50. case "NYSE":
  51.     diff = nydiff;
  52. case "NASDAQ":
  53.     diff =nadiff;
  54. case "NYSE+NASDAQ":
  55.     diff = nyse_y_nasdaq;
  56. case "AMEX":
  57.     diff = amdiff;
  58. case "ARCA":
  59.     diff = ardiff;
  60. case "ETF":
  61.     diff = etfdiff;
  62. case "ALL STOCKS":
  63.     diff = alldiff;
  64. }
  65.  
  66. # Show trend cloud
  67. def uptrend = diff > 0 and diff[1] > 0 and diff[2] > 0;
  68. def downtrend = diff < 0 and diff[1] < 0 and diff[2] < 0;
  69. def hiLevel = if uptrend then Double.POSITIVE_INFINITY else if downtrend then Double.NEGATIVE_INFINITY else 0;
  70. AddCloud(hiLevel, -hiLevel, Color.LIGHT_GREEN, Color.LIGHT_RED);
  71.  
  72. # show net new highs/lows bars
  73. plot hlp = diff;
  74. hlp.EnableApproximation();
  75. hlp.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
  76. hlp.SetLineWeight(5);
  77. hlp.AssignValueColor(if hlp < 0 then Color.RED
  78.                         else if hlp > 0 then Color.GREEN
  79.                         else Color.CYAN);
  80.  
  81. # show zero line
  82. plot zero = 0.0;
  83. zero.SetDefaultColor(Color.WHITE);
  84. zero.SetLineWeight(1);
  85. zero.HideBubble();
  86. zero.HideTitle();
  87.  
  88. def muestra_alerta;
  89. if GetAggregationPeriod() == AggregationPeriod.DAY {
  90.     muestra_alerta = 0;
  91. } else {
  92.     muestra_alerta = 1;
  93. }
  94.  
  95. AddLabel(muestra_alerta, "ALERT this indicator only gives correct information at DAILY", Color.Downtick);
Advertisement
Add Comment
Please, Sign In to add comment