SuperTrend Strategy

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.
*Updated from PineScript Version 4 to Version 5

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. Edit the ATR period & Factor (Optional)
  5. Save the code, and click "Add to Chart"
  6. Create alerts
    1. After changing anything from (3 or 4), please create a new alert
    2. Please ensure you select Supertrend strategy (PineConnector) when creating an alert, and select alert() function calls onlysupertrend strategy pineconnector

Recommended EA settings:
  1. Volume Type: Percentage of account balance
    1. Assuming risk=1 and $1000 account, the EA will compute the position size whereby when the trade hits SL, you will lose 1% or $10.
  2. Hedging (close on reverse): TRUE
    1. Then open buy position will be closed first followed by the open of a sell, upon receipt of a sell signal - and vice versa


strategy('Supertrend Strategy - PineConnector', overlay=true)

LicenseID = 50123456789 // 1. change to your PineConnector License ID 

atrPeriod = input(10, 'ATR Length') // 2. Change the ATR length/period (optional)  
factor = input(3, 'Factor') // 3. Change the ATR factor/multiplier (optional)  
riskvalue =, 'Risk Value', tooltip='The volume executed will be based on your EA Settings on your MT4/5') // 4. Change the risk value (optional)  

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

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

fill(bodyMiddle, upTrend,, 90), fillgaps=false)
fill(bodyMiddle, downTrend,, 90), fillgaps=false)

if ta.change(direction) < 0
    strategy.entry('My Long Entry Id', strategy.long)
    alert(str.tostring(LicenseID)+',buy,' + syminfo.ticker + ',sl=' + str.tostring(supertrend) + ',risk=' + str.tostring(riskvalue), alert.freq_once_per_bar_close)

if ta.change(direction) > 0
    strategy.entry('My Short Entry Id', strategy.short)
    alert(str.tostring(LicenseID)+',sell,' + syminfo.ticker + ',sl=' + str.tostring(supertrend) + ',risk=' + str.tostring(riskvalue), alert.freq_once_per_bar_close)

plotshape(ta.change(direction) < 0, style=shape.labelup, location=location.belowbar,, 0), size=size.large, text='PineConnector \n Buy',, 0))
plotshape(ta.change(direction) > 0, style=shape.labeldown, location=location.abovebar,, 0), size=size.large, text='PineConnector \n Sell',, 0))



  • It works fine, long term on Heiken Ashi candles. Short term I see no chance.

  • Has anyone set this up with any pairs and come out profitable in any capacity?


Leave a comment