How to shift any MAs

Posted By: SFF

How to shift any MAs - 12/20/12 06:33

Hi,

I don't find any idea to do it from the help.
Could you do it? How?

I mean that both +/- shift here.

Thanks in advance.
Posted By: jcl

Re: How to shift any MAs - 12/20/12 08:24

Well, I can certainly understand that people want a -/+ shift. If someone showed me how to do a negative shift of an MA, I could give up all work and would be obscenely rich.

A positive shift however is pretty simple, just add +n to the series. This is explained in Workshop 4.
Posted By: PriNova

Re: How to shift any MAs - 12/22/12 20:57

what @SFF mean is to shift the values forth or back. the same like in the ichimoku indicator or like it is possible with mt4.

so it is possible to shift the values in the desired direction. it doesn't have to do with value forecasting.
Posted By: jcl

Re: How to shift any MAs - 12/23/12 08:02

I understood what he meant.
Posted By: SFF

Re: How to shift any MAs - 12/24/12 11:19

Thanks, I will try.
Posted By: SFF

Re: How to shift any MAs - 02/03/13 00:00

Hi,

I made this script which I use shift but it doesn't work.

Code:
vars close_price = series(priceClose());
vars Buy1_1 = series(SMA(series(priceClose()),14));
vars Buy1_2 = series(SMA(series(priceClose()),28));

if(Buy1_1-1 < Buy1_2-1 && Buy1_1 > Buy1_2 )
enterLong();
if(Buy1_1-1 > Buy1_2-1 && Buy1_1 < Buy1_2)
enterShort();



As you know, I want to shift series -1 which is a normal shift strategy.

Could you correct this code?
Posted By: jcl

Re: How to shift any MAs - 02/04/13 09:27

Mankind's technology is still not ready to time travel. You can shift series into the past, but not into the future.

I could tell you a trick how to do it nevertheless, but there is no use of any shift in your code anyway. I guess you just want a crossover. You can find the crossOver function in the manual - there's also an example that just looks as your code should probably look.

http://manual.zorro-trader.com/crossover.htm
Posted By: SFF

Re: How to shift any MAs - 02/05/13 01:04

Thank you for your reply.
Yes, I know crossover compares [1] and [0] in series but it is not what I need.

What I mean is I want to use DMA.

Here it is for more info.
http://strategy4forex.com/forex-strategi...verage-dma.html
Posted By: jcl

Re: How to shift any MAs - 02/05/13 10:00

Ok, I see now what you want to do. That is just a delayed SMA.

You could shift the series into the past by adding +n, or even simpler, just calculate the SMA from a delayed price:

vars Buy1_1 = series(SMA(series(priceClose(n)),14));

n is the displacement.
Posted By: SFF

Re: How to shift any MAs - 02/05/13 10:05

Great, I will try. Thank you.
Posted By: SFF

Re: How to shift any MAs - 02/15/13 12:23

MT4 uses index [i - 1] for what I want.
Is it really same as (priceClose(1) in Zorro?
Posted By: jcl

Re: How to shift any MAs - 02/15/13 14:46

Yes.
© 2024 lite-C Forums