protected override void OnBarUpdate()
{Print(Time[0].ToString() + " lngstop " + lngstop);
}
protected override void OnPositionUpdate(IPosition position)
{
if (position.MarketPosition == MarketPosition.Long)
{double lngstop = swing(swlength).SwingLow[Swing(swlength).SwingLowBar(0,1,200)];
Print(Time[0].ToString() + position.ToString() + " " + lngstop);
}
}
The print in the OnBarUpdate method shows lngstop = 0 while the print in the OnPositionUpdate shows the correct value.
I want to use the lngstop value in the OnBarUpdate method to exit a trade. I declare the variable as follows in the variable section : private double lngstop; - is this what should change?

Comment