tonyjms2005:
What if I wanted to go from 00:00 hours and up the current bar +2 how can I do this I have been playing about with the "false" part of the code but with no luck.
Thanks
Antony
Your issue is that your are not setting a start value for iHighest, if it is not set then it assumes a value of 0, i.e. the current bar . . .
https://docs.mql4.com/series/iHighest
so change to this . . . (coloured braced added for clarity)
double dHi = nd(iHigh(Symbol(), Period(), iHighest(Symbol(), Period(), MODE_HIGH, iBarShift(Symbol(),Period(),dst,false), 2 ) ) );
tonyjms2005:
What if I wanted to go from 00:00 hours and up the current bar +2 how can I do this I have been playing about with the "false" part of the code but with no luck.
What if I wanted to go from 00:00 hours and up the current bar +2 how can I do this I have been playing about with the "false" part of the code but with no luck.
- Write readable code.
datetime dst = Time[0] - Time[0] % 86400; // Today 00:00 int shiftTo = iBarShift(NULL,0, dst), // from 00:00 hours shiftFrom = 2, // to current bar +2 length = shiftTo - shiftFrom + 1; if (length <= 0) return; // Sunday market opens 22:00. There may NOT be two bars. int shiftHigh = iHighest(NULL,0, MODE_HIGH, length, shiftFrom); double HH = High[shiftHigh], dHi = nd(HH);
Then you can print pieces to find problems. - No need to use iHigh(), marketInfo(MODE_ASK), etc. when you can use the simpler High[], Ask.
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
Hi
I am using ibarshift to identify the daily start time of a session for my EA:
The "dst" is defined in the EA already, so if dst is 00:00hours then it will look for the higest price from 00:00 to the current bar?
What if I wanted to go from 00:00 hours and up the current bar +2 how can I do this I have been playing about with the "false" part of the code but with no luck.
Thanks
Antony