Using Playback with market replay selected, I load 1 day of market replay data into a 200 volume chart of the CL on which I have an indicator with a sound alert (using PlaySound()). In the indicator I have the requisite encapsulating code as follows:
if ((State != State.Historical) && (IsFirstTickOfBar))
{
if (High[0] > High[1]) { PlaySound(@BuyAlertSound);}
}
On the Playback/Market Replay control I select a start date and time to load the chart with the market replay data. The chart starts constructing itself and as the data is loading the alert sound starts triggering in rapid fire succession. Just to be clear, playback is not running yet, all that is happening is the chart is populating, filling in the market replay data to the start time selected.
So I thought to myself, how is this possible ? I then decided to put a Print() statement just above that first if (State!=Historical...) statement to print the current state variable along with the bar number, and what shows up in the output window is about 1100 bars are loaded with the State of Historical, then all the bars after that, about another 2000 bars are loaded with a State of Realtime. Obviously these later bars that are loaded with the Realtime state are 'getting though' my protective if (State != Historical) and allowing the code inside to execute (resulting in the sound alert repeatedly triggering while the chart populates). So at the end of the day, my question here is simply, why is Market Replay changing the State variable from Historical to Realtime midway through the chart data population process ?
With all this said, this is code that I am porting into NT8 from NT7, which of course has been working perfectly fine in NT7 for many years. I have never encountered this type of behavior with Market Replay before in NT7, so assume it is either a new feature or a bug.
Thank you for your consideration and guidance.
Comment