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

PriorDayOHLC if statements

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

    PriorDayOHLC if statements

    I waz trying to use the following variables into an indicator.

    d110 & d111 work fine, however d112 does not. It outputs the same value as d111.

    Can anyone please see where I went wrong with my logic?

    Code:
     protected override void OnBarUpdate()    
                {
         
         if (CurrentBar < 1)
                        return;
        
                        d110            = (CurrentDayOHL().CurrentHigh[0] +     CurrentDayOHL().CurrentLow[0] + Close[0] ) / 3; // Current days       live pivot
        
                        if(PriorDayOHLC().PriorHigh[0] != 0 ||     PriorDayOHLC().PriorLow[0] != 0 || PriorDayOHLC().PriorClose[0] !=     0)
                        d111            = (PriorDayOHLC().PriorHigh[0] +     PriorDayOHLC().PriorLow[0] + PriorDayOHLC().PriorClose[0] ) / 3; //     Prior days pivot
                        
                        if(PriorDayOHLC().PriorHigh[1] != 0 ||     PriorDayOHLC().PriorLow[1] != 0 || PriorDayOHLC().PriorClose[1] !=     0)
                        d112            = (PriorDayOHLC().PriorHigh[1] +     PriorDayOHLC().PriorLow[1] + PriorDayOHLC().PriorClose[1] ) / 3; //[B]2 days back's pivot[/B]
        
        }

    #2
    Hi Tradethebonds,

    Thank you for your post.

    Are you running this script with CalculateOnBarClose set to true or false?

    What time frame are you running the script on?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Thanks, how can this be obtained please?

      CalculateOnBarClose set to false please.

      Time frame I am running on is a 6900 volume chart.
      Last edited by tradethebonds; 12-29-2013, 01:46 PM.

      Comment


        #4
        Tradethebonds,

        Thank you for the info.

        This is because you are using an intraday time frame.
        The index that you are calling is referring to the Bars themselves, not the days.
        PriorDayOHLC().PriorHigh[1] will reference one bar ago, not one day ago.

        You can try using Bars.FirstBarOfSession - 1 for the index to get the prior day values that you are looking for.

        http://www.ninjatrader.com/support/h...rofsession.htm
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Thx...but u are not correct here...PriorDayOHLC().PriorHigh[1] works fine...it is getting prior to that day's daily H, L & C.

          Comment


            #6
            Tradethebonds,

            How are you checking the values?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              It can be printed out and plotted. It matches the spreadsheet I have also.

              Here Ninjatrader_JC mentions that it works also...


              So I am only asking how to have this d112 value accessed please?

              Code:
              protected override void OnBarUpdate()                 {            if (CurrentBar < 1)                     return;                          d110            = (CurrentDayOHL().CurrentHigh[0] +     CurrentDayOHL().CurrentLow[0] + Close[0] ) / 3; // Current days       live pivot                          if(PriorDayOHLC().PriorHigh[0] != 0 ||     PriorDayOHLC().PriorLow[0] != 0 || PriorDayOHLC().PriorClose[0] !=     0)                     d111            = (PriorDayOHLC().PriorHigh[0] +     PriorDayOHLC().PriorLow[0] + PriorDayOHLC().PriorClose[0] ) / 3; //     Prior days pivot                                          if(PriorDayOHLC().PriorHigh[1] != 0 ||     PriorDayOHLC().PriorLow[1] != 0 || PriorDayOHLC().PriorClose[1] !=     0)                     d112            = (PriorDayOHLC().PriorHigh[1] +     PriorDayOHLC().PriorLow[1] + PriorDayOHLC().PriorClose[1] ) / 3; //[B]2 days back's pivot[/B]          }

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by gravdigaz6, Today, 11:40 PM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by MarianApalaghiei, Today, 10:49 PM
              3 responses
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by XXtrader, Today, 11:30 PM
              0 responses
              4 views
              0 likes
              Last Post XXtrader  
              Started by love2code2trade, Yesterday, 01:45 PM
              4 responses
              28 views
              0 likes
              Last Post love2code2trade  
              Started by funk10101, Today, 09:43 PM
              0 responses
              9 views
              0 likes
              Last Post funk10101  
              Working...
              X