Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Market Orders being cancelled by Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Stop Market Orders being cancelled by Strategy

    Hi everyone, I have one that has me pulling my hair our. I have a simple strategy I am working on that enters on one specific condition, with a predetermined stopmarket set by a userinput. There is a bool for a breakeven target. When the target price is reached, the bool flips to true, and a new stop order is entered which is based on the average position price plus an offset.

    Unfortunately, when it reaches this set, it seems to cancel both the newly inputted stopmarket order for the breakeven offset, and the original stopmarket order from when the strategy entered the position.

    I have prints, trace orders, nothing seems to be telling me what the story here is. There are no errors or issues regarding the price (i.e. wrong side of market price), and the strategy is running on an update for each tick, so my assumption is that it should continue to check whether the condition is true, and keep these orders live, at least, this is how it works in other strategies I have built. I've not seen this behavior before. What can I provide that would help solve the issue?

    Thanks

    #2
    Trace Order not giving any errors of a rejection? When you look at the trace order information are the price limits and all that all the prices you expect it to be? What are you using to set the stoploss? Are you setting a brand new request or using the original signal name? If you could paste your code, that could be helpful. The output that it is pumping out would be helpful as well

    Comment


      #3
      Hello sclay115,

      Thank you for your post.

      We would need the output from prints and TraceOrders to assist.

      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
      Gaby V.NinjaTrader Customer Service

      Comment


        #4
        Thanks for the replies! I think I worked this one out, there was a mistake in the conditions that was submitting on a contradicting order when the entire position should have closed. I ended up adding prints, and turning on the trace order function to find it.

        Thanks!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Pointtoni, Yesterday, 11:41 PM
        3 responses
        31 views
        0 likes
        Last Post jenacie.com  
        Started by DayTradingDEMON, Yesterday, 02:10 PM
        5 responses
        34 views
        0 likes
        Last Post DayTradingDEMON  
        Started by Nate G, 03-17-2025, 02:53 PM
        4 responses
        64 views
        1 like
        Last Post timko
        by timko
         
        Started by several, 03-18-2025, 03:53 AM
        11 responses
        177 views
        1 like
        Last Post timko
        by timko
         
        Started by Amelie4262, Today, 10:45 AM
        0 responses
        12 views
        0 likes
        Last Post Amelie4262  
        Working...
        X