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
Yeah, well, that's actually strange behaviour for a standard function. After all, we are dealing exactly with fitting values to its "benchmark".
The standard function iBarShift of MQL4, when the requested time falls into a hole, returns the left bar number (i.e. Saturday in this case), and iBarShift3 returns the right bar number from the hole (i.e. Monday), which makes more sense.
If we are in the hole, it is logical to return the left bar, the last known value, but not the future.
If we are in a hole, it is logical to return the left bar, the last known value, but not the future.
PS: Is it needed to post English version or Russian translation is correct ?
Yes, the translation is correct.
Run this script and you will see that the functions produce exactly the same result.
Can you give an example of a timeframe and the time at which the values of these functions are different?
By the way, your function is often mistaken. Returns the value -1
The requirement is to have ONLY as a version of mql4
Your function is not working correctly with the exact=true parameter.
This can be seen in this script.
And here is a full working analogue of iBarShift function with exact parameter:
Without this parameter it can be simplified to this form:
Yes, the translation is correct.
Run this script and you will see that the functions produce exactly the same result.
Can you give an example of a timeframe and the time at which the values of these functions are different?
By the way, your function is often mistaken. Returns the value -1
Please be serious. My code is for mql5.
It returns -1 because Bars() function is unreliable under MT4.
Script running on AUDUSD, M5 chart.
This is not happening with MT5.
Please be serious. My code is for mql5.
It returns -1 because Bars() function is unreliable under MT4.
Script running on AUDUSD, M5 chart.
This is not happening with MT5.
You said it should work like in MQL4.
But this script can be run on MQL5 too
If exact=True and future time you have to return -1.
My script has also found a strange error:
This error is confirmed by this check:
So I was right about theexistence of irregularities in your algorithm after all.From all the analysis I've done, we can conclude that this full analogue of the iBarShift:
is by far the most correct, and at the same time the fastest and with the simplest and shortest algorithm.
If you don't need the exact parameter, you can use the simplified version:
or just use this equivalent version without calling the function:
Or am I wrong?Silence is a sign of agreement.
Through CTRL+SHIFT+F in ME did a search for "BarShift". Turns out I don't use a similar function. Apparently didn't need it myself.
Once wrote a variant to convert MT4 EAs to MT5 in one line. Seems to be the only reason for writing it.
I don't work with bars and don't understand why everyone else doesn't do the same.
Didn't get into your code. But always glad when you get a quick solution.
Through CTRL+SHIFT+F in ME did a search for "BarShift". Turns out I don't use a similar function. Apparently didn't need it myself.
Once wrote a variant to convert MT4 EAs to MT5 in one line. Seems to be the only reason for writing it.
I don't work with bars and don't understand why everyone else doesn't do the same.
Didn't get into your code. But always glad when you get a quick solution.
I understand what you mean, but working with bars is still urgent for me. Maybe one day it will become a rudiment for me too.