Good evening all,
In order to improve the quality of my alerts I need to calculate the Highest High and the Lowest Low on every day starting from Midnight to any bar on any day, so that would be [i].
I found this thread where Whroeder explains how something like this should be done: https://www.mql5.com/en/forum/139445
Based on his explanation I wrote the following code, the code compiles without errors, but it isn't working. Can someone pleas tell me what I'm doing wrong here?
I'm not sure I follow... If all you need is the High and Low of the current day's bar then why are you using the code above? That code will give you the H/L of a rolling 24h window. This is an example of how to get the H/L from today on the the current timeframe.
void OnStart() { RefreshRates(); datetime day_begin = iTime(_Symbol, PERIOD_D1, 0); int x = iBarShift(_Symbol, PERIOD_CURRENT, day_begin); int index_high = ArrayMaximum(High, x, 0); int index_low = ArrayMinimum(Low, x, 0); printf("High of Today is %.5f @ %s", High[index_high], TimeToString(Time[index_high]) ); printf("Low of Today is %.5f @ %s", Low[index_low], TimeToString(Time[index_low]) ); }
Then next time I'd suggest reviewing your post before you submit it.
I need to calculate the Highest High and the Lowest Low on every day starting from Midnight
I need to calculate the Highest High and the Lowest Low on every day starting from Midnight
So that is not just on the current day.
I need to calculate the Highest High and the Lowest Low on every day starting from Midnight
So that is not just on the current day.
It is as I wrote originally every day from midnight
I want the code to take into account the number of pips between de HH end LL formed after midnight of each day.
I want it to calculate the range on any moment of each day
I hope this clarifies my original request, because I wouldn't know how to put it any clearer.
Then next time I'd suggest reviewing your post before you submit it.
Hi again Nicholi Shen,
Apparently I was tired yesterday evening and didn't understand your response correctly. I read it again today and I would like to thank you for your explanation.
It was only now I saw that I did not have coded Midnight. The example I used mentioned " Beginning of the day" and I took that for Midnight.
I'll use your code and hope to get this working.
Thanks
Hi Nicholi Shen,
I saw in your code you used shift zero, so that will return only the last midnight. I need every midnight, so I changed my code as shown below, but it still doesn't work. Can you tell me what I'm doing wrong her please.
datetime DayStart = iTime(NULL,PERIOD_D1,i); int BarDS = iBarShift(NULL,PERIOD_M5,DayStart, false); int Shift = BarDS-i+1; double HHFromDS = Close[iHighest(NULL,PERIOD_M5, MODE_CLOSE,Shift,i)]; datetime TimeHHDS = Time[iHighest(NULL,PERIOD_M5, MODE_CLOSE,Shift,i)]; int BarHHDS = iBarShift(NULL,PERIOD_M5, TimeHHDS, false); double LLFromDS = Close[iLowest(NULL,PERIOD_M5, MODE_CLOSE, Shift,i)]; datetime TimeLLDS = Time[iLowest(NULL,PERIOD_M5, MODE_CLOSE,Shift,i)]; int BarLLDS = iBarShift(NULL,PERIOD_M5, TimeLLDS, false); double RangeHHLL = (HHFromDS - LLFromDS) * factor;//number of pips between HH and LL since midnight
Hi Nicholi Shen,
I saw in your code you used shift zero, so that will return only the last midnight. I need every midnight, so I changed my code as shown below, but it still doesn't work. Can you tell me what I'm doing wrong her please.
Don't ever use the platform timeseries (High, Low, etc.) when you specify a timeframe. Instead you have to use iTimeseries functions.
I was not familiar with those, I will study them first,
Thanks
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Good evening all,
In order to improve the quality of my alerts I need to calculate the Highest High and the Lowest Low on every day starting from Midnight to any bar on any day, so that would be [i].
I found this thread where Whroeder explains how something like this should be done: https://www.mql5.com/en/forum/139445
Based on his explanation I wrote the following code, the code compiles without errors, but it isn't working. Can someone please tell me what I'm doing wrong here?