Hello everyone.
I’ve been testing a simple strategy for a few days now. I’m only processing two signals.
I set a stop loss and profit and activate a buy order for 5 contracts:
SetStopLoss(“Long1”, CalculationMode.Ticks, 100, false);
SetProfitTarget(“Long1”, CalculationMode.Ticks, 100, false);
EnterLong(5, “Long1”);
And a partial exit from a buy order of 5 contracts. For example, for 1 contract:
ExitLong(1, “PartialExit”, “Long1”);
What I’ve noticed: in some cases, everything works correctly. That is,
the open position is reduced by one contract. The stop loss and profit are also reduced by one contract, becoming equal to 4 contracts each. In most cases (and I’ve tested this dozens of times on the sim101 account),
the open position is reduced by one contract, and the stop loss and profit simply disappear from the chart.
I’m asking experienced experts to explain how to fix this. I need
both the stop loss and profit to be automatically reduced along with the open position.
Maybe I need to change something in the strategy settings in the
(State == State.SetDefaults) section or in the strategy settings on the chart?
I don’t think there are any errors in the code itself.
I’ve attached the log file.
I’m happy to answer any questions.
Thank you.
Sergey S.