Getting Started



SuperTrend Strategy

SuperTrend Strategy

Educational Purposes The purpose of this page is to demonstrate how you can fully automate a trading strategy on TradingView using PineConnector. Please note that the focus is not on the profitability of the strategy, if any.

SuperTrend Strategy


The SuperTrend strategy is a well-established and commonly utilized approach to trading has been optimized for use with PineConnector, a software that links TradingView to MetaTrader brokers and prop firms.

This trend-following method can be employed across multiple markets, including forex, stocks, futures, cryptocurrencies, and other financial assets.

With PineConnector, you can fully automate the SuperTrend strategy, making it a suitable solution for both day and swing traders. This allows you to streamline your trading process, freeing up time, minimizing the risk of human error and eliminating emotion in your trading.

Implementation of the Strategy

Before proceeding, please ensure:
  1. PineConnector EA running on your MetaTrader terminal — you should see your license details printed on your chart.
  2. image
  3. Close on Reverse EA setting set as “On — Hedging”.
  4. image

1. Create a new script

At the bottom of your TradingView tab, click "Pine Editor" → “Open” → “Strategy”.


2. Attach the code

Remove the default code generated, and attach the following code:

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

LicenseID = 601234567890 // 1. change to your PineConnector License ID (required) 

riskvalue =, 'Risk Value') // 2. Change the risk value (optional) 
atrPeriod = input(10, 'ATR Length') // 3. Change the ATR length/period (optional)  
factor = input(3, 'Factor') // 4. Change the ATR factor/multiplier (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('Long', strategy.long)
    alert(str.tostring(LicenseID)+',buy,' + syminfo.ticker + ',risk=' + str.tostring(riskvalue), alert.freq_once_per_bar_close)

if ta.change(direction) > 0
    strategy.entry('Short', strategy.short)
    alert(str.tostring(LicenseID)+',sell,' + syminfo.ticker + ',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))
Required Change: Instead of the License ID 601234567890, input your PineConnector License ID you’re entered in the PineConnector EA. It is a long string starting with a 6.

Basic Optional Change:

  • Instead of riskvalue being 1, you may increase or decrease the lot size per trade.
  • How the EA processes this riskvalue depends on your Volume Type in your EA.
    1. image
    2. the default setting of “Lots” will open 1 volume/lot each trade with riskvalue of 1 — use this option if you are a beginner.

Advanced Optional Changes:

  • Instead of atrPeriod of 10, you may increase or shorten the ATR period.
  • Instead of factor of 3, you may tweak the ATR multiplier to your desired value.

3. Save the code and Add Strategy to the Chart

After attaching and amending the above code, click “Save” then “Add to chart” to apply the strategy to your current chart. You should be able to see the SuperTrend entries indicated on the chart:


4. Create alerts

On your desired instrument and timeframe create the alerts.

In this tutorial, we will execute alerts based on EURUSD on the 1 second chart. You may use the 1 minute chart as well. If you EURUSD symbol in the Symbol List (CTRL+U) has a prefix or suffix such as, please add those details in the prefix (i.) and suffix (.mini) section in the EA settings — case sensitive.

To create an alert, press Alt+A (Windows) or Option+A (Mac), and configure your alert as follows:

Supertrend Strategy alert() function calls only
Webhook URL
For PineConnector v2: For PineConnector v3:
Alert name, Notify on app
“Alert name” does not matter ”Notify on app” selection does not matter as well

After proper alert configuration, click “Create”. An active alert will appear under your “Alerts” tab.

With this script, you will only need 1 alert to trigger both buy and sell entries for the current instrument and timeframe — in this example, the EURUSD 1 second chart.
New code? New alert. If you make changes to your code, saving it will not affect pre-existing alerts, which will still use the original code at the time of creation. To implement the updated code, you must delete the old alerts and create a new one.

5. Confirm triggered alerts

When entry conditions are met, an alert will fire. You will see an entry in your TradingView’s Alerts Log indicating the time, alert message, instrument and timeframe it fired based on.

Sky’s not the limit — 15 is While you send in multiple alerts at the same time, note that you can only send a maximum of 15 triggers in 3 minutes for a single alert. Having more than 15 alerts in that period will result in your alerts being paused automatically.

After a alert fires, you should see a corresponding trade entry as per the alert message.

Troubleshooting Trade Issues If you encounter an error or your trades are not triggering, consult the Error Guide for potential causes and solutions: Error Guide
Monitoring for Success For optimal results, it's recommended to regularly monitor the "Experts" tab to gain insights into how the EA processes your alert messages, especially when testing new syntax or adjusting EA settings.

6. Tailor your alerts (optional)

Consider adding a stop-loss, a comment with the position, or even a spread filter.

Relevant Guide
- Discover more about the proper way to write the alert messages - Add more components such as a spread filter
- Utilise a different Volume Type - Implement a Daily Profit or Loss
- Include additional parameters such as stop-loss - Implement dynamic symbols and values
Maximize your Trading Performance: Use Our Broker of Choice To ensure optimal trading performance, we recommend using the same broker that we use for PineConnector testing. In addition, you can trigger your alerts based on the broker's data source available on TradingView, leading to better trading performance. Minimize errors, maximize your trading potential, and ensure the best possible experience with our platform.

Broker of Choice →