The problem I am having is that occasionally (once ever 10-30 seconds) ES data will appear on the EURUSD chart and vise versa. It is not critical in this use but I am concerned this may happen in other instances where it matters.
Below is the OnBarUpdate method I am using:
protected override void OnBarUpdate()
{
//Add your custom indicator logic here.
volume = Volume[0];
double count=0, avgATR;
string strCount="";
if (CurrentBar<30) return;
if (State == State.Historical) return;
volume = Volume[0];
avgATR=EMA(ATR(atrPeriod),4)[1];
if (IsFirstTickOfBar)
{ playedAlert = false;
trend=0;
for (int i=1; i<=12; i++)
trend = trend + ZLEMA(21)[i]-EMA(20)[i];
trend = trend/avgATR;
}
// tick counter2
if (BarsPeriod.BarsPeriodType == BarsPeriodType.Tick)
{ // calculate the tick count value
count = BarsPeriod.Value - Bars.TickCount;
strCount=count.ToString()+" "+"Ticks";
}
else if (BarsPeriod.BarsPeriodType == BarsPeriodType.Volume)
{ // calculate the volume count value
count = BarsPeriod.Value - volume;
strCount=count.ToString()+" "+"Volume";
}
a=GetCurrentAsk();
av=(int)GetCurrentAskVolume();
b=GetCurrentBid();
bv=(int)GetCurrentBidVolume();
if (DisplayText)
{ string v = "Ask/Bid:\n"+
a.ToString("F"+DecimalPlaces.ToString())+"-"+av.ToString().PadLeft(5,' ')+"\n"+
b.ToString("F"+DecimalPlaces.ToString())+"-"+bv.ToString().PadLeft(5,' ')+"\n\n"+
strCount+"\n";
NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Arial Bold", FontSize) { Size = FontSize, Bold = true };
Draw.TextFixed(this,"BidAsk",v,TextPosition.TopRight,Brushes.White,myFont,Brushes.Transparent,Brushes.White,0);
if (Instrument.FullName=="EURUSD") Print("EURUSD Ask: "+a.ToString()+" Ask Vol: "+av.ToString());
}
if (DisplayAskLine) Draw.Ray(this,"AL", 30, a, 0, a, Brushes.Green);
if (DisplayBidLine) Draw.Ray(this,"BL", 30, b, 0, b, Brushes.Red);
atr=avgATR;
if (ATRMultiplier!=0) atr=ATRMultiplier * atr;
NinjaTrader.Gui.Tools.SimpleFont myFont2 = new NinjaTrader.Gui.Tools.SimpleFont("Arial Bold", FontSize) { Size = FontSize, Bold = true };
Draw.TextFixed(this, "ATR","ATR: "+atr.ToString("F2")
+ "\n"+"Trd: "+trend.ToString("F2")
+"\n\n",TextPosition.BottomRight,Brushes.White,myFont2,Brushes.Transparent,Brushes.White,0);
if (PlayAlertOnTicksLeft!=-1 && !playedAlert && count<PlayAlertOnTicksLeft)
{ PlaySound(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)+EndofBarAudio);
playedAlert=true;
}
}
EURUSD Ask: 1.06577 Ask Vol: 3
EURUSD Ask: 1.06575 Ask Vol: 4
EURUSD Ask: 1.06576 Ask Vol: 1
EURUSD Ask: 2271 Ask Vol: 1129
EURUSD Ask: 1.0658 Ask Vol: 9
EURUSD Ask: 1.0658 Ask Vol: 1
EURUSD Ask: 1.06575 Ask Vol: 9
EURUSD Ask: 1.06576 Ask Vol: 8
EURUSD Ask: 1.06576 Ask Vol: 2
EURUSD Ask: 2270.75 Ask Vol: 319
EURUSD Ask: 1.06577 Ask Vol: 1
EURUSD Ask: 1.06576 Ask Vol: 1
EURUSD Ask: 1.06576 Ask Vol: 2
EURUSD Ask: 1.06577 Ask Vol: 1

Comment