Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Stops when price too volatile

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

    Strategy Stops when price too volatile

    I want to add error handling, or some mechanism to prevent NT from cancelling the strategy when price moves too quickly beyond order placement position.

    For example my strategy places an order to go long one tick above a bull bar. If price moves too fast after bar closes (thin market), before NT has a chance to add the order using EnterLongStopMarket(), NT will generate an error when it tries to then place the order.

    How can I add error handling to prevent the strategy from just stopping. I just want to cancel that order, and let the strategy continue.

    Thanks.




    #2
    Hello globaljobber,

    While you can add handling for that it would also require adding handling for any other potential error you may encounter which opens the script up to a lot of problems. Generally we suggest increasing the offset to avoid having the strategy place invalid priced orders.

    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello there,

      I don't want to change the strategy entry criteria at this point.

      The only error I get is the one here. Otherwise the strategy so far runs well.

      Can I not just add error handling for this one issue?

      I would really like to add error handling to catch this error so that it avoids NT stopping the strategy.


      Many thanks
      Gerard

      Comment


        #4
        Hello globaljobber,

        When you change the error handling setting that means you will handle all rejections in code and not just that one. If you feel comfortable doing that you can change the setting to avoid rejections. The better solution is to correct the pricing used for the order so it does not get placed on the wrong side of the market. Volatile markets are a normal part of trading so in some cases you cannot use prices that are close to market because the rate of rejection increases.
        JesseNinjaTrader Customer Service

        Comment


          #5
          You could put the entry condition in a try { block and print the exception when the trade isn't taken due to volatility.

          Comment


            #6
            That's a fair point. I'll go and do some more consideration!

            Comment


              #7
              Hello wisdomspoon,

              Putting an entry condition in a try block won't avoid rejections and it will still disable the strategy upon rejection. Try in C# is only to try code that can raise an exception, order methods do not raise exceptions because the rejection is handled on a different thread for the execution. The best solution is still increasing the offset, if you need to you can handle rejections as well.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Rejections are a part of my life :0)

                Thanks for your help Jesse.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by brucerobinson, Today, 07:08 AM
                3 responses
                18 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by Dudley, Today, 09:52 AM
                2 responses
                10 views
                0 likes
                Last Post Dudley
                by Dudley
                 
                Started by Johnny, Yesterday, 12:39 PM
                6 responses
                33 views
                0 likes
                Last Post Johnny
                by Johnny
                 
                Started by Saronna, Today, 02:08 PM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by celtey, 03-21-2025, 09:46 AM
                6 responses
                80 views
                0 likes
                Last Post celtey
                by celtey
                 
                Working...
                X