Download MetaTrader 5
To add comments, please log in or register
Do you know C++? MQL5 has much in common with it. Just try it yourself!
fonx
52
fonx 2014.02.07 01:45 

Hi, there is something I don't understand about this parameter. Believe me that I've been searching for a while. The documentation says:

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

So if I use Shift=0 then is the current bar, isn't it? But that current bar is incomplete so for a EA that makes calculations on bar close (for instance EMAs crossover on bar close) I should always use Shift=1 once I detect that a new bar is created, isn't it?

So, if I'm right with the above stuff then EMA with Shift=0 is not reliable as we don't know what will be the final shape of the bar. Who would use Shift=0 ? What is the utility?

Many thanks in advance

qjol
3243
qjol 2014.02.07 01:52  

use your imagination

4 example, people who don't care 4 a close bar

fonx
52
fonx 2014.02.07 01:56  
qjol:

use your imagination

4 example, people who don't care 4 a close bar


But in my case, suppose I want to check the crossover on the close of the bar. I have to use Shift=1, right?

Ubzen
Moderator
5394
Ubzen 2014.02.07 02:08  
fonx:

Hi, there is something I don't understand about this parameter. Believe me that I've been searching for a while. The documentation says:

shift - Index of the value taken from the indicator buffer (shift relative to the current bar the given amount of periods ago).

So if I use Shift=0 then is the current bar, isn't it? But that current bar is incomplete so for a EA that makes calculations on bar close (for instance EMAs crossover on bar close) I should always use Shift=1 once I detect that a new bar is created, isn't it?

So, if I'm right with the above stuff then EMA with Shift=0 is not reliable as we don't know what will be the final shape of the bar. Who would use Shift=0 ? What is the utility?

Many thanks in advance

  • The way I understand it.
  • Shift=0 would base the ma_ calculations on the last_price.
  • The last price is namely the last Bid because mt4 data is Bid data.
  • People who would use that are people who care more for current price movements.
  • However this means that ma keep changing during the bar.
  • Also means that someone cannot look back and get the entire story.
  • An ma cross-over which happened during the bar may-not show up in history.
  • If someone understands the above and proceed anyway than that's fine.
  • Otherwise, using Shift=0 is un-reliable from what they expect.

Ubzen
Moderator
5394
Ubzen 2014.02.07 02:11  
fonx: But in my case, suppose I want to check the crossover on the close of the bar. I have to use Shift=1, right?
  • I generally use Open_Prices and Shift=0.
  • Because the Open Price doesn't change during the life of the Bar.
  • Its almost the same as using Close Price and Shift=1
  • They aren't exactly the same ... for example Weekend_Gaps.
  • Choose which ever applies best to your system and methods.

Ian Venner
2583
Ian Venner 2014.02.07 02:57  
fonx:

Who would use Shift=0 ? What is the utility?

Many thanks in advance


I would use it when I want to use values calculated by the indicator in real time on live prices.
fonx
52
fonx 2014.02.07 16:23  
Thanks for the answers guys, very appreciated. You've solved my question :)
/
To add comments, please log in or register