Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access to low in BarsArray

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

    Access to low in BarsArray

    Hello,

    for coding strategies including different timeframes (Add(PeriodType.Range, 15) I have one problem as I can not access the Low of a Bar in this timeframe (BarsArray[1]). How can I code correctly eg (as now I get error messages)

    If Lows[BarsArray[1] [0] < EMA((BarsArray[1],15 [0])

    I can compare different Bars within this BarsArray or code "Rising, CrossAbove"... but I couldn´t do "If Low of Bar < EMA(15)".

    Thanks
    Tony

    #2
    Hello tonynt,

    You use Lows[1][0] if you want to access the low of the secondary time frame.

    if (Lows[1][0] < EMA(BarsArray[1],15)[0])


    http://www.ninjatrader-support.com/H...deV6/Lows.html
    Last edited by NinjaTrader_RyanM1; 06-17-2010, 04:25 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you!

      I want to state hereby again that the support is great - within few minutes there´s always a help.

      Greetings to all there at NinjaTrader!

      Best
      Tony

      Comment


        #4
        Glad that helped, Tony. Thanks for the feedback.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by tonynt View Post
          Thank you!

          I want to state hereby again that the support is great - within few minutes there´s always a help.

          Greetings to all there at NinjaTrader!

          Best
          Tony
          Thanks for asking the question so I could find the answer!!

          Comment


            #6
            barsarray

            hi a believe I am asking in the right place,


            I am running a 60 min per bar strategy and need to add 1 min bars, I can call upon them no problem with
            PHP Code:
            add(PeriodType.Minute,1); 
            
            the question I have is that my strategy get signals as such :

            PHP Code:
            onbarupdate() 
            /* I get my high for the first 60 1 min bars - example from 12h00-12h59 */ 
            double XX = MAX(High.BarsArray[1], 60)[0] 
            /*get my high for 60 bars, (minus the first 1 min bar (12h00) and add the next one (1h00)) - 12h01 to 1h00 */ 
            double XX1 =MAX(High.BarsArray[1], 60)[-1] 
            
            /* trade */ 
            if(XX > XX1) 
            enterlong 
            
            am I using the right code (barsArray)? and is the [0] and [-1] giving me what I actually want?

            I know I should be tracking what this does and printing the outcomes in the output window, but if I am completely off...sad.

            thanks

            Comment


              #7
              Hi ChanceHero,

              You want to use Highs here, to access highs of secondary series.

              Highs[1] //Secondary Series high. Use this as input for other indicators.
              Highs[1][0] //Most recent secondary series high. Use this for parameters expecting a double as input.

              double XX = MAX(Highs[1], 60)[0]

              Using negative index values is not supported. You'll want to use positive index values to reference prior values.

              double XX1 =MAX(Highs[1], 60)[1] //gets the highest high of last 60 bars, starting one bar prior to the bar you're calling this from.
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                ok getting better

                Ok so I think I get it. now I have something like :

                NOTE: my main bars are 60 min. my secondary bar (index 1) are 1 min bars

                PHP Code:
                /* to obtain the first set of values for this just past hour example if it is 1pm now - this is getting me the 60 bars from 12h-1pm*/
                            double X00Y00 = MAX(Highs[1], 60)[0];
                            double X01Y00 = MAX(Highs[1], 60)[1];
                            double X02Y00 = MAX(Highs[1], 60)[2];
                            /* to obtain my second set of values for two hours ago - if it is 1pm now - this is getting me the 60 bars  from 11h (am) - 12h  */
                            double X00Y01 = MAX(Highs[1], 60)[60];
                            double X01Y01 = MAX(Highs[1], 60)[61];
                            double X02Y01 = MAX(Highs[1], 60)[62];
                            /* to obtain my third set of values for three hours ago - if it is 1pm now - this is getting me the 60 bars from 10am - 11am */
                            double X00Y02 = MAX(Highs[1], 60)[120];
                            double X01Y02 = MAX(Highs[1], 60)[121];
                            double X02Y02 = MAX(Highs[1], 60)[122];
                            
                            if(X00Y00 < X00Y01 < X00Y02);
                            {
                                myEntryOrder = EnterLongLimit(0,true,1,Close[0], "LongA0"]);    
                            }    
                            if(X01Y00 < X01Y01 < X01Y02);
                            {
                                myEntryOrder = EnterLongLimit(0,true,1,Close[0], "LongA1"]);    
                            }    
                            if(X02Y00 < X02Y01 < X02Y02);
                            {
                                myEntryOrder = EnterLongLimit(0,true,1,Close[0], "LongA2"]);    
                            } 
                
                It seem that since I am only jumping 60 bars at a time, there could be a easier way to do this. Especially if I want to do the three sets but 60 times each. i.e. from X00Y00 to X00Y59 and X01Y00 to X01Y59 and X02Y00 to X02Y59 and enter the same entry logic as I have above.

                thanks and have a great new year!

                Comment


                  #9
                  You could look into looping commands to simplify and run through iterations needed more efficiently - http://www.ninjatrader.com/support/h...g_commands.htm

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  106 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  54 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  36 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  38 views
                  0 likes
                  Last Post TheRealMorford  
                  Started by Mindset, 02-28-2026, 06:16 AM
                  0 responses
                  74 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Working...
                  X