OPEN-SOURCE SCRIPT
Strategy Validation Framework - Standardised ATR Exits & 1% Ris

A reusable backtesting template that applies consistent exit conditions to
any entry signal, allowing fair comparison between strategies.
HOW IT WORKS
Exits are driven entirely by ATR (Average True Range). Stop loss is placed
at a configurable multiple of ATR from entry (default: 3x ATR-14). Take
profit is set at a fixed multiple (default: 6x ATR, giving 2:1 R). Position
size is calculated so that the maximum loss on any trade equals a fixed
percentage of current equity (default: 1%), normalising risk across
instruments and account sizes.
WHY THIS EXISTS
Most strategy comparisons produce misleading results because each script
uses different stop distances, lot sizes, and commission assumptions. When
exits are standardised, you isolate the entry signal's actual edge rather
than comparing risk management decisions.
HOW TO USE
1. Paste your indicator logic below the INDICATOR comment line
2. Set longCondition / shortCondition to your entry signals
3. Open Strategy Tester — the framework handles exits, sizing, and costs
The placeholder entry (9/21 EMA cross) is an example only. Replace it.
DEFAULT PROPERTIES
ATR Length: 14 | Stop Loss: 3x ATR | Take Profit: 6x ATR (2:1 R)
Risk per trade: 1% | Commission: 0.01% per side | Slippage: 1 tick
LIMITATIONS
Results depend entirely on the entry logic substituted. The EMA cross
placeholder is for illustration only and does not represent a recommended
strategy. Backtesting results do not guarantee future performance.
any entry signal, allowing fair comparison between strategies.
HOW IT WORKS
Exits are driven entirely by ATR (Average True Range). Stop loss is placed
at a configurable multiple of ATR from entry (default: 3x ATR-14). Take
profit is set at a fixed multiple (default: 6x ATR, giving 2:1 R). Position
size is calculated so that the maximum loss on any trade equals a fixed
percentage of current equity (default: 1%), normalising risk across
instruments and account sizes.
WHY THIS EXISTS
Most strategy comparisons produce misleading results because each script
uses different stop distances, lot sizes, and commission assumptions. When
exits are standardised, you isolate the entry signal's actual edge rather
than comparing risk management decisions.
HOW TO USE
1. Paste your indicator logic below the INDICATOR comment line
2. Set longCondition / shortCondition to your entry signals
3. Open Strategy Tester — the framework handles exits, sizing, and costs
The placeholder entry (9/21 EMA cross) is an example only. Replace it.
DEFAULT PROPERTIES
ATR Length: 14 | Stop Loss: 3x ATR | Take Profit: 6x ATR (2:1 R)
Risk per trade: 1% | Commission: 0.01% per side | Slippage: 1 tick
LIMITATIONS
Results depend entirely on the entry logic substituted. The EMA cross
placeholder is for illustration only and does not represent a recommended
strategy. Backtesting results do not guarantee future performance.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
We test strategies so you don't have to. Research: @backtestbay · Tools: backtestbay.gumroad.com
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.