Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CurrentDayOHL plotting wrong open.

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

    #16
    Hello AdeptistJune,

    Thanks for your reply.

    Sorry but I am still confused about what you have done.

    If everything is in one indicator why then would you do this: MyRTHOHL1 = MyRTHOHL(Close, DateTime.Parse("8:31 AM"), DateTime.Parse("5:00 PM")); ? You cannot add an indicator to itself.

    Comment


      #17
      Hello,

      I added 4 more double-type variables to hold each of the prior day values in the existing indicator. On the last bar of the RTH session, I stored the currentday low, just as a test, and printed an output. So what would cause the plot value to be: 0

      if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay < RTHEnd.TimeOfDay)
      {
      RTHOpen = myRTHOpen;
      //Print (Time[0] + "RTHOpen:" + RTHOpen);

      if (High[0] > myRTHHigh)
      {
      myRTHHigh = High[0];
      }

      if (Low[0] < myRTHLow)
      {
      myRTHLow = Low[0];
      }

      RTHHigh = myRTHHigh;
      RTHLow = myRTHLow;
      Print (Time[0] + "RTHHigh:" + RTHHigh + "|" + "RTHLow:" + RTHLow );
      }
      if (Time[0].TimeOfDay == new TimeSpan(16,59, 00))
      {
      myPREVLOW = RTHLow;
      }
      Print (Time[0] + "myPREVLOW:" + myPREVLOW);
      }
      Attached Files

      Comment


        #18
        Hello AdeptistJune,

        Thanks for your reply.

        Try changing the time filter from: if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay < RTHEnd.TimeOfDay)

        To : if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay <= RTHEnd.TimeOfDay)

        Comment


          #19
          Hello, Paul

          I changed to: if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay <= RTHEnd.TimeOfDay)

          But the results are still the same.
          Attached Files

          Comment


            #20
            Hello AdeptistJune,

            Thanks for your reply.

            The print statements look like this:

            12/30/2021 3:58:00 PMRTHHigh:4799.75|RTHLow:4767.25
            12/30/2021 3:58:00 PMmyPREVLOW:0
            12/30/2021 3:59:00 PMRTHHigh:4799.75|RTHLow:4767.25
            12/30/2021 3:59:00 PMmyPREVLOW:0
            12/30/2021 4:00:00 PMRTHHigh:4799.75|RTHLow:4767.25
            12/30/2021 4:00:00 PMmyPREVLOW:0
            12/30/2021 5:01:00 PMmyPREVLOW:0
            12/30/2021 5:02:00 PMmyPREVLOW:0
            12/30/2021 5:03:00 PMmyPREVLOW:0
            12/30/2021 5:04:00 PMmyPREVLOW:0
            12/30/2021 5:05:00 PMmyPREVLOW:0

            See how your RTH prints stop at 4:00 PM (16:00)

            I suspect you have a mismatch between the RTHEnd actual time and the specific time of 16:59. Please check that you have RTHEND set to 5:00 PM.

            Actually, you should be able to use RTHEnd instead of the 16:59.

            So please try: if (Time[0].TimeOfDay == RTHEnd.TimeOfDay)

            Comment


              #21
              Hello, Paul,

              I did as instructed, but there was no change in the prints.
              Attached Files

              Comment


                #22
                Hello, Paul,

                Two things I learned from the print statement. 1.) The reason my previous plot value is "0" has something to do with the check condition "if (Time[0].TimeOfDay == RTHEnd.TimeOfDay)"

                protected override void OnBarUpdate()
                {
                if (BarsInProgress == 1)
                return;

                if (CurrentBars[0] < 1)
                return;

                if (Time[0].TimeOfDay == RTHStart.TimeOfDay)
                {
                myRTHOpen = Open[0];
                myRTHHigh = High[0];
                myRTHLow = Low[0];
                }

                if (Time[0].TimeOfDay >= RTHStart.TimeOfDay && Time[0].TimeOfDay < RTHEnd.TimeOfDay)
                {
                RTHOpen[0] = myRTHOpen;

                if (High[0] > myRTHHigh)
                {
                myRTHHigh = High[0];
                }

                if (Low[0] < myRTHLow)
                {
                myRTHLow = Low[0];
                }

                RTHHigh[0] = myRTHHigh;
                RTHLow[0] = myRTHLow;
                }
                else
                {
                RTHOpen[0] = RTHOpen[1];
                RTHHigh[0] = RTHHigh[1];
                RTHLow[0] = RTHLow[1];
                }
                Print(Time[0] + "RTHOpen[0]:" + RTHOpen[0] + "|" + "RTHHigh[0]:" + RTHHigh[0] + "|" + "RTHLow[0]:" + RTHLow[0]);
                }

                Comment


                  #23
                  Hello, Paul,

                  I figured out why the previous plot values were plotting: 0.

                  The trading session close is at 1600 not 1700. So when I was doing the time check: if (Time[0].TimeOfDay == RTHStart.TimeOfDay) instead of if (Time[0].TimeOfDay == new TimeSpan(16,00, 00)), I guess it was calling data that did not exist.

                  Attached Files

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  580 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  336 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  102 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  554 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  552 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X