Read the documentation, such as -
https://docs.mql4.com/series/ihighest to find the shift
then use
https://docs.mql4.com/series/ihigh on the shift to find the high of the bar
bxchen: How to get high of a certain time period I want to get the high for e.g time of my forex broker from 00:00:00 to 00:02:00 I want get the iHighest for the time period of 00:00:00 to 00:02:00 for Today How do I achieve it , sorry for asking and thanks for helping ! |
#define HR2400 (PERIOD_D1 * 60) // 86400 = 24 * 3600 int TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when % HR2400 ); } datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when - TimeOfDay(when) ); } //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent(); // return(DateOfDay(when) + HR2400); } //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent(); // int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); // return( iTime(NULL, PERIOD_D1, iD1) ); } #define HR0000 0 #define HR0002 (2*60) // 00:02:00 datetime bod=DateOfDay(); int iM1Bod = iBarShift(NULL, PERIOD_M1, bod + HR0000); int iM102 = iBarShift(NULL, PERIOD_M1, bod + HT0002 -1); // [0:00 - 0:02) int iM1HH = iHighest( NULL, PERIOD_M1, iM102 - iM1Bod + 1, iM1Bod); double M1HH= iHigh(NULL, PERIOD_M1, iM1HH); |
I don't know about this and also want to know . I think it is a good strategy.
whroeder1:
Found this thread in google and just want to correct two lines from the code from @whroeder1 (thx for that code!)
I think it should look like this
#define HR2400 (PERIOD_D1 * 60) // 86400 = 24 * 3600 int TimeOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when % HR2400 ); } datetime DateOfDay(datetime when=0){ if(when == 0) when = TimeCurrent(); return( when - TimeOfDay(when) ); } //datetime Tomorrow( datetime when=0){ if(when == 0) when = TimeCurrent(); // return(DateOfDay(when) + HR2400); } //datetime Yesterday(datetime when=0){ if(when == 0) when = TimeCurrent(); // int iD1 = iBarShift(NULL, PERIOD_D1, DateOfDay(when) - 1); // return( iTime(NULL, PERIOD_D1, iD1) ); } #define HR0000 0 #define HR0002 (2*60) // 00:02:00 datetime bod=DateOfDay(); int iM1Bod = iBarShift(NULL, PERIOD_M1, bod + HR0000); //int iM102 = iBarShift(NULL, PERIOD_M1, bod + HT0002 -1); // [0:00 - 0:02) int iM102 = iBarShift(NULL, PERIOD_M1, bod + HR0002 -1); // [0:00 - 0:02) // <-- this was the old line (small typo HT0002 vs. HR0002) //int iM1HH = iHighest( NULL, PERIOD_M1, iM102 - iM1Bod + 1, iM1Bod); // <-- this was the old line int iM1HH = iHighest( NULL, PERIOD_M1, MODE_HIGH, iM1Bod - iM102 + 1, iM102); double M1HH= iHigh(NULL, PERIOD_M1, iM1HH);
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How to get high of a certain time period
I want to get the high for e.g time of my forex broker
from 00:00:00 to 00:02:00
I want get the iHighest for the time period of 00:00:00 to 00:02:00 for Today
How do I achieve it , sorry for asking and thanks for helping !