PDA

View Full Version : Help with Code please.


dwalls
11-21-2008, 10:49 AM
Hello,
I can get this to compile but did doesnt plot an Diamond.
Does anyone know why?
protectedoverridevoid OnBarUpdate()
{
if (SMA(5)[0] > SMA(5)[1]
&& SMA(5)[1] < SMA(5)[2])
{
DrawDiamond("Up Diamond" + CurrentBar, 0, SMA(5)[0], Color.Blue);
}

if (SMA(5)[0] < SMA(5)[1]
&& SMA(5)[1] > SMA(5)[2])
{
DrawDiamond("Down Diamond" + CurrentBar, 0, SMA(5)[0], Color.Magenta);

}
}

Thanks

NinjaTrader_Bertrand
11-21-2008, 12:02 PM
Hi dwalls,

You need to make sure you have enough bars present to start your calculations, so please add this check at the start of your OnBarUpdate() section -


if (CurrentBar < 5)
return;


Then you should see the diamonds plot as per your conditions.

Please also review this link here - http://www.ninjatrader-support2.com/vb/showthread.php?t=3170

dwalls
11-21-2008, 07:08 PM
Thanks...That worked.
I learn something new here eveyday.

Thanks for your help.