Advertisement
fabgonber

Momentum_Alcista_Bajista_Segun_Carpatos

Apr 19th, 2024
1,426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.82 KB | None | 0 0
  1. #
  2. # Momentum/Trend Alcista o Bajista segΓΊn @carpatos
  3. #
  4.  
  5. declare lower;
  6.  
  7. input length = 14;
  8. input alcistas = 60;
  9. input bajistas = 50;
  10. input price = close;
  11. input averageType = AverageType.WILDERS;
  12. input showBreakoutSignals = no;
  13.  
  14. plot limite_alcistas = alcistas;
  15. plot limite_bajistas = bajistas;
  16.  
  17.  
  18. def NetChgAvg = MovingAverage(averageType, price - price[1], length);
  19. def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
  20. def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
  21.  
  22. plot RSI = 50 * (ChgRatio + 1);
  23.  
  24. RSI.DefineColor("bajista", GetColor(5));
  25. RSI.DefineColor("normal", GetColor(7));
  26. RSI.DefineColor("alcista", GetColor(6));
  27. RSI.SetPaintingStrategy(PaintingStrategy.Histogram);
  28.  
  29. RSI.AssignValueColor
  30.        (
  31.         if RSI[2]>alcistas AND RSI[1]>alcistas AND RSI[0]>alcistas  
  32.             then  RSI.color("alcista")
  33.         else
  34.        
  35.         if RSI[2]>alcistas AND RSI[1]>alcistas AND RSI[0]<alcistas  
  36.             then  RSI.color("alcista")
  37.         else
  38.  
  39.         if RSI[2]>alcistas AND RSI[1]<alcistas AND RSI[0]>alcistas  
  40.             then  RSI.color("alcista")
  41.         else
  42.  
  43.         if RSI[2]<alcistas AND RSI[1]>alcistas AND RSI[0]>alcistas  
  44.             then  RSI.color("alcista")
  45.         else
  46.  
  47.         if RSI[2]<bajistas AND RSI[1]<bajistas AND RSI[0]<bajistas  
  48.             then  RSI.color("bajista")
  49.         else
  50.  
  51.         if RSI[2]<bajistas AND RSI[1]<bajistas AND RSI[0]>bajistas  
  52.             then  RSI.color("bajista")        
  53.         else
  54.  
  55.         if RSI[2]<bajistas AND RSI[1]>bajistas AND RSI[0]<bajistas  
  56.             then  RSI.color("bajista")        
  57.         else
  58.         if RSI[2]>bajistas AND RSI[1]<bajistas AND RSI[0]<bajistas  
  59.             then  RSI.color("bajista")
  60.         else
  61.         RSI.color("normal")
  62.  
  63. );
  64.  
  65.  
  66.  
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement