I still have some questions concering the logic of SetProfitTarget:
My strategy logic is:
1.
SetStopLoss( CalculationMode.Percent, initialRiskPercent/100.0);
2. EnterLongLimit()
.., now the trade is "alive" and every now and then the stop loss is adjusted by calls to SetStopLoss(CalculationMode.Price,price);
I have no SetProfitTarget called because I don't want OCO orders sitting there with the OCO logic handled locally.
By having simple stop loss orders all these orders sit on the exchange and are (almost!) guarenteed to execute.
3. No I decide to exit the position and I do so by calling
SetProfitTarget(zh.Buy,CalculationMode.Price,GetCurrentAsk()-TickSize);
The result is that the positions exits as exspected once the Profit target order is filled, but at the same time I get an error concering the stop loss order. It seems that NT re-transmitts the stop loss order and by the time it is retransmitted the profit target was filled and the stop loss order turns invalid.
Please indicate me what happens there? Why does the NT logic retransmit the stop loss?
Why this error
Can't modify a filled order" (104) Affected Order: Sell 1 Stop @ 4689,5
Best regards
Andreas
Here is the log (cleaned up)
It begins 10.17 with a change ot the stop loss order by my strategy.
All later changes of the stop loss do not originate from my code, but from NT logic.
Please explain how to avoid such errors!
10.24 Execution Execution='FDAX 06-09/0000e7d2.4a0bc210.01.01' Instrument='FDAX 06-09' Exchange=Eurex Price=4724,5 Quantity=1 Market position=Short Operation=Insert Order='227258006' Time='14/05/2009 10.24.09'
10.24 Order Order='227258006' Name='Profit target' New State=Filled Instrument='FDAX 06-09' Action=Sell Limit price=4724,5 Stop price=0 Quantity=1 Type=Limit Filled=1 Fill price=4724,5
10.24 Order Affected Order: Sell 0 Stop @ 4689,5
10.24 Order Order='227258005' Name='Stop loss' New State=Rejected Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5 Quantity=0 Type=Stop Filled=0 Fill price=0 Error=NoError Native error=''
10.24 Order Order='227258006' Name='Profit target' New State=PendingCancel Instrument='FDAX 06-09' Action=Sell Limit price=4724,5 Stop price=0 Quantity=1
10.24 Strategy Strategy 'AndreasLongEntry' submitted an order that generated the following error 'OrderRejected'. Strategy has sent cancel requests, attempted to close the position and terminated itself.
10.24 Order Can't modify a filled order" (104) Affected Order: Sell 1 Stop @ 4689,5
10.24 Order Order='227258005' Name='Stop loss' New State=Rejected Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5 Quantity=1 Type=Stop Filled=0 Fill price=0 Error=OrderRejected Native error='Can't modify a filled order" (104)'
10.24 Order Order='227258005' Name='Stop loss' New State=Accepted Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5 Quantity=1 Type=Stop Filled=0
10.24 Order Order='227258005' Name='Stop loss' New State=PendingChange Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5 Quantity=1 Type=Stop Filled=0
10.24 Order Order='227258005' Name='Stop loss' New State=Working Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5 Quantity=0 Type=Stop Filled=0
10.24 Order Order='227258006' Name='Profit target' New State=Working Instrument='FDAX 06-09' Action=Sell Limit price=4724,5
10.24 Order Order='227258006' Name='Profit target' New State=Accepted Instrument='FDAX 06-09' Action=Sell Limit price=4724,5
10.24 Order Order='9023d6dd28bc4b1187a8194d83df3be5' Name='Profit target' New State=PendingSubmit Instrument='FDAX 06-09' Action=Sell Limit price=4724,5
10.17 Order Order='227258005' Name='Stop loss' New State=Working Instrument='FDAX 06-09' Action=Sell Limit price=0 Stop price=4689,5
Comment