SuperTrend Strategy

PineConnector
The famous SuperTrend Strategy is modified to be compatible with PineConnector. The down-arrows signify short/sell entries while the up-arrows signify long/buy entries. An alert will automatically be sent to the PineConnector server for the EA on your MT4/5 to generate the necessary trade orders.

Steps to use this strategy:
1) Create a PineScript and attach the code below.
2) Attach the script to your chart.
3) Edit the License ID
4) Create alerts

Recommended EA settings:
1) Hedging (close on reverse): TRUE

//@version=4
strategy("Supertrend Strategy - PineConnector", overlay=true)

atrPeriod = input(10, "ATR Length")
factor = input(3, "Factor")

[supertrend, direction] = supertrend(factor, atrPeriod)

bodyMiddle = plot((open + close) / 2, display=display.none)
upTrend = plot(direction < 0 ? supertrend : na, "Up Trend", color = color.green, style=plot.style_linebr)
downTrend = plot(direction < 0? na : supertrend, "Down Trend", color = color.red, style=plot.style_linebr)

fill(bodyMiddle, upTrend, color.new(color.green, 90), fillgaps=false)
fill(bodyMiddle, downTrend, color.new(color.red, 90), fillgaps=false)

if change(direction) < 0
    strategy.entry("My Long Entry Id", strategy.long)
    alert("LICENSEID,buy,"+syminfo.ticker+",risk=1", alert.freq_once_per_bar_close)

if change(direction) > 0
    strategy.entry("My Short Entry Id", strategy.short)
    alert("LICENSEID,sell,"+syminfo.ticker+",risk=1", alert.freq_once_per_bar_close)

plotshape(change(direction) < 0, style=shape.labelup, location=location.belowbar, color=#046ff9, size=size.large, text='PineConnector \n Buy', textcolor=color.white)
plotshape(change(direction) > 0, style=shape.labeldown, location=location.abovebar, color=#046ff9, size=size.large, text='PineConnector \n Sell', textcolor=color.white)
        

Leave a comment