MACD PULBA CHART REDDIT COMMENT SCRIPT by ITCHY
MACD PULBA CHART REDDIT COMMENT SCRIPT by ITCHY
// RSI
rsi_len = input.int(14, title="RSI Length")
rsi_lvl1 = input.int(70, title="RSI Overbought Level")
rsi_lvl2 = input.int(30, title="RSI Oversold Level")
rsi = ta.rsi(close, rsi_len)
// PULBA
pulba_len = input.int(20, title="PULBA Length")
pulba_up = ta.highest(high, pulba_len)
pulba_dn = ta.lowest(low, pulba_len)
// MACD
macd_fast = input.int(12, title="MACD Fast Length")
macd_slow = input.int(26, title="MACD Slow Length")
macd_sig = input.int(9, title="MACD Signal Length")
[macd_line, macd_signal, _] = ta.macd(close, macd_fast, macd_slow, macd_sig)
// Williams %R
wpr_len = input.int(14, title="Williams %R Length")
wpr_lvl1 = input.int(-20, title="Williams %R Overbought Level")
wpr_lvl2 = input.int(-80, title="Williams %R Oversold Level")
wpr = ta.wma(((ta.highest(high, wpr_len) - close) / (ta.highest(high, wpr_len) - ta.lowest(low,
wpr_len))) * -100, 9)
// Plotting
plot(rsi, title="RSI", color=color.blue)
hline(rsi_lvl1, "RSI Overbought", color=color.red, linestyle=hline.style_dashed)
hline(rsi_lvl2, "RSI Oversold", color=color.green, linestyle=hline.style_dashed)
// Strategy
long_condition = (rsi < rsi_lvl2) and (close > pulba_up) and (macd_line > macd_signal) and (wpr <
wpr_lvl2)
short_condition = (rsi > rsi_lvl1) and (close < pulba_dn) and (macd_line < macd_signal) and (wpr >
wpr_lvl1)
if (long_condition)
strategy.entry("Long", strategy.long)
if (short_condition)
strategy.entry("Short", strategy.short)
// Exits
stop_loss = input.float(0.5, title="Stop Loss (%)") * 0.01
take_profit = input.float(1, title="Take Profit (%)") * 0.01
strategy.exit("Long Exit", "Long", stop=close * (1 - stop_loss), limit=close * (1 + take_profit))
strategy.exit("Short Exit", "Short", stop=close * (1 + stop_loss), limit=close * (1 - take_profit))