SuperTrend Strategy
Add the published SuperTrend example to TradingView, connect its buy and sell alerts, and verify the result on a demo account.
This walkthrough connects SuperTrend’s direction changes to PineConnector. You will add the published Pine Script v5 example, create one alert for its buy and sell messages, then check the order in MetaTrader.
The code below retains the original Pine v5 version and its settings-dependent sizing. If you choose to upgrade it, follow Convert Pine Script versions and verify the changed script separately. A language upgrade does not establish that alerts, sizing or reversals behave the same way.
Confirm the connection in MetaTrader and the PineConnector Portal, then complete a test alert.
- Your License ID and broker symbol
The example uses the chart ticker. Check that it matches your broker’s exact symbol.
Review Volume Type and Close on Reverse before creating an alert.
1. Prepare the EA settings
Section titled “1. Prepare the EA settings”The published walkthrough uses Close on Reverse → On — Hedging: an opposite entry signal closes the relevant opposite position before opening the new direction. Check Close on Reverse in the EA guide for its scope and interaction with your other settings.
EnlargeThese EA input changes apply to a self-hosted terminal. For Edge, confirm the hosted reversal and sizing settings through Portal or Support; changing a local EA does not change Edge. If Signal Authentication is enabled, add your configured secret= privately to both generated alert messages before creating the alert.
2. Add the script to TradingView
Section titled “2. Add the script to TradingView”Open Pine Editor and create a New strategy. Replace the generated sample with the complete code below.
EnlargeSet your License ID
Section titled “Set your License ID”The value after LicenseID = must be your actual numeric License ID before you create an alert. If it still shows 0, replace that value with the ID from your PineConnector Portal. Leave the variable name LicenseID unchanged.
Check the symbol and trade size
Section titled “Check the symbol and trade size”- Symbol:
syminfo.tickersends the ticker of the chart used for the alert. If your broker uses a different name, follow the symbol-mapping example before continuing. - Risk Value: the default is
1; choose the value appropriate to your EA’s Volume Type and demo test. - ATR Length and Factor: these control SuperTrend’s calculation. The published defaults are
10and3. Changing them changes when the script signals.
Select Save, give the script a recognisable name, then Add to chart.
3. Recognise what appears on the chart
Section titled “3. Recognise what appears on the chart”The script draws SuperTrend lines and blue PineConnector Buy/Sell labels. The strategy also appears in Strategy Tester, which displays simulated historical results for the selected symbol, timeframe and data feed.
EnlargeBeside the script’s name, use the eye to show/hide it, Settings to change inputs, the source-code control to edit it, and the bin to remove it from the chart.
EnlargeIf you are comparing markers with strategy fills, remember that signal calculation and simulated fill timing can differ. See the strategy timing explanation.
4. Create one alert for both directions
Section titled “4. Create one alert for both directions”The published walkthrough suggests a 1-minute chart for observing a test sooner than a daily chart: select that interval before creating the alert. A shorter interval does not guarantee an immediate SuperTrend direction change.
On the symbol and timeframe you intend to test, select Create alert and configure:
| Field | Choose |
|---|---|
| Condition | Your saved SuperTrend strategy |
| Event type | alert() function calls only |
| Webhook URL | The PineConnector URL below |
| Alert name | A name that identifies the script, symbol and timeframe |
Enable Webhook URL in the alert’s notification settings.
Choose Create. This script supplies the buy and sell messages, so one alert can listen to both directions. Do not select Order fills and alert() function calls for this setup: that adds a separate event source.
5. Verify the full path on a demo account
Section titled “5. Verify the full path on a demo account”Wait for a new real-time direction change. Adding the script does not send every historical signal.
- TradingView Alerts log: open the triggered alert and inspect its message. Confirm the License ID, buy/sell direction, symbol and risk value.
- PineConnector Signals log: find the corresponding received message and check its processing status.
- MetaTrader: check the account, symbol, order direction and volume. Read the Experts output for how the EA handled the message.
- Opposite signal: with the stated reversal setup, verify the close-and-open behaviour on demo. Confirm there is no unexpected duplicate or remaining opposite position.
If TradingView stops the alert for triggering too often, check its status and the regular-alert limit of 15 triggers in three minutes before restarting it.
| What you see | Where to look next |
|---|---|
| Chart marker, but no alert-log entry | Check the alert is running on the intended saved script and event type. |
| TradingView fired, but PineConnector has no message | Check the webhook and License ID; follow Missing signals. |
| PineConnector received it, but the trade is wrong or absent | Read the full processing/Experts error and use Errors. |
| More than one trade per event | Check duplicate alerts and EA/connection setup before another test. |
Video walkthrough
Section titled “Video walkthrough”Published SuperTrend setup walkthrough
Written summary
Create the strategy, replace its License ID, choose the appropriate EA settings, create an alert for alert() calls, and confirm the message in TradingView, PineConnector and MetaTrader.
Continue from a working example
Section titled “Continue from a working example”Use Add alerts to your script to understand the code or build dynamic messages. Review Best Practices & Tips before expanding to more symbols or accounts.
Browse Strategy examples for the other existing walkthrough, or Learn PineConnector for version conversion and alert tools.

