Infinity Algo Backtest

Stop-loss is now working in backtest
Alert function message
Fixed reverse trading
Changed Colors
New ribbon and channel bands
This update brings the backtesting strategy script in line with the main Infinity Algo V3.0 indicator, incorporating the AI optimization engine and refining the strategy logic and settings.
🚀 Major Updates & New Features:
Pine Script V6 Update: The strategy script has been migrated to Pine Script version 6, enabling the use of newer Pine features and aligning it with the indicator script.
🧠 AI Optimization Engine Integration:
Adaptive Signals: Introduced the "AI" option in the 🔔 Show Signals Type input. When selected and 🧠 Enable AI Optimization is checked, the strategy uses signals generated by the AI engine, which dynamically adapts its parameters based on simulated performance and market volatility.
AI Engine Core: Includes the same core AI logic as the indicator: simulation of configurations, performance evaluation based on selectable metrics (📊 AI Performance Metric), K-Means clustering based on volatility, and dynamic selection of the best configuration for the current market regime.
AI Inputs: Added the 🧠 AI Clustering settings group, allowing configuration of the AI engine (Enable, Update Frequency, Range, Simulation TP/SL%, Performance Metric). Note: The AI Dashboard visualization is not included in the strategy script.
"Opposite Signal" Exit Type: Added a new option to the 🏁 Exit Type input (Opposite Signal) which closes the current position when a signal in the opposite direction occurs.
🧹 Removed Features:
Visualizations Removed:
Keltner Channel Bands
EMA Ribbon
Peak Profit Line. These were primarily visual aids not essential for backtesting logic.
✨ Refinements & Improvements:
Signal Type Input: Added the 🔔 Show Signals Type dropdown (Normal + Smart, Normal Only, etc., including AI), providing explicit control over which signal logic drives the strategy entries, similar to the indicator.
Signal Toggle Logic: Integrated 🔁 Toggle Same Signal Consecutively and 🔄 Next Signal Must Be Opposite Signal inputs to control signal generation behavior consistently with the indicator.
Exit Logic Overhaul:
Refactored the strategy.exit and strategy.close logic to handle the different 🏁 Exit Type options ('Percentage', 'Signals', 'Opposite Signal') more clearly.
Improved handling of partial exits for 'Signals'and 'Percentage' modes.
Ensured Stop Loss is applied correctly across different exit types.
State Management: Improved internal tracking of position state to work reliably with strategy.* functions and the different exit modes.
Settings Organization: Grouped related inputs more logically (e.g., 📊 Strategy Settings, ⚙️ Signal Settings, 🧠 AI Clustering, 💰 Take Profit Settings, 🚪 Exit Settings, 📏 Precision Settings, Alerts), mirroring the indicator's structure.
Alerts:
Code Structure: General refactoring for better readability, consistency with the V3 indicator, and integration of the AI components. Removed redundant code related to visual elements.
Note: As with the indicator, bugs may appear due to the significant changes. Thorough testing across different settings and market conditions is recommended.
The backtesting strategy has been updated in lockstep with the main indicator to ensure its parameters and logic are aligned. This allows for more accurate and reliable backtesting of the new features.
Script sob convite
Somente usuários autorizados pelos autores tem acesso a esses scripts, e isso normalmente requer pagamento. Você pode adicionar o script aos seus favoritos, mas você será capaz somente para usar ele depois de solicitar permissão e permiti-lo do seu autor — saiba mais aqui. Para mais detalhes, siga as instruções dos autores abaixo ou contate InfinityAlgo diretamente.
Observe que esse script privado e sob convite não tem foi revisado por moderadores de scripts, sua conformidade com as Regras da Casa é indeterminado. O TradingView NÃO recomenda pagar ou usar um script ao não ser que você confie totalmente no seu autor e compreende como isso funciona. Você pode também encontrar alternativas gratuitas e de código aberto em nossa comunidade de scripts.
Instruções do autor
Aviso: leia nosso guia para scritps somente sob convite antes de solicitar acesso.
Aviso legal
Script sob convite
Somente usuários autorizados pelos autores tem acesso a esses scripts, e isso normalmente requer pagamento. Você pode adicionar o script aos seus favoritos, mas você será capaz somente para usar ele depois de solicitar permissão e permiti-lo do seu autor — saiba mais aqui. Para mais detalhes, siga as instruções dos autores abaixo ou contate InfinityAlgo diretamente.
Observe que esse script privado e sob convite não tem foi revisado por moderadores de scripts, sua conformidade com as Regras da Casa é indeterminado. O TradingView NÃO recomenda pagar ou usar um script ao não ser que você confie totalmente no seu autor e compreende como isso funciona. Você pode também encontrar alternativas gratuitas e de código aberto em nossa comunidade de scripts.
Instruções do autor
Aviso: leia nosso guia para scritps somente sob convite antes de solicitar acesso.