OPEN-SOURCE SCRIPT
Advanced Strategy Template

This script is a strategy execution and risk-management template designed to test external indicators under consistent and repeatable conditions.
The script does not generate buy or sell signals internally. All trade entries and exits are driven by a user-supplied indicator through a numeric connector. This design intentionally separates signal generation from trade execution, allowing users to evaluate indicators without rewriting strategy logic.
Purpose and Originality
The purpose of this template is to provide a standardized execution framework rather than a trading methodology.
Instead of embedding a specific signal logic, the script focuses on how trades are managed after a signal occurs. This allows users to:
This makes the script suitable for educational testing and experimentation, not for presenting a profitable strategy.
How the Signal Connector Works
The strategy listens to a single numeric data source supplied by an external indicator.
The indicator must output values using the following convention:
1 → open long position
-1 → open short position
0 → no action
Optional:
2 → custom close for long
-2 → custom close for short
The strategy reacts only to these values and ignores all other indicator logic.
Example Connector Code (Indicator Side)
Users must add the following logic to their indicator to make it compatible with this template:
// Strategy Connector
// 1 = Buy
// -1 = Sell
// 0 = No Signal
signal = buySignal ? 1 : sellSignal ? -1 : 0
plot(signal, title="Connector", display=display.none)
buySignal and sellSignal represent the indicator’s own conditions
The connector plot is hidden and used only as a data source
How to Connect the Indicator to the Strategy
The strategy will not execute trades unless a valid connector signal is received.
Execution and Risk-Management Features
This template provides configurable execution modules including:
All execution logic operates independently of the signal source.
Strategy Properties and Results
Default strategy properties are intentionally conservative and provided only as a demonstration baseline.
Backtest results depend entirely on:
Results shown by this template do not represent a trading edge and should not be interpreted as investment advice.
Intended Use
This script is intended for:
It is not intended to promote or present a standalone trading strategy.
The script does not generate buy or sell signals internally. All trade entries and exits are driven by a user-supplied indicator through a numeric connector. This design intentionally separates signal generation from trade execution, allowing users to evaluate indicators without rewriting strategy logic.
Purpose and Originality
The purpose of this template is to provide a standardized execution framework rather than a trading methodology.
Instead of embedding a specific signal logic, the script focuses on how trades are managed after a signal occurs. This allows users to:
- Benchmark different indicators under identical execution rules
- Compare stop-loss and take-profit models objectively
- Study the impact of risk constraints on performance
- Reduce bias caused by inconsistent trade management
This makes the script suitable for educational testing and experimentation, not for presenting a profitable strategy.
How the Signal Connector Works
The strategy listens to a single numeric data source supplied by an external indicator.
The indicator must output values using the following convention:
1 → open long position
-1 → open short position
0 → no action
Optional:
2 → custom close for long
-2 → custom close for short
The strategy reacts only to these values and ignores all other indicator logic.
Example Connector Code (Indicator Side)
Users must add the following logic to their indicator to make it compatible with this template:
// Strategy Connector
// 1 = Buy
// -1 = Sell
// 0 = No Signal
signal = buySignal ? 1 : sellSignal ? -1 : 0
plot(signal, title="Connector", display=display.none)
buySignal and sellSignal represent the indicator’s own conditions
The connector plot is hidden and used only as a data source
How to Connect the Indicator to the Strategy
- Add the indicator (with connector output) to the chart
- Add this strategy template to the same chart
- Open the strategy’s settings
- Set Data source to the indicator’s Connector plot
- Configure risk, stop-loss, and take-profit settings as required
The strategy will not execute trades unless a valid connector signal is received.
Execution and Risk-Management Features
This template provides configurable execution modules including:
- Position sizing and pyramiding control
- Maximum drawdown and intraday loss limits
- Consecutive win, loss, and losing-day limits
- Stop-loss methods (percent, trailing, ATR, structure-based)
- Take-profit models (single target, tiered targets, risk-reward, Fibonacci levels)
- Optional breakeven logic
- Session-based trading control
All execution logic operates independently of the signal source.
Strategy Properties and Results
Default strategy properties are intentionally conservative and provided only as a demonstration baseline.
Backtest results depend entirely on:
- The connected indicator
- Market and timeframe selection
- User-defined execution parameters
Results shown by this template do not represent a trading edge and should not be interpreted as investment advice.
Intended Use
This script is intended for:
- Educational study of trade execution and risk control
- Indicator benchmarking under identical execution rules
- Exploring how exits and risk constraints influence outcomes
It is not intended to promote or present a standalone trading strategy.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Automate TradingView alerts to brokers no coding needed. Trade futures, forex, or crypto, copy trades across unlimited accounts, & control risk with ease.
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Automate TradingView alerts to brokers no coding needed. Trade futures, forex, or crypto, copy trades across unlimited accounts, & control risk with ease.
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
For Tradovate: bit.ly/4a1KBrY
For all other supported brokers: bit.ly/4qEbU2G
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.