Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Invalid price in changing Setstoploss()
Collapse
X
-
Invalid price in changing Setstoploss()
I am implemneting some strategy to change stoploss price. But sometime, it is informed that "' submitted an order that generated the following error 'Unable to change order'. Strategy has sent cancel requests, attempted to close the position and terminated itself." in output. At the meantime, that is Pop-up window like the picture in attachment. I think the price follow the tick size.1 PhotoTags: None
-
Hello steinberg123,
Thank you for your post.
This error is letting you know that the price you are submitting the order to is invalid. To determine the cause you'll need to debug the script using Prints and TraceOrders.
In particular, I recommend printing out the current price and the price you are trying to change your stop loss to.
To understand why the script is behaving as it is, such as placing orders or not placing orders when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.
In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.
The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.
The debugging print output should clearly show what the condition is, what time the conditions are being compared, all values being compared, and how they are being compared.
Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).
Further, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.
After enabling TraceOrders remove the instance of the strategy from the Configured list in the Strategies window and add a new instance of the strategy from the Available list.
I am happy to assist you with analyzing the output from the output window.
Run or backtest the script and when the output from the output window appears save this by right-clicking the output window and selecting Save As... -> give the output file a name and save -> then attach the output text file to your reply.
Below is a link to a support article that demonstrates using informative prints to understand behavior and includes a link to a video recorded using the Strategy Builder to add prints.
https://support.ninjatrader.com/s/ar...nd-TraceOrders
-
thanks for the reply. I am freshman in ninja trader.for example, if it is entering long, the price of Setstoploss() is submitted. later, when I am trying to change the stoploss price, if the submitted price for Setstoploss() is less than current market price, it would be error. the condition of Setstoploss() is that the stopprice should be less than current market price????
Comment
-
Hello steinberg123,
We would need the debugging from the prints to specifically see why the conditions are leading to this error, unfortunately just knowing what the conditions are isn't telling us why this is happening. We need to know the actual values of the stop loss in addition to all other values in the conditions.
If you need assistance creating a debugging print, provide a screenshot of one of your conditions (the actual code).
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
25 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
121 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
64 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
41 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment