Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Previous day high low open close price in C#

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

    Previous day high low open close price in C#

    Hi Team,
    I will be using 5 minutes time timeframe for intraday but I need previous day with timeframe of day Low, High, Open and Close Price details.
    How can I get the details while I am in 5 minutes candle but looking for previous day DAY candle details




    #2
    Hello rajeshks1988,

    Thank you for your post.

    You could call the PriorDayOHLC indicator to get that information:



    Please let us know if we may be of further assistance to you.

    Comment


      #3
      Thanks for your quick reply.
      Could you please let me know how I can check today's Open Price.
      I can loop to all 5 candles but I wanted to know if there is any option to get Open price of the day?

      Comment


        #4
        Hello rajeshks1988,

        Thank you for your reply.

        You could call CurrentDayOHL().CurrentOpen[0] to get the current session open for the current bar:



        Please let us know if we may be of further assistance to you.

        Comment


          #5
          Thank you.

          Comment


            #6
            Hi Team,
            I am using following code for getting previous day hig low


            double previousDayClose = PriorDayOHLC().PriorClose[0];
            double previousDayHigh = PriorDayOHLC().PriorHigh[0];
            double previousDayOpen = PriorDayOHLC().PriorOpen[0];
            double previousDayLow = PriorDayOHLC().PriorLow[0];

            But Getting value as 0 for high low open and close.

            can you suggest me.
            I am trying in offline market but it suppose to work right.

            Comment


              #7
              Sorry I am able to get the previous Day data but not matching the value with previous close price.

              Can you please suggest why

              MY stock previous close 1350 but here I am getting 1360.

              Comment


                #8
                Hello rajeshks1988,

                Thank you for your reply.

                Since the PriorDayOHLC calculates from intraday data, while daily bars use the settlement close, it would be expected that they would be different.

                If you wish to get the prior day settlement close, you would need to add an additional 1 day series in your code, ensure you have at least 1 daily bar before calculating, and then reference the close price of the daily bar like so:

                Code:
                 protected override void OnStateChange()
                {
                if (State == State.SetDefaults)
                {
                Description = @"Enter the description for your new custom Indicator here.";
                Name = "ExampleGetPriorDaySettlementClose";
                Calculate = Calculate.OnBarClose;
                IsOverlay = false;
                DisplayInDataBox = true;
                DrawOnPricePanel = true;
                DrawHorizontalGridLines = true;
                DrawVerticalGridLines = true;
                PaintPriceMarkers = true;
                ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                //See Help Guide for additional information.
                IsSuspendedWhileInactive = true;
                }
                else if (State == State.Configure)
                {
                AddDataSeries(BarsPeriodType.Day, 1);
                }
                }
                
                protected override void OnBarUpdate()
                {
                if(CurrentBars[1] < 1)
                return;
                
                double mySettlementPrice = Closes[1][1];
                }
                Please let us know if we may be of further assistance to you.

                Comment


                  #9
                  I do not see the exact previous open, close, high and low values of previous Day candle.

                  Sometime I get values of high,open, low but not close value accurately.

                  so basically I am unable to get the exact information of all the values in C# strategy.

                  example, used below code for getting details of Axis Bank for 21/01/2021(on 22/01/2021 day using below code) values appeared as Low:673.6 High:690.8 Open:676.45 Close:689.5)
                  double previousDayClose = PriorDayOHLC().PriorClose[0];
                  double previousDayHigh = PriorDayOHLC().PriorHigh[0];
                  double previousDayOpen = PriorDayOHLC().PriorOpen[0];
                  double previousDayLow = PriorDayOHLC().PriorLow[0];

                  But actual Low:669.75 High:695 Open:680.75 & Close:675.85


                  I have also attached the trading platform candles which is not similar if you observe, so why do I see such difference?
                  Attached Files
                  Last edited by rajeshks1988; 01-23-2021, 02:46 PM.

                  Comment


                    #10
                    Hello rajeshks1988,

                    Thank you for your reply.

                    This is due to the daily bars being settlement adjusted whereas the PriorDayOHLC() uses intraday data, which means the Close price is not settlement adjusted and would be expected as I mentioned in my last post:

                    Originally posted by NinjaTrader_Kate View Post
                    Hello rajeshks1988,

                    Thank you for your reply.

                    Since the PriorDayOHLC calculates from intraday data, while daily bars use the settlement close, it would be expected that they would be different.

                    If you wish to get the prior day settlement close, you would need to add an additional 1 day series in your code, ensure you have at least 1 daily bar before calculating, and then reference the close price of the daily bar like so:

                    Code:
                     protected override void OnStateChange()
                    {
                    if (State == State.SetDefaults)
                    {
                    Description = @"Enter the description for your new custom Indicator here.";
                    Name = "ExampleGetPriorDaySettlementClose";
                    Calculate = Calculate.OnBarClose;
                    IsOverlay = false;
                    DisplayInDataBox = true;
                    DrawOnPricePanel = true;
                    DrawHorizontalGridLines = true;
                    DrawVerticalGridLines = true;
                    PaintPriceMarkers = true;
                    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive = true;
                    }
                    else if (State == State.Configure)
                    {
                    AddDataSeries(BarsPeriodType.Day, 1);
                    }
                    }
                    
                    protected override void OnBarUpdate()
                    {
                    if(CurrentBars[1] < 1)
                    return;
                    
                    double mySettlementPrice = Closes[1][1];
                    }
                    Please let us know if we may be of further assistance to you.

                    Comment


                      #11
                      Is it possible to call the closing price of the last 3-4 Monday Closes?

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by NullPointStrategies, Today, 05:17 AM
                      0 responses
                      50 views
                      0 likes
                      Last Post NullPointStrategies  
                      Started by argusthome, 03-08-2026, 10:06 AM
                      0 responses
                      126 views
                      0 likes
                      Last Post argusthome  
                      Started by NabilKhattabi, 03-06-2026, 11:18 AM
                      0 responses
                      69 views
                      0 likes
                      Last Post NabilKhattabi  
                      Started by Deep42, 03-06-2026, 12:28 AM
                      0 responses
                      42 views
                      0 likes
                      Last Post Deep42
                      by Deep42
                       
                      Started by TheRealMorford, 03-05-2026, 06:15 PM
                      0 responses
                      46 views
                      0 likes
                      Last Post TheRealMorford  
                      Working...
                      X