SetStopLoss(order1Name, CalculationMode.Ticks, 50, false); SetProfitTarget(order1Name, CalculationMode.Ticks, 50); EnterLong(Convert.ToInt32(TargetSize), order1Name);
See the attached CSV document with the data from the Orders window. See that transition from 1:00 and the orders at 1:09 where the problem happened. Also, it is not shown in the CSV format, but the orders at the same minute mark (like 1:09) all happen at the same second (it happens fast). There's one Sell Short at 1:09 and then immediately the Profit Target is filled, however, the price is nowhere near the profit target.
Note, the immediate close of the position (profit target) happens intermittently, not always. How can I fix this or is there a cleaner way to reverse a position with stop loss and profit target orders?
If the above code was used to enter a position, then when the strategy is triggered again, for example, the following code would reverse that position:
SetStopLoss(order1Name, CalculationMode.Ticks, 50, false); SetProfitTarget(order1Name, CalculationMode.Ticks, 50); EnterShort(Convert.ToInt32(TargetSize), order1Name);
Comment