Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fastLength = input(title='MACD Fast Length', defval=9)
- slowLength = input(title='MACD Slow Length', defval=34)
- cycleLength = input(title='Cycle Length', defval=11)
- d1Length = input(title='1st %D Length', defval=1)
- d2Length = input(title='2nd %D Length', defval=4)
- src = close
- upper = 75
- lower = 25
- macd = ta.ema(src, fastLength) - ta.ema(src, slowLength)
- k = nz(fixnan(ta.stoch(macd, macd, macd, cycleLength)))
- d = ta.ema(k, d1Length)
- kd = nz(fixnan(ta.stoch(d, d, d, cycleLength)))
- stc = ta.ema(kd, d2Length)
- stc := math.max(math.min(stc, 100), 0)
- buySignal = ta.crossover(stc, lower)
- sellSignal = ta.crossunder(stc, upper)
- // rsi
- rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
- rsiSourceInput = input.source(close, group="RSI Settings")
- uprsi = ta.rma(math.max(ta.change(rsiSourceInput), 0), rsiLengthInput)
- downrsi = ta.rma(-math.min(ta.change(rsiSourceInput), 0), rsiLengthInput)
- rsi = downrsi == 0 ? 100 : uprsi == 0 ? 0 : 100 - (100 / (1 + uprsi / downrsi))
- rsi2 = ta.rsi(close, 5)
- RSI_long = rsi2 > 50
- RSI_short = rsi2 < 50
- // RSI_long = ta.crossover(rsi2, 50)
- // RSI_short = ta.crossunder(rsi2, 50)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement