Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator not processing every day from historical data

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

    Indicator not processing every day from historical data

    Hello, I have created indicator for logging data.

    I want to log data between certain date and time. I want to set Start timestamp and End timestamp and log data between given hours in each day for example between 08:00 and 15:30.

    This indicator works but is not logging every day even though I do not see problem with the conditions in my code. For example if I run this indicator on historical data which are from for example 25.9. 2024 until 12.10. 2024 and set my Start timestamp to 26.9. and End timestamp to 12.10. the indicator will start logging from 4.10. and stop logging after 3 days which is on 7.10.

    Logging is done by writing into text file.

    The Start timestamp and End timestamp are user input parameters which are set in SetDefaults state like this:

    var now = DateTime.Now.ToUniversalTime();
    StartTimestamp = new DateTime(now.Year, now.Month, now.Day, 7, 30, 0).ToUniversalTime();
    EndTimestamp = new DateTime(now.Year, now.Month, now.Day, 15, 30, 0).ToUniversalTime();​

    My OnBarUpdate method is:

    Code:
    protected override void OnBarUpdate()
    {
      if (Count < 2)
        return;
    
      var timestamp = Time[0].ToUniversalTime();
    
      if (timestamp >= StartTimestamp && timestamp <= EndTimestamp)
      {
        var start = timestamp.TimeOfDay >= StartTimestamp.TimeOfDay;
        var end = timestamp.TimeOfDay <= EndTimestamp.TimeOfDay;
    
        if (start && end)
        {
           // Write to textfile ommited
        }
      }
    }​
    Are there any reasons why the indicator should not work on historical data? Should I use something else? Could you please help?

    Thanks in advance
    Kind Regards

    #2
    Hello,

    Thank you for your inquiry.

    If you print out Times[0][0] at the top of OnBarUpdate (outside of any conditions), are you still seeing the historical data being skipped?

    If not, it is likely your conditions which are leading to the script not writing to the file on those days. You'll need to debug the script using prints to determine why the logic of the script is causing certain days to be skipped.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    672 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    577 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X