Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator Values Incorrect

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

    Indicator Values Incorrect

    Hello,

    See attached code.

    I'm using a Donchian Channel indicator in my strategy, and when I print the Donchian values to the output window for debugging, the values printed from the strategy do not match the Donchian values on the chart. I can have the strategy draw the Donchian on the chart, and the Donchian channel drawn from the strategy matches exactly a Donchian channel manually added to the chart, however the Donchian values called from the strategy do not match what is on the chart. I've got Calculate On Bar Close = true, and enough bars on my chart where I'm not overlapping trading sessions. I'm stuck why the values from the code don't match the indicator values on the chart.

    Thanks for your help.
    Attached Files

    #2
    Hello TheWolf,

    Welcome to the NinjaTrader Support Forums!

    Can you verify that the values that are looking at are going for the same bar by printing the time of the current bar?

    For Example:

    Code:
    Print("Time: "+Time[0]);
    http://www.ninjatrader.com/support/h....html?time.htm

    Happy to be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      You guessed it, my times are way off. How do I synch time in my strategy to time in my chart?

      Comment


        #4
        Hello TheWolf,

        If you are not using a multi-time frame strategy you would not need to synchronize the time since it will use the parameters that are set with it.

        That being said what time interval are you using on the strategy/chart?

        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          My strategy uses volume bars, but I also tried it with 5 Min chart, just to test the Time[0]. They are both way off. In fact, using the 5 Min chart, the strategy doesn't even print the correct date for Time[0]

          Comment


            #6
            Hello TheWolf,

            Do you set Debug back to true somewhere inside your code?

            Based upon the screenshot that you sent over it looks like you are only printing the values once and since you set Debug back to false. So it will show the values of the DonchianChannel() back when the historical data was loaded for the calculations.

            Happy to be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              Ahh, that's it. If I keep printing output, it does give me the correct values. With that said, when loading a strategy on the chart, is it typical to wait several ticks before letting the strategy implement a trade based upon indicator values?

              Thanks for all your help. Extremely grateful.

              Comment


                #8
                Hello TheWolf,

                Order should be submitted fairly quick once the conditions are met. Note that with CalculateOnBarClose(COBC) set to true, then the strategy will be calculated at the close of each bar. If your strategy is set to COBC=false, it will be calculated on each tick. See the following link for more info on COBC.
                http://www.ninjatrader.com/support/h...onbarclose.htm

                You can also view the time the orders are submitted in the output window if you like as well by using the TraceOrders option by set to true. View the following link for an example of using TraceOrders.
                http://www.ninjatrader.com/support/f...ead.php?t=3627

                Let us know if we can be of further assistance.
                JCNinjaTrader Customer Service

                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