Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Unrecognized Orders

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

    Unrecognized Orders

    At one minute before the close of every hour, I want to close all orders in process and all pending orders. NinjaScript does not seem flexible enough to handle this, so I created a strategy (attached) with CalculateOnBarClose False that calls (in Sets 3 through 10) to ExitLong and ExitShort at one minute before the end of each hour beginning with 1:59 AM and ending with 8:59 AM. The ExitLong and ExitShort are not being executed. Why? Also, how do I close all pending hours at one minute before the end of each hour?
    Attached Files

    #2
    On which chart interval do you run this? Are you sure you get a corresponding timestamp to trigger your exits?

    Unfortunately there's no 'flatten all' from NinjaScript, so I would suggest to work with the IOrder objects -

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Running on 60 minute chart. What do you mean by "a corresponding timestamp to trigger your exits?" I set up the strategy such that at 1:59 AM, for example, an ExitLong and ExitShort are entered. Doesn't that mean the strategy recognizes the computer's clock for that value?

      Comment


        #4
        60 minutes won't give you the needed granularity in timestamps, try for example a minute chart with your strategy.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Can an ExitLong and ExitShort be entered at the same time or only one per bar? What I am doing is saying that if Close of the current bar is > Open of the current bar, then enter ExitLong and ExitShort at a certain level.

          Comment


            #6
            Not sure what you mean. If you want to enter a position use EnterLong/Short(). You need to choose which position you want and place the appropriate order.

            ExitLong/Short() only work if you already have a long/short position. You can only be long or short. You cannot be both for the same instrument so not sure what behavior you are looking for with submitting both. Please clarify. Thank you.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Sorry, I misstated. I meant can I enter an EnterLong and EnterShort on the same bar? I know this can be done using two SuperDoms, but can it be written as NinjaScript? As an example, if the current bar closes at 1.012, I want to say EnterLong at 1.025 and EnterShort at 1.000 so that if the price thereafter moves up to 1.025, the EnterLong is executed but if it, instead, moves down to 1.000, the EnterShort is executed.

              Comment


                #8
                Those would be limit/stop orders not market orders. You cannot place simultaneous working orders in opposite directions for the same instrument.
                Josh P.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Tin34, Today, 03:30 AM
                2 responses
                11 views
                0 likes
                Last Post Tin34
                by Tin34
                 
                Started by sastrades, Yesterday, 09:59 AM
                2 responses
                26 views
                0 likes
                Last Post brucerobinson  
                Started by ETFVoyageur, Today, 12:52 AM
                1 response
                12 views
                0 likes
                Last Post Leeroy_Jenkins  
                Started by lollers, Today, 03:26 AM
                0 responses
                10 views
                0 likes
                Last Post lollers
                by lollers
                 
                Started by aliyahany, Today, 03:16 AM
                0 responses
                2 views
                0 likes
                Last Post aliyahany  
                Working...
                X