INVITE-ONLY SCRIPT
已更新 Backtest - Strategy Builder [AlgoAlpha]

🟠OVERVIEW
This script by AlgoAlpha is a modular Strategy Builder designed to let traders test custom trade entry and exit logic on TradingView without writing their own Pine code. It acts as a framework where users can connect multiple external signals, chain them in sequences, and run backtests with built-in leverage, margin, and risk controls. Its main strength is flexibility—you can define up to five sequential steps for entry and exit conditions on both long and short sides, with logic connectors (AND/OR) controlling how conditions combine. This lets you test complex multi-step confirmation workflows in a controlled, visual backtesting environment.
🟠CONCEPTS
The system works by linking external signals—these can be values from other indicators, and/or custom sources—to conditional checks like “greater than,” “less than,” or “crossover.” You can stack these checks into steps, where all conditions in a step must pass before the sequence moves to the next. This creates a chain of logic that must be completed before a trade triggers. On execution, the strategy sizes positions according to your chosen leverage mode (Cross or Isolated) and allocation method (Percent of equity or absolute USD value]). Liquidation prices are simulated for both modes, allowing realistic margin behaviour in testing. The script also tracks performance metrics like Sharpe, Sortino, profit factor, drawdown, and win rate in real time.
🟠FEATURES
🟠USAGE
Add the strategy to your chart. In the settings, under Master Settings, enable longs/shorts, select leverage mode, set leverage multipliers, and define position sizing. Then, configure your Long Trigger and Short Trigger groups: turn on conditions, pick which external signal they reference, choose the comparison type, and assign them to a sequence step. For exits, use the corresponding Exit Long Trigger and Exit Short Trigger groups, with the option to link exits to opposite-side entries for auto-flips. You can also enable TP and/or SL exits with custom sources for the TP/SL levels. Once set, the strategy will simulate trades, show performance stats in the on-chart table, and highlight any configuration issues before execution. This makes it suitable for testing both simple single-signal systems and complex, multi-filtered strategies under realistic leverage and margin constraints.
🟠EXAMPLE
The backtester on its own does not contain any indicator calculation; it requires input from external indicators to function. In this example, we'll be using AlgoAlpha's Smart Signals Assistant indicator to demonstrate how to build a strategy using this script.
We first define the conditions beforehand:
Entry:
Exit
Other Parameters (⚠️Example only, tune this based on proper risk management and settings)
Steps
It is important to note that the strategy provided above is just an example, and the complexity of possible strategies stretches beyond what was shown in this short demonstration. Always incorporate proper risk management and ensure thorough testing before trading with live capital.
This script by AlgoAlpha is a modular Strategy Builder designed to let traders test custom trade entry and exit logic on TradingView without writing their own Pine code. It acts as a framework where users can connect multiple external signals, chain them in sequences, and run backtests with built-in leverage, margin, and risk controls. Its main strength is flexibility—you can define up to five sequential steps for entry and exit conditions on both long and short sides, with logic connectors (AND/OR) controlling how conditions combine. This lets you test complex multi-step confirmation workflows in a controlled, visual backtesting environment.
🟠CONCEPTS
The system works by linking external signals—these can be values from other indicators, and/or custom sources—to conditional checks like “greater than,” “less than,” or “crossover.” You can stack these checks into steps, where all conditions in a step must pass before the sequence moves to the next. This creates a chain of logic that must be completed before a trade triggers. On execution, the strategy sizes positions according to your chosen leverage mode (Cross or Isolated) and allocation method (Percent of equity or absolute USD value]). Liquidation prices are simulated for both modes, allowing realistic margin behaviour in testing. The script also tracks performance metrics like Sharpe, Sortino, profit factor, drawdown, and win rate in real time.
🟠FEATURES
- Up to 5 sequential steps for both long and short entries, each with multiple conditions linked by AND/OR logic.
- Two leverage modes (Cross and Isolated) with independent long/short leverage multipliers.
- Separate multi-step exit triggers for longs and shorts, with optional TP/SL levels or opposite-side triggers for flipping positions.
- Position sizing by equity percent or fixed USD amount, applied before leverage.
- Realistic liquidation price simulation for margin testing.
- Built-in trade gating and validation—prevents trades if configuration rules aren’t met (e.g., no exit defined for an active side).
- Full performance dashboard table showing live strategy status, warnings, and metrics.
- Configurable bar coloring based on position side and TP/SL level drawing on chart.
- Integration with TradingView's strategy backtester, allowing users to view more detailed metrics and test the strategy over custom time horizons.
🟠USAGE
Add the strategy to your chart. In the settings, under Master Settings, enable longs/shorts, select leverage mode, set leverage multipliers, and define position sizing. Then, configure your Long Trigger and Short Trigger groups: turn on conditions, pick which external signal they reference, choose the comparison type, and assign them to a sequence step. For exits, use the corresponding Exit Long Trigger and Exit Short Trigger groups, with the option to link exits to opposite-side entries for auto-flips. You can also enable TP and/or SL exits with custom sources for the TP/SL levels. Once set, the strategy will simulate trades, show performance stats in the on-chart table, and highlight any configuration issues before execution. This makes it suitable for testing both simple single-signal systems and complex, multi-filtered strategies under realistic leverage and margin constraints.
🟠EXAMPLE
The backtester on its own does not contain any indicator calculation; it requires input from external indicators to function. In this example, we'll be using AlgoAlpha's Smart Signals Assistant indicator to demonstrate how to build a strategy using this script.
We first define the conditions beforehand:
Entry:
- Longs – SSA Bullish signal (strong OR weak)
- Shorts – SSA Bearish signal (strong OR weak)
Exit
- Longs/Shorts: (TP/SL hit OR opposing signal fires)
Other Parameters (⚠️Example only, tune this based on proper risk management and settings)
- Long Leverage: default (3x)
- Short Leverage: default (3x)
- Position Size: default (10% of equity)
Steps
- Load up the required indicators (in this example, the Smart Signals Assistant).
- Ensure the required plots are being output by the indicator properly (signals and TP/SL levels are being plotted).
- Open the Strategy Builder settings and scroll down to "CONDITION SETUP"; input the signals from the external indicator.
- Configure the exit conditions, add in the TP/SL levels from the external indicator, and add an additional exit condition → {{Opposite Direction}} Entry Trigger.
- After configuring the entry and exit conditions, the strategy should now be running. You can view information on the strategy in TradingView's backtesting report and also in the Strategy Builder's information table (default top right corner).
It is important to note that the strategy provided above is just an example, and the complexity of possible strategies stretches beyond what was shown in this short demonstration. Always incorporate proper risk management and ensure thorough testing before trading with live capital.
版本注释
- Added step based condition invalidation options版本注释
Update:- Added OR/AND NOT options in the Logic Gates
- Added Rising/Falling options in Comparison operators
仅限邀请脚本
只有经作者批准的用户才能访问此脚本。您需要申请并获得使用权限。该权限通常在付款后授予。如需了解更多详情,请按照以下作者的说明操作,或直接联系AlgoAlpha。
除非您完全信任其作者并了解脚本的工作原理,否則TradingView不建议您付费或使用脚本。您还可以在我们的社区脚本中找到免费的开源替代方案。
作者的说明
Get access to this indicator at https://algoalpha.io or visit https://discord.gg/xCmqTVRexz
提醒:在请求访问权限之前,请阅读仅限邀请脚本指南。
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/algoalpha
❓Do you have feedback or indicator ideas? Join our server to tell us about it!
🛜Get FREE signals: discord.gg/algoalpha
❓Do you have feedback or indicator ideas? Join our server to tell us about it!
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
仅限邀请脚本
只有经作者批准的用户才能访问此脚本。您需要申请并获得使用权限。该权限通常在付款后授予。如需了解更多详情,请按照以下作者的说明操作,或直接联系AlgoAlpha。
除非您完全信任其作者并了解脚本的工作原理,否則TradingView不建议您付费或使用脚本。您还可以在我们的社区脚本中找到免费的开源替代方案。
作者的说明
Get access to this indicator at https://algoalpha.io or visit https://discord.gg/xCmqTVRexz
提醒:在请求访问权限之前,请阅读仅限邀请脚本指南。
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/algoalpha
❓Do you have feedback or indicator ideas? Join our server to tell us about it!
🛜Get FREE signals: discord.gg/algoalpha
❓Do you have feedback or indicator ideas? Join our server to tell us about it!
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。