//this is not working: ObjectCreate ("fib_1", OBJ_FIBOFAN, 0, iHighest(NULL,0,MODE_TIME, 100), iHighest(NULL,0,MODE_HIGH, 100,0), iLowest(NULL,0,MODE_TIME,100), iLowest(NULL,0,MODE_HIGH,100,0)); ObjectSet ("fib_1", OBJPROP_COLOR, Red);
Can someone please kindly tell me how to find the date of a particular bar that is say 50 or 100 bars back (in code), so I can
use that date for my indicator parameters. (I only understand MQL4 to some extent --- MQL5 is too confusing for me)
Thanks in advance for all the help I have received here..
Sincerely, Russell
Hi,
Yes, you can't use Time[100] in mq5.
Here is my code in mq5 that can help you:
datetime time(string xSymbol, int xPeriod, int xBarIndex) { if(xBarIndex < 0) return(-1); ENUM_TIMEFRAMES timeframe=(ENUM_TIMEFRAMES)xPeriod; datetime Arr[]; if(CopyTime(xSymbol, timeframe, xBarIndex, 1, Arr)>0) return(Arr[0]); else return(-1); }
You can use it in this way:
//-- example : datetime time_in_bar_100 = time(_Symbol, _Period, 100);
Kind regards,
Yohana.
Hi .
The iHighest and iLowest return bar indices . (which bar has the highest and lowest)
In mt4 all the arrays are series so you don't care how you read these values
In mt5 you can use the iHigh to retrieve the index the iHighest returns (if it returns a valid index) and the iLow , as these iSeries are "series" ([0] is the newest)
Also , when you look for the lowest if its not intentional and a mistake (MODE_HIGH) ,use MODE_LOW
When you find the highest and lowest bars you can get their time by the same indices with iTime.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can someone please kindly tell me how to find the date of a particular bar that is say 50 or 100 bars back (in code), so I can
use that date for my indicator parameters. (I only understand MQL4 to some extent --- MQL5 is too confusing for me)
Thanks in advance for all the help I have received here..
Sincerely, Russell