Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

"Flatten Everything" Ninjascript

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

    "Flatten Everything" Ninjascript

    Does anyone have a sample Ninjascript code for simulating "Flatten Everything" or direct me to a thread already discussed?

    Thanks,
    dbatrader

    #2
    dbatrader,

    Please note that a NinjaScript strategy only knows its own strategy position and as such can only act according to that information. If you want the strategy to stop all its own orders and positions you can check out this reference sample: http://www.ninjatrader-support2.com/...ead.php?t=4804
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the sample. My strategy will have multiple scale-in and scale-out orders. But when the direction changes, I want to cancel all open orders that are not filled.
      Per examples, i have to track each order with "private IOrder" variable. Iam looking for a single command or function, that checks for all open orders issued by the strategy and cancel it.

      Comment


        #4
        You have to track them and cancel them all manually.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          okay. Given that such option is available in Tradestation interface as well as OIF, I am surprised it is not there in Ninjascript itself.

          Thank you for replying during Christmas.

          Happy Holidays !

          Comment


            #6
            You could just go ExitLong() and ExitShort() and that would close any long and shorts. As far as working orders, you have to cancel them through code that calls your IOrders to cancel though.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Or "Cancel All"

              Also, a Cancel All command would be extremely useful. For example, when you have a strategy that would EnterLong or EnterShort and have a trail stop associated with it, you start up the strategy and it thinks its in a position based on the rules even tho it missed the entry because it was earlier. Then it puts out the trail stop. Bad if it hits the stop and now enters a new opposite position. You could check your "MarketPosition" and if flat, "CancelAll" to make sure no extra stops are floating around.

              Comment


                #8
                Thanks for the suggestion, in this scenario just work with 'WaitUntilFlat' as your 'On Starting A Realtime strategy setting', thus not submitting the historically working / needed stop order, but starting to execute live with the first freshly generated entry.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Where is that ''On Starting A Realtime strategy' setting found?

                  Comment


                    #10


                    Under Tools > Options > Strategies > NinjaScript
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      OK, thanks, seems to be what I needed.

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by GussJ, 03-04-2020, 03:11 PM
                      16 responses
                      3,281 views
                      0 likes
                      Last Post Leafcutter  
                      Started by WHICKED, Today, 12:45 PM
                      2 responses
                      19 views
                      0 likes
                      Last Post WHICKED
                      by WHICKED
                       
                      Started by Tim-c, Today, 02:10 PM
                      1 response
                      9 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by Taddypole, Today, 02:47 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post Taddypole  
                      Started by chbruno, 04-24-2024, 04:10 PM
                      4 responses
                      53 views
                      0 likes
                      Last Post chbruno
                      by chbruno
                       
                      Working...
                      X