Actually I sync it up right before the opening everyday, but when dealing with a certain indicator I use, I often get a different open price on my 1min chart compared to my 150tick chart, so I decided to look in to solving the issue with grabbing the correct open tick price. My strategy must have the correct open price on both charts.
Here is what I worked out. It may not be the cleanest way to do it, but I wasn't in the mood to study the Microsoft site.
private bool xChange = false; //exChange is about to open
private bool needData = true; //Looking for the true opening price
private double o = 0; //First tick - true opening price
protected override void OnBarUpdate()
{
if (ToTime(Time[0]) >= 72950 && ToTime(Time[0]) <= 73010)
{xChange = true;}
else{xChange = false;}
//More strategy code below here........
}
protected override void OnMarketData(MarketDataEventArgs e)
{
if (xChange)
{
if (e.MarketDataType == MarketDataType.Last)
Print("Time = " + e.Time + " " + e.Price);
if(needData)
{
if (i == 1)
{
o = e.Price;
needData = false;
}
if (ToTime(e.Time) == 73000)
{i = 1;}
}
}
}
insomniac
Comment