I have a sporadic problem where a particular strategy sometimes blocks data from being received on all other charts. The if I disable the strategy, the charts would then be flooded with all the data that they should have been processing.
I am using OnMarketData(MarketDataEventArgs e) routine from which I call every function in the strategy one the currentbar has changed. It also replace onbarupdate for me in this case as well.
Is there anything I can look at to determine if I have locked threads of Files that would block Ninjatrader incoming market data and make it queue in line until the strategy is disable and then process as normal?
if (Bars.Count <= 100)
return;
if(State ==State.Realtime )
if (CurrentBar>100)
if (CallOnce==false)
{
CallOnce=true;
}
if (State !=State.Realtime)
return;
try
{
if (BarsInProgress !=0)
return;
if (Sim22_VsaMaV1(Close, 50).IsValidDataPointAt(1) == false )
return;
else
{
Draw.Diamond(this,"sims"+ CurrentBar%10+1, false, 1,Sim22_VsaMaV1(Close, 50)[1], Brushes.Turquoise);
}
if ((ToTime(Time[0]) > 160000) && MarketPosition.Flat != Positions[TradeSeries].MarketPosition && Flatten ==false)
{
ExitLong();
ExitShort();
Flatten=true;
}
if (Time[0].Ticks >= startTime.Ticks && startBarIndex == 0)
startBarIndex = CurrentBar;
if (startBarIndex > 0 && startBarIndex == CurrentBar)
Draw.Diamond(this,"Start Tag", false, 0, High[0] + TickSize, Brushes.Turquoise);
/// THis Section different?
if (lastBar != CurrentBar)
{ RealBars++;
if(WeakHead.IsValidDataPoint(1))
{
Draw.TriangleDown(this,"WeakHead" + CurrentBar, false,1, High[1] + 3 * TickSize, Brushes.Purple);
Draw.TriangleDown(this,"WeakHead2" + CurrentBar, false,1, High[1] + 5 * TickSize, Brushes.Purple);
}
if(WeakBottom.IsValidDataPoint(1))
{
Draw.TriangleUp(this,"WeakBottom" + CurrentBar, false,1, High[1] - 3 * TickSize, Brushes.Purple);
Draw.TriangleUp(this,"WeakBottom2" + CurrentBar, false,1, High[1] - 5 * TickSize, Brushes.Purple);
}
Analyse();
NewBarUpdate();
volumeInfoL[lastarrayVal].Clear();
lastarrayVal=activearray;
if (activearray==19)
{activearray=0;}
else
{activearray++;}
lastBar = CurrentBar;
volumeInfoC.Clear();
//DrawZones();
}
// End Difference
if (e.MarketDataType == MarketDataType.Ask)
{
askPrice = e.Price;
return;
}
if (e.MarketDataType == MarketDataType.Bid)
{
bidPrice = e.Price;
return;
}
if ( ChartControl == null || askPrice == 0 || bidPrice == 0)
return;
if (e.MarketDataType == MarketDataType.Last)
{// Print(GetCurrentAsk() + " Using " + askPrice);
double price = e.Price;
long volume = e.Volume;
if (!volumeInfoL[activearray].ContainsKey(price))
volumeInfoL[activearray].Add(price, new VolumeInfoItem());
VolumeInfoItem volumeInfoItem = volumeInfoL[activearray][price];
if (price > LastSeen)
{ volumeInfoItem.up += volume;
// Print("buy");
}
else
{ if (price <LastSeen)
{ volumeInfoItem.down += volume;
//Print("sell");
}
else
{
if (price >bidPrice)
{volumeInfoItem.up += volume;
//Print("buy");
}
else
{//Print("sell");
volumeInfoItem.down += volume;
}
}
}
LastSeen=price;
CreateFootPrint(); //thisone
}
}
catch (Exception f)
{
// Outputs the error to the log
Log(f.ToString(), NinjaTrader.Cbi.LogLevel.Error);
Print("string Error" + f.ToString());
throw;
}
}
Comment