Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Inside bar order system

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

    #16
    Thanks. Should I put the unmanaged statement after "protected override void OnBarUpdate()" also?
    Adding the unmanaged statement as you said, I'm getting the long entry order generated after an inside bar, but not the short entry order.

    Comment


      #17
      Also, orders don't get generated outside of regular trading hours. How do I enable automatic execution 24/7?

      Comment


        #18
        You only need to declare Unmanaged = true; once, in the Initialize() method.

        Use TraceOrders output and Print() statements to debug strategy submission issues.

        You'll want to check the session template applied to the strategy for the times submitted.

        Debugging your NinjaScript Code
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          How do I view the session template for the strategies? When I view my historical trades for the day, I can only see the regular trading hours as well on the 1 minute chart that shows the entry and exits. How do I change the session hours for this chart as well?
          Thanks for all your help.

          Comment


            #20
            If the strategy is applied to a chart, then the session template is defined in the chart's Right Click > Data Series window.

            You can see the definitions for session templates by clicking tools > Session manager
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              OK, got the session time straightened out. Now, another issue, when I to the strategy tab in control center and right click to add a new strategy, first I get a blank window as seen in the attachment.(insidebar). I then choose a different strategy like "longentry" and all the contents of the window appear. I then switch back to "insidebarv2" at shown in the second attachment (insidebar2), but the label row under General stays at "longentry". Why is does this happen? I have to manually type in "insidebarv2" in order for the correct strategy to apply.

              Furthermore, on debugging, I put in both the trace order statement, and a print statement but see no additional information in the output window. The strategy goes through a full cycle of entry/exit (long only for now, because the short orders won't generate), but no information is displayed in the output window.

              Comment


                #22
                Forgot attachments.
                Attached Files

                Comment


                  #23
                  ...and one more thing, , in the output window I get a message, ( I can't cut and past it), "Failed to call Method 'Initialize' for strategy.......'SetTrailingStop method can't be called since 'Submitorder' was called before.
                  Can I not use SetTrailingStop now since I am using unmanaged orders?

                  Comment


                    #24
                    Correct, Set() methods can't be used in the unmanaged approach - on which NT7 release version are you now working?

                    Comment


                      #25
                      Version 7.23
                      So then use something like submit order() to create profit targets and stop?

                      Comment


                        #26
                        Correct, you would use SubmitOrder then to send your Exit limit orders for the target and your ExitStop / StopLimit orders for the stops, you basically manage those yourself in this approach.

                        For the strategy accessing issues in the strategies tab - would you mind sending us Trace / Logs in via the Help > Mail to Support option?

                        Thanks

                        Comment


                          #27
                          OK, eliminating the conflict of SubmitOrder() and Set() in unmanaged script eliminated a bunch of issues. Disregard posts 21 and 22. I now get an output that makes some sense, so I'm good there.
                          Can I just put submitOrder() in place (on the same line) as where I had th Set() code for profit/stop target? Does the code somehow automatically check to see if I'm in a position before executing this SubmitOrder? Is sounds like a need some logic like "if currentposition = 1" (EL text), then perform this SubmitOrder(). Any documentation I can reference as to how to code target/stop orders in unmanaged script?
                          Thanks!

                          Comment


                            #28
                            Unfortunately you can't replace the Set lines with SubmitOrder lines.

                            There is always more than one way to do things and unmanaged strategy means there is nothing going on internally to manage your position.

                            You can still use market position checks with an unmanaged strategy so one option is to submit your target or stop loss orders when long or short. .

                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #29
                              OK. If I don't have any exit order script in my strategy, when I enable the strategy, it is highlighted yellow and never turns to green because it still thinks I should be in a position and is waiting for the position to be in sync, but it never will historically, because I didn't exit the order...historically. So, the strategy will never turn to green and start entering orders. Make sense? This is basically telling me I must have code in the strategy to exit the position entered by the strategy. Is this correct? If not, I have no problem exiting the positions manually by pointing and clicking on the chart and entering orders, I would just prefer the strategy to enter the orders automatically. Please clarify.
                              Thanks.

                              Secondly, I have a statement "Print("inside bar detected");" which appears in my output window as it should. is there a way to include in the output what symbol this message is referring to since I have the strategy applied to multiple symbols?

                              Comment


                                #30
                                I'm now getting inside bars detected at the close of every bar. I think my ";" and/or "{}" may be in error. Can you check the following code and tell me if you think I've placed them correctly?

                                protected override void OnBarUpdate()
                                {
                                // Condition set 1
                                if (High[0] <= High[1]
                                && Low[0] >= Low[1])
                                Print("inside bar detected");
                                {
                                SubmitOrder(0,OrderAction.Buy, OrderType.StopLimit, 1, High[0] + 1 * TickSize, High[0] + 1 * TickSize, "", "IB long");
                                SubmitOrder(0,OrderAction.SellShort, OrderType.StopLimit, 1, Low[0] + -1 * TickSize, Low[0] + -1 * TickSize, "", "IB short");

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by NullPointStrategies, Today, 05:17 AM
                                0 responses
                                39 views
                                0 likes
                                Last Post NullPointStrategies  
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                124 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                64 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                41 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                46 views
                                0 likes
                                Last Post TheRealMorford  
                                Working...
                                X