Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Ordering more contracts than strategy wants

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

    Ordering more contracts than strategy wants

    Hello,

    I have VERY interesting problem with ninjatrader...
    as you can see in attached picture, strategy is taking more and more contracts.
    for example at 11:31 is the strategy working with 3 or 4 contracts.
    But the interesting thing is that in the source code of the enter is this:

    Code:
    			if (CrossBelow(Close, Open, 1) 
    						&& Position.MarketPosition!=MarketPosition.Long
    						&& ToTime(Time[0]) > ToTime(startOfBuyZone_hour, startOfBuyZone_minute, 0) 
    						&& ToTime(Time[0]) < ToTime(endOfBuyZone_hour, endOfBuyZone_minute, 0)) {
    				DrawArrowUp("My up arrow" + CurrentBar, false, 0, Low[0] + -17 * TickSize, Color.Blue);
                    PlaySound(@"C:\Program Files\NinjaTrader 6.5\sounds\Alert1.wav");
                    EnterLong();
    				SetStopLoss(CalculationMode.Ticks, stopLossTicks);
    				SetProfitTarget(CalculationMode.Ticks, profitTargetTicks);
    				return;
                }
    I guess it is NOT possible that strategy could send two EnterLong() orders.
    You can see that in the conditions of source code for entering.
    So how its possible that I have so much contracts ???

    When you will run the strategy on historical data (backtest) you will see its working good. But on realtime data (simulated data) its buying and selling lots of contracts in the order. Why???

    Thank you for advice.
    Attached Files

    #2
    Hi zooinek,

    Thank you for your post. Someone will respond shortly.
    TimNinjaTrader Customer Service

    Comment


      #3
      Do you call EnterLong or EnterShort or any other Enter lines in your code anywhere else?

      We would need to take a look at your full strategy code. You can send your code to support at ninjatrader dot com with ATTN: Brett Reference this forum post and I can take a quick look at it.

      Alternately, If you add TraceOrders = True in the Initialize Method you will be able to trace the orders to see what is happening to see if this will help you in fiquring out where this orders are coming from.
      BrettNinjaTrader Product Management

      Comment


        #4
        Hi Brett,
        thank you for your response.
        No, this is the only place where i am using enterlong method.
        I dont understand your note:
        ...with ATTN: Brett Reference this forum post and I can take a quick look at it.

        I cannot translate what you mean...?
        If I understand, i will send the strategy code to support at ninjatrader dot com and write subject: "To Brett from http://www.ninjatrader-support2.com/vb/showthread.php?t=28623"
        ok?

        Comment


          #5
          Yes this is correct. This way we can take a look at your strategy code to see what is happening.

          I look forward to assisting you further.
          BrettNinjaTrader Product Management

          Comment


            #6
            Oh I forgot to tell... it's for latest version of NinjaTrader 6.5. I guess its 6.5.1000.15
            NOT for Ninja7.

            Even I dont think this will be very useful information

            So what do you think? What could be the problem? The source code is correct, right?
            The entry method is used only once... so it is really mystery how it's possible that the strategy is working with so many contracts.. and only on live data, not in backtest.

            Comment


              #7
              zooinek, thanks for the additonal info - are you working with CalculateOnBarClose = false in live trading? Then you could get easily whipsawed as the conditions become true / false intrabar...

              Comment


                #8
                Hello,

                I am always writing CalculateOnBarClose = true; to the Initialize block.

                Comment


                  #9
                  I will continue to follow up with you via email.
                  BrettNinjaTrader Product Management

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  651 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  370 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  109 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  574 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  577 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X