My goal is to enter a position with a full stop and then move the stop twice as the trade goes in my favor. My command to adjust the stop is ignored. (I’ve not added the second stair-step yet). Entry is done in OnExecution() whereas the stop is done during OnBarUpdate(). I trade CalculateOnBarClose(false) and NT7.0.1000.1 . Below i show setting the stop the first time.
#region Variables
private int stopLoss = 12;
private IOrder entryOrderLong = null;
private IOrder stopOrder = null;
protected override void Initialize()
{
SetStopLoss("R1Long",CalculationMode.Ticks,stopLoss,false);
}
protected override void OnBarUpdate()
{
if((Position.MarketPosition==MarketPosition.Long&&
Close[0] >= (Position.AvgPrice + (stopLoss*TickSize)))) {
if (stopOrder != null && stopOrder.StopPrice < Position.AvgPrice) {
stopOrder = ExitLongStop(0, true, stopOrder.Quantity, Position.AvgPrice, "R1Long Stop", "R1Long"); }}


Comment