Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

To technical support

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

    To technical support

    Just found out the strange issue:

    Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Indicator;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Strategy;
    #endregion
    
    namespace NinjaTrader.Strategy
    {
        [Description("Enter the description of your strategy here")]
        public class AAATest : Strategy
        {
            #region Variables
            private DataSeries plot, plot1;
            #endregion
    
            protected override void Initialize()
            {
                CalculateOnBarClose = true;
                plot     = new DataSeries(this);
                plot1    = new DataSeries(this);
            }
    
            protected override void OnBarUpdate()
            {
                plot1.Set(5);
                plot.Set(SMA(plot1, 5)[0]);
                
            Print("** " + plot1[0] + " " + plot1[1] + " " + plot1[2] + " " + plot1[3] + " " + plot1[4] +" **  = Last 5 values of plot1");
            Print(" ");
            Print("-- " + plot[0] + " -- " + SMA(plot1, 5)[0] + " ----  == SMA(plot1, 5)[0]");
            Print(" ");
            Print(" ");
            Print(" ");
            Print(" ");
            }
    
        }
    }
    Output:

    ** 5 5 5 5 5 ** = Last 5 values of plot1

    -- -388 ---388 ---- == SMA(plot1, 5)[0]




    ** 5 5 5 5 5 ** = Last 5 values of plot1

    -- -389 ---389 ---- == SMA(plot1, 5)[0]




    ** 5 5 5 5 5 ** = Last 5 values of plot1

    -- -390 ---390 ---- == SMA(plot1, 5)[0]



    Something is not right

    Thanks for looking

    #2
    roonius, which market and timeframe did you test this on? On the TD 5min I get this output from exactly your code -

    Code:
     
    ** 5 0 0 0 0 **  = Last 5 values of plot1
     
    -- 1 -- 1 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 0 0 0 **  = Last 5 values of plot1
     
    -- 2 -- 2 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 5 0 0 **  = Last 5 values of plot1
     
    -- 3 -- 3 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 5 5 0 **  = Last 5 values of plot1
     
    -- 4 -- 4 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 5 5 5 **  = Last 5 values of plot1
     
    -- 5 -- 5 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 5 5 5 **  = Last 5 values of plot1
     
    -- 5 -- 5 ----  == SMA(plot1, 5)[0]
     
     
     
     
    ** 5 5 5 5 5 **  = Last 5 values of plot1
     
    -- 5 -- 5 ----  == SMA(plot1, 5)[0]

    Comment


      #3
      I tested on CL 10-09 1 tick.

      Comment


        #4
        Ok thanks roonius, which CalculateOnBarClose setting?

        Comment


          #5
          roonius, finally I could see this on my end for 6.5.1000.12 - this will be fixed with NinjaTrader 7, thanks for posting this.

          Comment


            #6
            Originally posted by NinjaTrader_Bertrand View Post
            Ok thanks roonius, which CalculateOnBarClose setting?
            CalculateOnBarClose = true

            Comment


              #7
              I thought that it only affects strategies, but...

              Something changed in the recent releases - it brakes indicators and strategies which are using SMA and set to calculateonbarclose = false;
              attached code is totally stripped indicator which does not work when calculateonbarclose set to false.

              Code:
              using System;
              using System.ComponentModel;
              using System.Diagnostics;
              using System.Drawing;
              using System.Drawing.Drawing2D;
              using System.Xml.Serialization;
              using NinjaTrader.Cbi;
              using NinjaTrader.Data;
              using NinjaTrader.Gui.Chart;
              
              namespace NinjaTrader.Indicator
              {
                  [Description("Enter the description of your new custom indicator here")]
                  public class AAASMA : Indicator
                  {
                           private int period = 14; // Default setting for Period
              
                      protected override void Initialize()
                      {
                          Add(new Plot(Color.FromKnownColor(KnownColor.Magenta), PlotStyle.Line, "SmaPlot"));
                          CalculateOnBarClose    = false;
                          Overlay                = true;
                          PriceTypeSupported    = true;
                      }
              
                      protected override void OnBarUpdate()
                      {
                          SmaPlot.Set(SMA(Input, Period)[0]);
                      }
              
                      [Browsable(false)]    // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                      [XmlIgnore()]        // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                      public DataSeries SmaPlot
                      {
                          get { return Values[0]; }
                      }
              
                      [Description("")]
                      [Category("Parameters")]
                      public int Period
                      {
                          get { return period; }
                          set { period = Math.Max(1, value); }
                      }
                  }
              }

              Comment


                #8
                roonius, I'm not aware of changes in recent releaes - however the reported issue will be fixed with NinjaTrader 7

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                646 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                367 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
                573 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X