Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy in chart disables Chart Trader?

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

    #16
    Thanks MichaelM, I will see what I can do with ATMStrategyCreate() . I have traded for many years, but as you can tell, I am a NinjaScript novice.

    Comment


      #17
      Hello Pete77,

      It is always my pleasure and no problem at all.

      Please let me know if you encounter any issues while adjusting your code.
      Michael M.NinjaTrader Quality Assurance

      Comment


        #18
        I am using the SampleAtmStrategy as a template. Regarding ATMStrategyCreate() I understand how to enter my atmStrategyId, but am puzzled how to enter my logic, which is very simple for an upward price direction:
        if(Close[1] < Open[1])
        { EnterLongStop(High[1] + 1 * TickSize);}
        In my prior attempt this logic actually moved the LongStop down as red bars declined, but how to use this in ATMStrategyCreate() ???

        Comment


          #19
          Hello Pete77,

          Here is one way you could accomplish that with the ATM strategy methods:
          Code:
          //...in your variables region
          string orderId;
          
          //...in your OnBarUpdate() or other method
          if(Close[1] < Open[1])
          {
              if(orderId == null)
              {
                  orderId = GetAtmStrategyUniqueId();
                  AtmStrategyCreate(OrderAction.Buy, OrderType.Stop, 0, High[1] + 1 * TickSize, TimeInForce.Day, orderId, "MyTemplate", GetAtmStrategyUniqueId());
              }
              else
              {
                  AtmStrategyChangeEntryOrder(0, High[1] + 1 * TickSize, orderId);
              }
          }
          Because things are done a little differently in ATM strategy methods, it is very helpful to be aware of all the methods on this list: http://ninjatrader.com/support/helpG...gy_methods.htm

          Please let me know if I may be of further assistance.
          Michael M.NinjaTrader Quality Assurance

          Comment


            #20
            Many thanks. The program compiles but stop order does not take place (using sim). It is enabled in both user dialog and under strategy tab in Control Center. I will do some debugging.

            Comment


              #21
              Hello Pete77,

              You likely need to make sure you have the following code at the top of your OnBarUpdate() method:
              Code:
              if(Historical) return;
              Please let me know if you continue to experience difficulties.
              Thank you in advance.
              Michael M.NinjaTrader Quality Assurance

              Comment


                #22
                Hi Michael,
                With your help I am making progress, Testing is slow when not able to use historical data. Sell & buy stops are now appearing. Next step is to cancel an order if it has not been filled by the close of the next bar, or if a new order is created. I will see what i can do with that. I have found some examples

                Comment


                  #23
                  Hello Pete77,

                  You can use Historical data if you require it for testing purposes. The fix I provided is just a quick solution to make sure your strategy position does not prevent your orders from submitting when you have the default settings set.
                  If you need to use historical data, please read through the following two documents and make sure you pick the settings that best apply to how you want your strategy to work, then you can remove the following code:
                  Code:
                  if(Historical) return;
                  1. http://ninjatrader.com/support/helpG...unt%2Bposition
                  2. http://ninjatrader.com/support/helpG..._positions.htm

                  You may wish to use "Immediately submit live working historical orders" and also "Sync account position = true".

                  "Immediately submit live working historical orders" can be selected by navigating to Tools -> Options -> Strategies tab -> NinjaScript sub-tab

                  You can set Sync Account Position in the strategy parameters box, when enabling the strategy.

                  Please let me know if you have any questions or if I may be of further assistance.
                  Michael M.NinjaTrader Quality Assurance

                  Comment


                    #24
                    Hi Michael,

                    I have been struggling to find a way "If order entry not filled one bar past order entry bar cancel order"

                    I assume that one way to do this would be to identify this bar, which I have not been able to do. Could use some help with this.

                    Comment


                      #25
                      Hello Pete77,

                      You would use the overload that contained liveUntilCancelled. For example:
                      Code:
                      EnterLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName)
                      If you set liveUntilCancelled to true, the order will NOT expire at the end of a bar, but instead remain live until the CancelOrder() method is called or its time in force has been reached.

                      You would have to store the entry in an IOrder so you could call the CancelOrder() method.
                      For more information on IOrders: http://ninjatrader.com/support/helpG...ightsub=iorder
                      For more information on the CancelOrder() method: http://ninjatrader.com/support/helpG...ub=cancelorder

                      Then you need to use the OnOrderUpdate() method to determine if the order was filled by the end of the next bar or not. If not, call the CancelOrder() method.

                      For more information on the OnOrderUpdate() method: http://ninjatrader.com/support/helpG...=onorderupdate

                      Please let me know if you have any further questions.
                      Michael M.NinjaTrader Quality Assurance

                      Comment


                        #26
                        HI Michael,

                        My strategy at its present stage is working fine in simulation, but when I switch to live it does not work at all, orders to not show up on the chart trader screen as the do in sim. As you know my strategy is on a separate non-chart trader screen. I brought up the the Dom and set it live, but that didn't have any effect.

                        Can you tell me what I am missing?

                        Comment


                          #27
                          Hello Pete77,

                          When trying to run your strategy live, please open the strategies tab of the control center. If your strategy is colored anything except green when enabled (such as yellow), you are likely having an issue with your strategy position vs account position. Please see my earlier post for more information on this: http://ninjatrader.com/support/forum...5&postcount=23

                          Please clarify if your strategy is turning green or not in the strategies tab so I can investigate further.

                          Thank you in advance.
                          Michael M.NinjaTrader Quality Assurance

                          Comment


                            #28
                            Thanks Michael,

                            Color is green on strategy tab but account shows sim101 on strategy tab, which I should have noticed before. Same on dialog box in non chart trader screen which holds the strategy.













                            thanks

                            Comment


                              #29
                              Hello Pete77,

                              Based on your response, tt will help to see the code you are testing to find the cause of this behavior. If you do not want to post it here on the forums, please feel free to attach it in an email to platformsupport[AT]ninjatrader[DOT]com with the following information contained in the body: "ATTN: Michael M http://ninjatrader.com/support/forum/showthread.php?t=30165".

                              Thank you in advance.
                              Michael M.NinjaTrader Quality Assurance

                              Comment


                                #30
                                I see now how to change to live in the user dialog. I will try that when I see an oportunity live. Sorry to bother you with that.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                639 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                366 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                107 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                569 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                572 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X