Advertisement
danucante

Untitled

Nov 23rd, 2023
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. fastLength = input(title='MACD Fast Length', defval=9)
  2. slowLength = input(title='MACD Slow Length', defval=34)
  3. cycleLength = input(title='Cycle Length', defval=11)
  4. d1Length = input(title='1st %D Length', defval=1)
  5. d2Length = input(title='2nd %D Length', defval=4)
  6. src = close
  7. upper = 75
  8. lower = 25
  9.  
  10. macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
  11. k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
  12. d = ta.ema(k, d1Length)
  13. kd = nz(fixnan(ta.stoch(d, d, d, cycleLength)))
  14. stc = ta.ema(kd, d2Length)
  15. stc := math.max(math.min(stc, 100), 0)
  16.  
  17.  
  18. buySignal = ta.crossover(stc, lower)
  19. sellSignal = ta.crossunder(stc, upper)
  20.  
  21.  
  22. // rsi
  23. rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
  24. rsiSourceInput = input.source(close, group="RSI Settings")
  25. uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
  26. downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
  27. rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
  28.  
  29. rsi2 = ta.rsi(close, 5)
  30.  
  31. RSI_long = rsi2 > 50
  32. RSI_short = rsi2 < 50
  33. // RSI_long = ta.crossover(rsi2, 50)
  34. // RSI_short = ta.crossunder(rsi2, 50)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement