- At some moment during the session it sets a value for the variable TargetPriceAbove, it will be the target price, (not currency, not ticks, the price).
- Later, when the conditions indicate it is moment to create an order it does the following in this exact order:
- Based on current price and target price (calculated before), it calculates the stop price and stores it in the variable StopPriceBelow, again, it is the actual price for the stop loss (not currency, not ticks).
- It adds a message to the log indicating: Target, Stop and From (current price).
- It creates a Long order with the tag "V26Up".
- On the "Stops and Targets" it does the following in this order:
- Uses SetStopLoss with tag "V26Up", calculation mode "Price" and the value is the variable StopPriceBelow (calculated some milliseconds ago).
- Uses SetProfitTaget with tag "V26Up", calculation mode "Price" and the value is the variable TargetPriceAbove (calculated several minutes or hours ago).
Do you have a clue why the log uses the correct values for the variables but the SetStopLoss and SetProfitTarget functions do not use those values?
The log output:
Time,Category,Message, 9/30/2024 7:10:00 AM,Order,Order='125798094604/DEMO597393' Name='Stop loss' New state='Cancelled' Instrument='MES DEC24' Action='Sell' Limit price=0 Stop price=0.25 Quantity=1 Type='Stop Market' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094604/DEMO597393' Name='Stop loss' New state='Cancel submitted' Instrument='MES DEC24' Action='Sell' Limit price=0 Stop price=0.25 Quantity=1 Type='Stop Market' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094604/DEMO597393' Name='Stop loss' New state='Accepted' Instrument='MES DEC24' Action='Sell' Limit price=0 Stop price=0.25 Quantity=1 Type='Stop Market' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094606/DEMO597393' Name='Profit target' New state='Submitted' Instrument='MES DEC24' Action='Sell' Limit price=0.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094606/DEMO597393' Name='Profit target' New state='Working' Instrument='MES DEC24' Action='Sell' Limit price=0.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094606/DEMO597393' Name='Profit target' New state='Accepted' Instrument='MES DEC24' Action='Sell' Limit price=0.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094604/DEMO597393' Name='Stop loss' New state='Working' Instrument='MES DEC24' Action='Sell' Limit price=0 Stop price=0.25 Quantity=1 Type='Stop Market' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Position,Instrument='MES DEC24' Account='DEMO597393' Average price=0 Quantity=0 Market position=Flat Operation=Remove, 9/30/2024 7:10:00 AM,Execution,Execution='125798094606_1' Instrument='MES DEC24' Account='DEMO597393' Exchange=Default Price=5779.75 Quantity=1 Market position=Short Operation=Operation_Add Order='125798094606' Time='9/30/2024 7:10 AM', 9/30/2024 7:10:00 AM,Order,Order='125798094606/DEMO597393' Name='Profit target' New state='Filled' Instrument='MES DEC24' Action='Sell' Limit price=0.25 Stop price=0 Quantity=1 Type='Limit' Time in force=DAY Oco='125798094595_1' Filled=1 Fill price=5779.75 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094604/DEMO597393' Name='Stop loss' New state='Submitted' Instrument='MES DEC24' Action='Sell' Limit price=0 Stop price=0.25 Quantity=1 Type='Stop Market' Time in force=DAY Oco='125798094595_1' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Position,Instrument='MES DEC24' Account='DEMO597393' Average price=5780 Quantity=1 Market position=Long Operation=Operation_Add, 9/30/2024 7:10:00 AM,NinjaScript,NinjaScript strategy 'V26LeaveNoOneBehind/336144117' submitting order, 9/30/2024 7:10:00 AM,NinjaScript,NinjaScript strategy 'V26LeaveNoOneBehind/336144117' submitting order, 9/30/2024 7:10:00 AM,Execution,Execution='125798094595_1' Instrument='MES DEC24' Account='DEMO597393' Exchange=Default Price=5780 Quantity=1 Market position=Long Operation=Operation_Add Order='125798094595' Time='9/30/2024 7:10 AM', 9/30/2024 7:10:00 AM,Order,Order='125798094595/DEMO597393' Name='V26Up' New state='Filled' Instrument='MES DEC24' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=1 Fill price=5780 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094595/DEMO597393' Name='V26Up' New state='Working' Instrument='MES DEC24' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094595/DEMO597393' Name='V26Up' New state='Accepted' Instrument='MES DEC24' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,Order,Order='125798094595/DEMO597393' Name='V26Up' New state='Submitted' Instrument='MES DEC24' Action='Buy' Limit price=0 Stop price=0 Quantity=1 Type='Market' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error='', 9/30/2024 7:10:00 AM,NinjaScript,NinjaScript strategy 'V26LeaveNoOneBehind/336144117' submitting order, 9/30/2024 7:10:00 AM,NinjaScript,V26 Long. Target: 5792.75 Stop: 5772.875 From: 5779.5,

Comment