-
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon.There is no such function in MT5 (StrToTime). It is deprecated in MT4. Use StringToTime.
Your code int LHSearchcandle = iBarShift(_Symbol,_Period,StrToTime("09:00")),true); int HLSearchcandle = iBarShift(_Symbol,_Period,StrToTime("09:00")),true); // 1 2 21 ?
Fixed int LHSearchcandle = iBarShift(_Symbol, _Period, StringToTime("09:00"), true);
-
Why are you searching for the same thing twice?
-
When dealing with time, a lot of people use strings; they can not be optimized. Using (int) seconds or (double) hours and fraction can be inputs.
See also Dealing with Time (Part 1): The Basics - MQL5 Articles (2021.10.01)
Dealing with Time (Part 2): The Functions - MQL5 Articles (2021.10.08)
MQL5 Programming Basics: Time - MQL5 Articles (2013.04.26)Remember to handle the case where start > end (e.g. 2100 … 0200
Thanks for your help. didnt realise it was in the Mq5 section. although whe ni go to Mql4.com go to forums it redirects to the mql5 forum page.
its being searched twice as i want to to store in two different variables that are named in accordance to the strategy.
however the fix does not work in MT4, which is what i am coding it in.
-
Don't double post! You already had this thread open.
General rules and best pratices of the Forum. - General - MQL5 programming forum (2017) -
What part of “bottom of the root page” was unclear? There is no MT4.com forums.
- mheathcote89 #: its being searched twice as i want to to store in two different variables that are named in accordance to the strategy.But your search is identical, results in the same identical index. If you want “to store in two…” then store it V1=V2=iBarShift(…)
ok i see, i may do that then.
do you have any idea why it doesn't compile in mt4 please?
ok i see, i may do that then.
do you have any idea why it doesn't compile in mt4 please?
William has already given you the solution.
You should also be wary of using StringToTime() with just the time. When you do that it will take the date from your computer's local time and this can result in an unwanted date.
My local time is 5 hours ahead of my platform time. So between midnight and 5 AM it would result in a datetime that is effectively tomorrow compared to broker time.
The solution does not compile in MT4. so i would not consider it a solution.
the date will always need to be the current date. the broker time is the same as mine.
the error is, when compiled shows the error 'true' name expected.
Pay attention to the answers given, especially about the the unbalanced brackets, which William even numbered for you to see the problem. As they say—the devil is in the details.
- 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,
im trying to code a variable that will be the index of a candle at a time to start scanning the candle for various price points.
int LHSearchcandle = iBarShift(_Symbol,_Period,StrToTime("09:00")),true);
int HLSearchcandle = iBarShift(_Symbol,_Period,StrToTime("09:00")),true);
the above code, when compiled shows the error 'true' name expected.
i have no idea how to correct this.
i also tried;
datetime timetmp = StrToTime(TimeToStr(Time[0],TIME_DATE) + " " + "09:00");
int LHSearchcandle = iBarShift(Symbol(),_Period, timetmp),True);
but this doesnt work either.