Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Why Ninja doesn’t run correctly this strategy?

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

    Why Ninja doesn’t run correctly this strategy?

    It’s a very simple strategy: when the price crosses above a SMA, we send an enterlong stop order 4 ticks above this price. If the price crosses below, we send an entershort stop order 4 ticks below.

    For example, if we are short and the last bar closes over the SMA, then Ninja sends two stop orders, one to close the short position and the other to open a long position.

    If the orders are filled, there is no problem and ninja runs the strategy correctly.

    But if the price doesn’t reach the stop, and one of the following bars crosses below the SMA, then Ninja should cancel the two orders, but in fact it only cancel the open long position order, not the close short position order.

    Is there any way to solve this?

    I have programmed the strategy by the wizard, here is the code:


    ///</summary>
    protectedoverridevoid Initialize()
    {
    Add(SMA(SMAperiod));

    CalculateOnBarClose = true;
    }

    ///<summary>
    /// Called on each bar update event (incoming tick)
    ///</summary>
    protectedoverridevoid OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] > SMA(SMAperiod)[0])
    {
    EnterLongStop(DefaultQuantity, Close[0] + 4 * TickSize, "");
    }

    // Condition set 2
    if (Close[0] < SMA(SMAperiod)[0])
    {
    EnterShortStop(DefaultQuantity, Close[0] + -4 * TickSize, "");
    }

    #2
    Entering two simultaneous stop entry orders is not allowed as it violates our internal order handling rules.

    Please scroll to the bottom of the follow page for information on this.

    RayNinjaTrader Customer Service

    Comment


      #3
      ??

      I think the strategy doesn't enter two simultanous orders.

      EnterLongStop if Close>SMA

      EnterShortStop if Close<SMA

      As long as these orders are to reverse position, Ninja sends two orders: one to close, and other to open a new position.

      Comment


        #4
        jmreal.

        This line...
        Close[0] > SMA(SMAperiod)[0]
        can submit an order on every bar.
        If you send the entry order in, and do it again and again you're submitting multiple orders as the market moves.

        make sense?

        You only want to submit another long order if one doesn't already exist that is waiting to get filled.
        mrlogik
        NinjaTrader Ecosystem Vendor - Purelogik Trading

        Comment


          #5
          I overlooked the question jmreal...

          To clarify --> What NT version are you running? Help > About.

          - You are long
          - An short entry is triggered, two orders are sent, one to open, one to close existing long
          - Short entry signal is now false, the open entry is cancelled but the close remains

          Correct?
          RayNinjaTrader Customer Service

          Comment


            #6
            100% correct Ray, I’m running Version 6.5.1000.3

            Mrlogik, thank you for your comment. I thougth the same when I first programmed this strategy, so I added a “Current market position” condition to avoid this problem.

            But later I realized that Ninja does not submit an enterlong order if our strategy position is long, so I removed this condition to make it simpler.

            In fact, the same strategy without stop orders works perfectly:

            // Condition set 1
            if (Close[0] > SMA(SMAperiod)[0])
            {
            EnterLong(DefaultQuantity, "");
            }

            // Condition set 2
            if (Close[0] < SMA(SMAperiod)[0])
            {
            EnterShort(DefaultQuantity, "");
            Last edited by jmreal; 08-05-2008, 09:29 AM.

            Comment


              #7
              Can you upgrade to 6.5.1000.5 and let me know if this problem persists in our latest version. Thanks.
              RayNinjaTrader Customer Service

              Comment


                #8
                With the new version the problem disappears and the two orders are correctly cancelled

                Thank you very much.

                Comment


                  #9
                  Excellent...
                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  627 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  359 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  105 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  562 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  567 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X