OPEN-SOURCE SCRIPT
LinReg Scale-In Strategy

This strategy is based on an basic LinReg concept. Instead of using traditional price levels or moving averages, it uses the Linear Regression Correlation Coefficient (Pearson's r) to measure the actual strength of a trend and dynamically build up a position.
How it works:
The indicator calculates how closely the price follows a linear trend, returning a value between -1 and +1.
Scale-In (Entries): The strategy enters a Long position step-by-step as the uptrend gains momentum. It adds to the position when the coefficient crosses above the 0.25, 0.50, and 0.75 thresholds (pyramiding up to 3 times).
Scale-Out (Exit): Following the "let profits run but cut losses quick" mentality, the strategy closes the entire position as soon as the trend starts dying out and the coefficient crosses back down below 0.25.
Setup Tip: It is recommended using this approach on commodities using the Daily timeframe. The strategy is set to fixed contracts by default to allow smooth backtesting on futures like NQ or ES without running into margin limits.
Disclaimer:
This script is published for educational and testing purposes only. It does not constitute financial advice. Trading futures and other financial instruments involves significant risk of loss. Past performance is not indicative of future results. Always do your own research and backtesting before risking real capital.
How it works:
The indicator calculates how closely the price follows a linear trend, returning a value between -1 and +1.
Scale-In (Entries): The strategy enters a Long position step-by-step as the uptrend gains momentum. It adds to the position when the coefficient crosses above the 0.25, 0.50, and 0.75 thresholds (pyramiding up to 3 times).
Scale-Out (Exit): Following the "let profits run but cut losses quick" mentality, the strategy closes the entire position as soon as the trend starts dying out and the coefficient crosses back down below 0.25.
Setup Tip: It is recommended using this approach on commodities using the Daily timeframe. The strategy is set to fixed contracts by default to allow smooth backtesting on futures like NQ or ES without running into margin limits.
Disclaimer:
This script is published for educational and testing purposes only. It does not constitute financial advice. Trading futures and other financial instruments involves significant risk of loss. Past performance is not indicative of future results. Always do your own research and backtesting before risking real capital.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.