Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

finding high low over interval error in Sample code

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

    finding high low over interval error in Sample code

    Attached is a code snippet below from the 6.5 SampleGetHighLowByTimeRange.cs file shipped with 6.5.
    It finds different values when run in real time or Replay versus using F5 key.
    The F5 behavior is the "correct" behavior. I believe.
    The real time/replay does not include the last bar of the range properly.
    What am I missing to correct this?
    Thanks


    ==============
    / Check to make sure the end time is not earlier than the start time
    if (EndHour < StartHour)
    return;

    //Do not calculate the high or low value when the ending time of the desired range is less than the current time of the bar being processed
    if (ToTime(EndHour, EndMinute, 0) > ToTime(Time[0]))
    return;

    // If the stored date time date is not the same date as the bar time date, create a new DateTime object
    if (startDateTime.Date != Time[0].Date)
    {
    startDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, StartHour, StartMinute, 0);
    endDateTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, EndHour, EndMinute, 0);
    }

    // Calculate the number of bars ago for the start and end bars of the specified time range
    int startBarsAgo = GetBar(startDateTime);
    int endBarsAgo = GetBar(endDateTime);

    // Now that we have the start end end bars ago values for the specified time range we can calculate the highest high for this range
    double highestHigh = MAX(High, startBarsAgo - endBarsAgo)[endBarsAgo];

    // Now that we have the start end end bars ago values for the specified time range we can calculate the lowest low for this range
    double lowestLow = MIN(Low, startBarsAgo - endBarsAgo)[endBarsAgo];

    // Set the plot values
    HighestHigh.Set(highestHigh);
    LowestLow.Set(lowestLow);

    #2
    Have you tried running the code with CalculateOnBarClose = false in the indicator properties?

    Comment


      #3
      Bertrand:
      The indicator in which I am using the snippet already has CalculateOnBarClose = false. and still experiences the problem

      Comment


        #4
        Hi Roland, ok thanks - can you please post the indicator so I can give it a run here?

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, 03-23-2026, 04:31 AM
        0 responses
        42 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        295 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        290 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        135 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        98 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X