PROTECTED SOURCE SCRIPT
Best Profitable Hours Strategy with TP/SL

Core Concept:
Trades only during historically most profitable market hours (based on specified lookback period)
Input Parameters:
Lookback period (5-30+ days)
Number of top profitable hours to trade (1-6)
Long/short trade enable/disable
Customizable TP/SL percentages
Data Processing:
Tracks hourly returns in 24-element arrays
Resets calculations daily at market close
Ranks hours by profitability using array sorting
Trading Logic:
Entries only during top-performing hours
Position sizing: 100% margin allocation
Automatic exit at end of each trading hour
0.1% commission per trade
Risk Management:
Percentage-based take profit orders
Percentage-based stop loss orders
Separate TP/SL for long and short positions
Visual Features:
Blue background highlighting best trading hours
Triangle markers for entry points
Real-time TP/SL level indicators (circles)
Color-coded signals (green=long, red=short)
Position Handling:
Prevents multiple entries in same hour
Closes all positions when best-hour window ends
Uses average entry price for TP/SL calculation
Optimization:
Adjustable historical analysis period
Customizable number of trading hours
Flexible TP/SL ratios
The strategy combines historical hour performance analysis with active trade management through TP/SL orders, providing visual feedback for trading decisions while maintaining strict hour-based position control
Trades only during historically most profitable market hours (based on specified lookback period)
Input Parameters:
Lookback period (5-30+ days)
Number of top profitable hours to trade (1-6)
Long/short trade enable/disable
Customizable TP/SL percentages
Data Processing:
Tracks hourly returns in 24-element arrays
Resets calculations daily at market close
Ranks hours by profitability using array sorting
Trading Logic:
Entries only during top-performing hours
Position sizing: 100% margin allocation
Automatic exit at end of each trading hour
0.1% commission per trade
Risk Management:
Percentage-based take profit orders
Percentage-based stop loss orders
Separate TP/SL for long and short positions
Visual Features:
Blue background highlighting best trading hours
Triangle markers for entry points
Real-time TP/SL level indicators (circles)
Color-coded signals (green=long, red=short)
Position Handling:
Prevents multiple entries in same hour
Closes all positions when best-hour window ends
Uses average entry price for TP/SL calculation
Optimization:
Adjustable historical analysis period
Customizable number of trading hours
Flexible TP/SL ratios
The strategy combines historical hour performance analysis with active trade management through TP/SL orders, providing visual feedback for trading decisions while maintaining strict hour-based position control
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Korumalı komut dosyası
Bu komut dosyası kapalı kaynak olarak yayınlanmaktadır. Ancak, özgürce ve herhangi bir sınırlama olmaksızın kullanabilirsiniz – daha fazla bilgi burada.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.