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

Use Value of BarsArray[1]

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

    Use Value of BarsArray[1]

    i need to know the last 5 high of barsArray[1]...

    i do this code :


    ..............

    AddDataSeries(BarsPeriodType.Minute, 1440);

    ...............


    if (CurrentBars[1] < 5) return;

    highd0 = Highs[1][0];
    highd1 = Highs[1][1];
    highd2 = Highs[1][2];
    highd3 = Highs[1][3];
    highd4 = Highs[1][4];
    highd5 = Highs[1][5];


    But Highs[1][5] is not the high of 5 bars ago in my secondary series

    How you suggest me?

    #2
    Hello turbofib,

    Thanks for your post.

    I copied your code and created an illustration of the output as it relates to the 1440 minute bars. I used 3 colors to show the sequence. The values are of the highs of the 1440 minute bars as shown. Please see the attached.
    Attached Files
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      now it's ok ...
      excuse me...i did confusion

      if i want to know the High of bar in progress (this session) i must to find it using DayCurrentOhL[0] or
      i can to use the value of secondary bar in progress?

      Comment


        #4
        Hello turbofib,

        Thanks for your post.

        For the current session, you could use CurrentDayOHL or if you use Calculate.OnEachTick or Calculate.OnPriceChange, the bar index references would shift so that [0][0] would point to the currently forming bar, so Highs[0][0] on the 1440 minute bar would be the high of the current day. [0][1] would be the high of yesterday.

        I think it would be helpful for you to review the helpguide reference: http://ninjatrader.com/support/helpG...nstruments.htm In particular in the section, "How Bars Data is Referenced" is a great illustration of showing which bar is referenced in the different calculate mode and this may help answer some of your questions.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          hi, now there is another problem

          look my code : (in new indicator)


          .....
          AddDataSeries(BarsPeriodType.Minute, 1440);
          .....
          highd1 = Highs[1][0]; //i want plot High of 1 session ago

          with chart 60 minutes i see correct


          With chart Daily is not correct...it is High of this day


          I want if i use Chart Daily. this high must to be High Of Yesterday session

          Comment


            #6
            Hello turbofib,

            Thanks for your post.

            If you are using Calculate.OnEachTick or Calculate.OnPriceChange then Highs[1][0] would point to the currently forming bar (todays bar). In either of these modes, to get yesterdays bar you would need Highs[1][1].

            If you are using Calculate.OnBarClose then Highs[1][0] will provide the completed bar of yesterday.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I use always calculate.onbarclose...
              But there is different if i use chart intraday or i use chart daily...

              Comment


                #8
                Hello turbofib,

                Thanks for your reply and clarifying the calculate mode used.

                The screenshots you previously attached did not provide any clarity as to the issue, all I see is a green line at the high of each bar.

                I would advise putting both daily bars and your intraday bars on the same chart and then print out your values from Highs[1][0], perhaps similar to how I did in post #2, to help you resolve.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  theree is a pics(intraday and daily)...and i give you a code to test it



                  Can you apply my indicator in chart 60 minutes and chart daily...please
                  Attached Files
                  Last edited by turbofib; 09-19-2017, 02:35 PM.

                  Comment


                    #10
                    Hello turbofib,

                    Thanks for your reply.

                    I have attached what I see here. It plots as I would expect where the green line shows the prior days high value, perhaps I am misunderstanding what you are trying to accomplish or are expecting.
                    Attached Files
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      i see in your pics that is not okey....in chart intraday is correct,it plot high of session Yesterday...
                      In daily is not okey,it plot high of current session....

                      I want to plot High of yesterday session( in intraday chart) and want plot High of Yesterday (in daily chart)


                      i hope to clarify the question
                      Last edited by turbofib; 09-20-2017, 05:30 AM.

                      Comment


                        #12
                        Hello turbofib,

                        Thanks for your reply.

                        What you are seeing (in my previous posts example chart) is that that yesterdays high from your indicator is drawing intraday only because there are multiple bars intraday, however, the line is only drawn up to the last fully closed 60 minute bar and not to the current bar. This is because the indicator is running Calculate.OnbarClose.

                        In the chart of the daily bars, the line is not extended to the current bar because the indicator is running Calculate.OnBarClose and the current daily bar is still forming thus the line will not draw until the bar is closed.

                        In todays example chart, I have your indicator on the 60 minutes set the same as yesterday (OnBarClose) and on the daily bars I have set another instance of your indicator to OnPriceChange to illustrate.
                        Attached Files
                        Paul H.NinjaTrader Customer Service

                        Comment


                          #13
                          as i mentioned you, i need to create code that if i use chart with minute frame it give me High of session Yesterday, or if i use chart daily it give me High of Yesterday..
                          (High of Session if it's minute, High Of Daily if it's Daily)


                          I create this code
                          Can give me your opinion ( if is good or not)
                          I appreciate it...thank you
                          Attached Files
                          Last edited by turbofib; 09-20-2017, 10:58 AM.

                          Comment


                            #14
                            Hello turbofib,

                            Thanks for your reply.

                            The code you wrote says that if the chart bars are day, week, or month bars to then use the High[1] of the chart bars data series. Using Calculate.OnBarClose, this means you would use the high from:
                            The day before yesterday
                            The week before last week
                            The month before last month.

                            To meet your goal of, "i need to create code that if i use chart with minute frame it give me High of session Yesterday, or if i use chart daily it give me High of Yesterday.." You would want to use the High[0] to obtain:
                            Yesterday high for the day high
                            last week for the week high
                            last month for the month high

                            Also, I would change if (CurrentBar < 1 || CurrentBars[1] < 1) return; to if (CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
                            Paul H.NinjaTrader Customer Service

                            Comment


                              #15
                              in my code i had write Calculate = Calculate.OnPriceChange
                              not Calculate = Calculate.OnClose




                              anyway thanks
                              Last edited by turbofib; 09-20-2017, 11:38 AM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by terofs, Yesterday, 04:18 PM
                              1 response
                              21 views
                              0 likes
                              Last Post terofs
                              by terofs
                               
                              Started by CommonWhale, Today, 09:55 AM
                              1 response
                              3 views
                              0 likes
                              Last Post NinjaTrader_Erick  
                              Started by Gerik, Today, 09:40 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post Gerik
                              by Gerik
                               
                              Started by RookieTrader, Today, 09:37 AM
                              2 responses
                              13 views
                              0 likes
                              Last Post RookieTrader  
                              Started by alifarahani, Today, 09:40 AM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X