Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

PeriodType.Minute limitations?

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

    PeriodType.Minute limitations?

    Hi !

    I am trying to show the SMA of 5 minute period in a 1 minute chart but dont work.
    Works, 1, 2 and 3 minute but not 4,5,6 ...etc...

    Too, if my chart time is 5 minutes, dont work period of 1, 16, 17, 18 ..... minute

    Why? Could you help me please to understand?
    Thanks


    Code:
    Add(PeriodType.Minute, 5);
    
    Add(new Plot( Color.Green, PlotStyle.Line, "misma"));
    
    misma.Set(SMA(BarsArray[1],10)[0]);

    #2
    marynja, are you getting any errors in NT's log tab shown when you add your script?

    Displaying the lower timeframe value will have its limiations depending on what your primary series is on the chart, as this would determine which time interval can be used to update / show the plots on the main series.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand.

      No errors in compilation and no log errors.

      EG.
      My primary series time is 5. Then If declare 1 minute timeframe or if declare 16 minute or highest, then the plot isnt draw.




      //Works
      Add(PeriodType.Minute, 2);
      Add(PeriodType.Minute, 3);
      :
      Add(PeriodType.Minute, 15);

      //Dont Works
      Add(PeriodType.Minute, 1);
      and
      Add(PeriodType.Minute, 16);
      Add(PeriodType.Minute, 17);
      :
      Add(PeriodType.Minute, infinite);

      Comment


        #4
        Sorry me Bertrand, yes was a log error:

        You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart

        I think its a nosense error, because if my principal dataseries time is 5 minutes dont work with a 20, 25, 30, etc... minutes. All a 5 multiples.
        If the principal dataseries time is 15, the plot only draw in 15....

        Any idea?

        Thanks
        Last edited by marynja; 12-13-2011, 07:15 AM.

        Comment


          #5
          No worries - thanks for the error post here. Please retest your script with an included CurrentBars check for all series you would use in it - http://www.ninjatrader.com/support/h...urrentbars.htm
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Thank you a lot Bertrand.
            With this line, all works correctly.

            Code:
            if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)return;

            Comment


              #7
              Originally posted by marynja View Post
              Hi !

              I am trying to show the SMA of 5 minute period in a 1 minute chart but dont work.
              Works, 1, 2 and 3 minute but not 4,5,6 ...etc...

              Too, if my chart time is 5 minutes, dont work period of 1, 16, 17, 18 ..... minute

              Why? Could you help me please to understand?
              Thanks


              Code:
              Add(PeriodType.Minute, 5);
              
              Add(new Plot( Color.Green, PlotStyle.Line, "misma"));
              
              misma.Set(SMA(BarsArray[1],10)[0]);
              Hi marynja,

              I tried to make the same thing, but I couldn't it, yet.
              Can you help me?

              Thanks,

              Josue

              Comment


                #8
                Hello Josue,

                Thank you for your post.

                Did you incorporate the CurrentBars check?
                if (CurrentBars[0] < BarsRequired || CurrentBars[1] < BarsRequired)return;

                Comment


                  #9
                  Originally posted by NinjaTrader_PatrickH View Post
                  Hello Josue,

                  Thank you for your post.

                  Did you incorporate the CurrentBars check?
                  Hi Patrick,

                  With your orientation and not this, doesn't show SMA (5 minutes) in chart of 1 min.
                  Main chart is 1 min.
                  Enclosed you can see the script.
                  Thanks,
                  Josue
                  Attached Files
                  Last edited by josuempc; 06-15-2014, 09:37 PM. Reason: forgot the script file

                  Comment


                    #10
                    The first BarsArray is BarsArray[0], the second one is BarsArray[1]. There is no BarsArray[2], as you only added one secondary bar series.

                    Please replace BarsArray[2] with Inputs[1] in line 55.

                    Comment


                      #11
                      Josue, could you work please work in Harry's thoughts as per post #10 and then recheck?
                      BertrandNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Bertrand View Post
                        Josue, could you work please work in Harry's thoughts as per post #10 and then recheck?
                        Hi Harry and Patrick,

                        Thank you very much, it works now.
                        My doubt is about the "steps" in SMA line, is possible to do a continue line? (you can see in attached file)
                        I intend to make this to others indicators (MACD , price oscilator, and RSI).
                        Best Regards,

                        Josue
                        Attached Files

                        Comment


                          #13
                          You can get a continuous line, if you code an algorithm that performs the interpolation.

                          The 5-min chart shows a 20-period SMA calculated from 60 min bars. I have it set to display the nodes, which are calculated when the 60 min bar closes. The distance between the nodes is interpolated. In order to make the interpolation work, the indicator values after the last nodes are being recalculated with each incoming tick. That means that the indicator repaints the final leg after the last node. You will see the leg moving up and down when the indicator is set to CalculateOnBarClose = false.
                          Attached Files
                          Last edited by Harry; 06-16-2014, 07:24 AM.

                          Comment


                            #14
                            Originally posted by Harry View Post
                            You can get a continuous line, if you code an algorithm that performs the interpolation.

                            The 5-min chart shows a 20-period SMA calculated from 60 min bars. I have it set to display the nodes, which are calculated when the 60 min bar closes. The distance between the nodes is interpolated. In order to make the interpolation work, the indicator values after the last nodes are being recalculated with each incoming tick. That means that the indicator repaints the final leg after the last node. You will see the leg moving up and down when the indicator is set to CalculateOnBarClose = false.
                            I let CalculateOnBarClose = false and the lines continue with little steps, but your help was very important to fix these problems.
                            Thank very much.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by jclose, Today, 09:37 PM
                            0 responses
                            5 views
                            0 likes
                            Last Post jclose
                            by jclose
                             
                            Started by WeyldFalcon, 08-07-2020, 06:13 AM
                            10 responses
                            1,413 views
                            0 likes
                            Last Post Traderontheroad  
                            Started by firefoxforum12, Today, 08:53 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post firefoxforum12  
                            Started by stafe, Today, 08:34 PM
                            0 responses
                            11 views
                            0 likes
                            Last Post stafe
                            by stafe
                             
                            Started by sastrades, 01-31-2024, 10:19 PM
                            11 responses
                            169 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Working...
                            X