10v5 - SSL + T3 Strategy With ADX+EMA Filter
10v5 - SSL + T3 Strategy With ADX+EMA Filter
strategy("NNFX Style Strategy with ADX, EMA, ATR SL and TP", overlay=true)
// SSL Channel
period = input.int(title="SSL Period", defval=140)
smaHigh = ta.sma(high, period)
smaLow = ta.sma(low, period)
var float Hlv = na
Hlv := close > smaHigh ? 1 : close < smaLow ? -1 : nz(Hlv[1])
sslDown = Hlv < 0 ? smaHigh : smaLow
sslUp = Hlv < 0 ? smaLow : smaHigh
// T3 Indicator
length_fast = input.int(40, minval=1, title="Fast T3 Length")
length_slow = input.int(90, minval=1, title="Slow T3 Length")
b = 0.7
// ADX Calculation
adxlen = input.int(100, title="ADX Smoothing")
dilen = input.int(110, title="DI Length")
dirmov(len) =>
up = ta.change(high)
down = -ta.change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
truerange = ta.rma(ta.tr(true), len)
plus = nz(100 * ta.rma(plusDM, len) / truerange)
minus = nz(100 * ta.rma(minusDM, len) / truerange)
[plus, minus]
// Strategy Logic
longCondition = ta.crossover(t3_fast, t3_slow) and adx_value > adx_ema and Hlv > 0
shortCondition = ta.crossunder(t3_fast, t3_slow) and adx_value > adx_ema and Hlv <
0
// Debug plots
plotshape(series=longCondition, location=location.belowbar, color=color.green,
style=shape.labelup, text="LONG")
plotshape(series=shortCondition, location=location.abovebar, color=color.red,
style=shape.labeldown, text="SHORT")
if (longCondition)
stopLoss = close - atr_stop_loss_multiplier * atr
takeProfit = close + atr_take_profit_multiplier * atr
strategy.entry("Long", strategy.long)
strategy.exit("Long TP/SL", from_entry="Long", stop=stopLoss, limit=takeProfit)
if (shortCondition)
stopLoss = close + atr_stop_loss_multiplier * atr
takeProfit = close - atr_take_profit_multiplier * atr
strategy.entry("Short", strategy.short)
strategy.exit("Short TP/SL", from_entry="Short", stop=stopLoss,
limit=takeProfit)
if (exitLongCondition)
strategy.close("Long")
if (exitShortCondition)
strategy.close("Short")