Good day to all,
I'm using MT4, but I just started to convert my indicators and scripts to MT5, so MT5 is new to me.
I'm using the code below which is in principle the same as I used to calculate the starting point of the grid in MT4, but in MT5 LastGloseGridnumber is calculated as zero which is not correct. Can anyone please explain what should be coded differently? (pips is set as: int pips = 250;)
have you done the math, do you know what the answer should be?
have you checked the value of the variables with the debugger?
do you know what order the highlighted line is calculated in?
regards
double myPoint = SymbolInfoDouble(_Symbol,SYMBOL_POINT); //--- double LastClose = iClose(NULL,PERIOD_H1,1); int LastCloseGridNumber = MathRound(LastClose/pips*myPoint); double StartPrice = (LastCloseGridNumber * pips)/(1/myPoint); //--- Print("LastClose = " + LastClose,"LastCloseGridNumber = " + LastCloseGridNumber, "pips = " + DoubleToString(pips,0));
example of your code output based on EURUSD
- www.mql5.com
Hi Paul,
Thanks for your response. I noticed I had forgotten to put brackets like this (interval*myPoint), this solves the problem, and I changed the type of the LastClosedGridNumber to double, so now the code composes without warnings too.
Thanks again, and have a nice day,
Robert
- 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 day to all,
I'm using MT4, but I just started to convert my indicators and scripts to MT5, so MT5 is new to me.
I'm using the code below which is in principle the same as I used to calculate the starting point of the grid in MT4, but in MT5 LastGloseGridnumber is calculated as zero which is not correct. Can anyone please explain what should be coded differently? (pips is set as: int pips = 250;)
Best regards,
Robert