Set Limit Hours For An Indicator - page 4

 
Vladislav Boyko #:

If I understand you correctly and you want to hide fractals whose bar time does not fall within the range you specify, then you need to analyze the time of the bars (on which the fractals are located), and not the current time


[EDIT]

Apply your algorithm (below) not to TimeCurrent(), but to time[i]

(I did not check the correctness of the algorithm, and in this case it is better to remove the prints, otherwise you will get a million of them)


Bro What I Want is really really simple.

this indicator work all day long and print fractals arrows; I Want to work just from 9am to 11pm instead of all day long.

 
R4tna C #:

I think Vladislav has a very good point - perhaps the timing control should come after the exit from Oncalculate()

If it is just a matter of printing, then the timing code should be elsewhere

OK, But This Indicator Print arrow, in OnCalculate(). After That, How We Can Control The Operation Time?

 
p4rnak #:

OK, But This Indicator Print arrow, in OnCalculate(). After That, How We Can Control The Operation Time?

I a guessing here, but you could put the timing and print statement at the end of OnCalculate() 

The rest of the indicator code can run every time, the print code can be timed

I will be offline now until tomorrow, so I hope that helps for now

 
Vladislav Boyko #:
At the moment a new fractal appears, print something in the journal if the current time is in the range 09:00-23:00

In the settings, the time of prints is set, not the time of fractals

I just took the standard indicator, then added prints and filtered prints by time
Files:
 
Vladislav Boyko #:

In the settings, the time of prints is set, not the time of fractals

Yes, the code below can be simplified. This function is several years old, I'm too lazy to change and test it.

bool CTimeRange::isTimeInRange(int timeInMin,int startInMin,int endInMin)
  {
   if(startInMin > endInMin)
      return(timeInMin < startInMin && timeInMin > endInMin ? false : true);
   else return(timeInMin < startInMin || timeInMin > endInMin ? false : true);
  }
 
Vladislav Boyko #:

In the settings, the time of prints is set, not the time of fractals

I just took the standard indicator, then added prints and filtered prints by time

thanks a lot mate.

but this one still print all day long...

 
p4rnak #: I Use This One But It's Not Work On MT5 :

Of course, it doesn't. OnStart is only for scripts, not indicators.

 
William Roeder #:

Of course, it doesn't. OnStart is only for scripts, not indicators.

Yes, You right.

But I try other codes; no one works.

 
p4rnak #:

thanks a lot mate.

but this one still print all day long...

Log file?

It works correctly for me.


I ran it again with the settings 14:00-23:00, all prints are within the specified range:

2023.12.07 00:50:23.669 EURUSD,H1: testing of Indicators\FractalsPrinter\FractalsPrinter.ex5 from 2023.11.06 00:00 to 2023.12.06 00:00 started with inputs:
2023.12.07 00:50:23.669   inpFrom=14:00
2023.12.07 00:50:23.669   inpTo=23:00
2023.12.07 00:50:53.404 2023.11.06 20:00:00   A new lower fractal 1.07260 appeared on the 2023.11.06 17:00 bar
2023.12.07 00:50:53.689 2023.11.06 21:00:00   A new upper fractal 1.07491 appeared on the 2023.11.06 18:00 bar
2023.12.07 00:51:00.066 2023.11.07 16:00:00   A new lower fractal 1.06655 appeared on the 2023.11.07 13:00 bar
2023.12.07 00:51:08.426 2023.11.07 19:00:00   A new lower fractal 1.06640 appeared on the 2023.11.07 16:00 bar
2023.12.07 00:51:09.898 2023.11.07 22:00:00   A new lower fractal 1.06724 appeared on the 2023.11.07 19:00 bar
2023.12.07 00:51:21.805 2023.11.08 15:00:00   A new lower fractal 1.06593 appeared on the 2023.11.08 12:00 bar
2023.12.07 00:51:35.820 2023.11.08 16:00:00   A new upper fractal 1.06777 appeared on the 2023.11.08 13:00 bar
2023.12.07 00:51:37.627 2023.11.08 18:00:00   A new lower fractal 1.06601 appeared on the 2023.11.08 15:00 bar
2023.12.07 00:51:39.491 2023.11.08 21:00:00   A new upper fractal 1.07159 appeared on the 2023.11.08 18:00 bar
 
Vladislav Boyko #:

Log file?

It works correctly for me.


I ran it again with the settings 14:00-23:00, all prints are within the specified range:

I share my screenshot.