Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1265
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
Good Morning All!
Question: what is the easiest way to determine the high and low times of a bar?
Baropen/close time is not interesting.
On MT4.
Thank you!
did this
posted in KBhttps://www.mql5.com/ru/code/25897
Please tell me, in MT4 there was a predefined variable double Ask, and as I understand, inside void OnTick() without forced
RereshRates its value would NOT change.
In MT5, Ask is replaced by MqlTick last_tick; SymbolInfoTick(_Symbol,last_tick); double Ask=last_tick.ask ; its value is always updated by a new tick.
My problem is that I need to set the line coordinate by the value of Ask + X but I can't do it in MT5 because the line changes its coordinates after the value changes
Ask=last_tick.ask. What is your advice?
Please tell me, in MT4 there was a predefined variable double Ask, and as I understand, inside void OnTick() without forced
RereshRates its value would NOT change.
In MT5, Ask is replaced by MqlTick last_tick; SymbolInfoTick(_Symbol,last_tick); double Ask=last_tick.ask ; its value is always updated by a new tick.
My problem is that I need to set the line coordinate by the value of Ask + X but I can't do it in MT5 because the line changes its coordinates after the value changes
Ask=last_tick.ask. What is your advice?
How it did not change? It changed with every tick. But in the loop, it didn't change. Maybe you have got a little confused with it?
But in mql5 you can determine the current price before the loop and it won't change until you exit the loop.
Is there any way to measure the width in pixels of the written text in OBJ_TEXT?
How did it not change? It changed with every tick. But in the cycle, yes, it didn't. Maybe, you got a little confused with that one?
But in mql5 you can determine the current price before the loop and it will not change until you exit the loop.
Yes, thank you, my assumption turned out to be wrong, but the question is a bit different. I have a code, samefor MT4 and MT5:
The question is that in MT4 the created line will be fixed at the price at which it was created, but in MT5 every time on a new tick the line will be drawn at a new value of LastAsk and its position will change along with the price. How can I avoid it in MT5?
Yes, thanks, my assumption was wrong, but the question is a bit different. There is a code,same for MT4 and MT5:
The question is that in MT4 the line created will be stationary at the price at which it was created, but in MT5 every time on a new tick the line will be drawn at a new LastAsk value and its position will change along with the price. How can I avoid it in MT5?
Check for a line by name. If there is no line, create one. This is the basics in general.
Thank you, what else can I read about these programming logic basics? It seems elementary, but it's hard to figure out from scratch.
I added a condition and everything worked.
Thank you, what else can I read about these programming logic basics? It seems elementary, but it's hard to figure out from scratch.
I added a condition and everything worked.
Suddenly (as usual) ObjectGetInteger(0,objectName,OBJPROP_TYPE) works faster.
ObjectFind is a synchronous command, i.e. it waits for a complete update (and availability) of the chart objects.
If you work with your own objects (ie created in your own stock), you should not use ObjectFind - you already know in which window object was created and that it most likely exists and it is the right type.
The worst that can happen is that the user deletes the object or changes the property
Yes, thanks, my assumption turned out to be wrong, but the question is a bit different. There is code,same for MT4 and MT5:
The question is that in MT4 the line created will be stationary at the price at which it was created, but in MT5 every time on a new tick the line will be drawn at a new value of LastAsk and its position will change along with the price. How can I avoid it in MT5?
I don't remember it, I need to check it but I don't want to. Maybe, in mql4 when trying to create an object named after already existing one, an error was just returned, while in mql5 it's not an error but parameter modification, if the coordinates are different.
As Artem said - check the existence of the object