Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator's PriorDayOHLC().PriorClose[0]

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

    Indicator's PriorDayOHLC().PriorClose[0]

    I want to get this value: priorOpenPrice0 = PriorDayOHLC().PriorClose[0]; for a specific indicator (the last indicator value for the day before).
    How can I get that?

    #2
    Hello dafonseca,

    Thanks for your post.

    If I understand correctly, you want to obtain the value of an indicator on the last bar of the session.

    Here is a code example, using the SMA indicator

    if (Bars.FirstBarOfSession)
    {
    double yesterdaysEndingSMA = SMA[1]; // save the prior sma value on first bar of new session.
    }

    Comment


      #3
      If I understood, this will get the first bar value of the current session. What I want is the last bar value of the previous session.

      Comment


        #4
        Hello dafonseca,

        Thanks for your reply.

        I apologize for not explaining the logic better.

        This statement: if (Bars.FirstBarOfSession) will be true on the very first bar of the session.

        This statement: double yesterdaysEndingSMA = SMA[1]; will get the previous SMA value and put it in the double variable yesterdaysEndingSMA. This was just an example indicator.

        Please note that SMA[0] would be the current bar so if the current bar is the first bar of the session that would mean the the prior bar [1] is the last bar of the previous session. You could apply the logic to any indicator.

        Comment


          #5
          now I see.

          In case I am using a indicator such as:
          ncatHistoricalVolatility("6229", 40, false, 1, PeriodType.Minute)

          Can I use
          ncatHistoricalVolatility("6229", 40, false, 1, PeriodType.Minute)[1]
          ??

          Comment


            #6
            Hello dafonseca,

            Thanks for your reply.

            I'm sorry, I have no knowledge of that indicator but if it outputs on a bar to bar basis then I suspect it will.

            Comment


              #7
              I will check, But one more question:
              regarding (Bars.FirstBarOfSession)

              how can I be sure that (Bars.FirstBarOfSession) will consider the right value.

              In case of backtesting, for instatnce, does (Bars.FirstBarOfSession) consider the first bar of each session??
              supposing I am runing my strategy on a 5 days chart, will (Bars.FirstBarOfSession) updated all five days' sessions?

              Comment


                #8
                Hello dafonseca,

                Thanks for your reply and great questions.

                When you load an indicator or strategy (backtesting, market replay, live data) it will start at very first bar of the data series and work from left to right ending at the current bar on the chart. As it moves from the end of one session to the beginning of the next the bool FirstBarOfSession will be true for the duration of the first bar.

                You can validate this yourself by adding print statements and observing the data printed in the output window, something like:

                if (Bars.FirstBarOfSession)
                {
                Print ("FirstBarofSession: "+Time[0]); //print the date/time of the first bar of the session as it occurs
                }
                if you had 5 days of data, you would likely see 4 - 5 prints.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                633 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                364 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                105 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                567 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                568 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X