Use loop. Nothing else comes to mind.
DateTime TMStart; DateTime TMEnd; int DayCount = 5; int StartIndex = 0; int EndIndex = 1000; while (StartIndex<EndIndex) { TMStart = Time[StartIndex]; TMEnd = TMStart + DayCount*24*3600; MaxVal(TMStart,TMEnd); StartIndex+=DayCount; }
Some way to loop.
Use loop. Nothing else comes to mind.
Some way to loop.
Time[0] is a (last) candle time, if loops starts from the beginning the first date should be Time[TMEnd]?
Time[0] is a (last) candle time, if loops starts from the beginning the first date should be Time[TMEnd]?
Time[0] - this is a current candle not yet closed. If you build calculations from the past to the future. Then you need to change the algorithm a little. In my example, the calculation goes from the current candle to the past.
DateTime TMStart; DateTime TMEnd; int DayCount = 5; int StartIndex = 1000; int EndIndex = 0; while (StartIndex>EndIndex) { TMStart = Time[StartIndex]; TMEnd = TMStart + DayCount*24*3600;//Date forward to future MaxVal(TMStart,TMEnd); StartIndex-=DayCount; }
Like this.
In the previous example I was a little wrong I should have written like this:
DateTime TMStart; DateTime TMEnd; int DayCount = 5; int StartIndex = 0; int EndIndex = 1000; while (StartIndex<EndIndex) { TMStart = Time[StartIndex]; TMEnd = TMStart - DayCount*24*3600;//Date back to the past MaxVal(TMStart,TMEnd); StartIndex+=DayCount; }
Time[0] - this is a current candle not yet closed. If you build calculations from the past to the future. Then you need to change the algorithm a little. In my example, the calculation goes from the current candle to the past.
Like this.Thx ! I will try the first solution, i had read bad first expression, it seems perfect.
StartIndex<EndIndex
Thx ! I will try the first solution, i had read bad first expression, it seems perfect.
Give it a try. Maybe someone will offer an even better option. In any case, you must use a loop to calculate MaxVal() and MinVal() each time passing a new date range in the parameters.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, how can I loop through days to find minvalue and max value, it would be interesting to write to file the following informations:
<Day number>,<session>,<MinValInRange>,<MaxValInRange>,<NumPipsInRange>,<VarPercent>
Variables:
The first 2 functions could be:
and