@@ -51,18 +51,23 @@ public override void Initialize()
5151 _stochasticHistory = new Stochastic ( "SECOND" , 14 , 3 , 3 ) ;
5252 RegisterIndicator ( _spy , _stochasticHistory , dailyConsolidator ) ;
5353
54+ // The warm-up period for the Stochastic indicator is calculated as:
55+ // period + kPeriod + dPeriod - 2 = 14 + 3 + 3 - 2 = 18
56+ // To ensure the indicator is fully warmed up, we request a history length
57+ // significantly greater than 18.
58+ var periods = 50 ;
5459 // Get historical data for warming up the stochasticHistory
55- var history = History ( _spy , _stochasticHistory . WarmUpPeriod , Resolution . Daily ) ;
60+ var history = History ( _spy , periods , Resolution . Daily ) ;
5661
5762 // Warm up STO indicator
58- foreach ( var bar in history . TakeLast ( _stochasticHistory . WarmUpPeriod ) )
63+ foreach ( var bar in history )
5964 {
6065 _stochasticHistory . Update ( bar ) ;
6166 }
6267
6368 var indicators = new List < IIndicator > ( ) { _stochasticIndicator , _stochasticHistory } ;
6469
65- // Ensure both are ready
70+ // Ensure both indicators are ready
6671 foreach ( var indicator in indicators )
6772 {
6873 if ( ! indicator . IsReady )
@@ -124,7 +129,7 @@ public override void OnEndOfAlgorithm()
124129 /// <summary>
125130 /// Data Points count of the algorithm history
126131 /// </summary>
127- public int AlgorithmHistoryDataPoints => 36 ;
132+ public int AlgorithmHistoryDataPoints => 68 ;
128133
129134 /// <summary>
130135 /// Final status of the algorithm
0 commit comments