Alignment of MA for the first time

Hii I am using below formula for MA aligning for the first time but its not working. Any ideas?


v1=MA(STYLE=Exponential, BARS=21, CALC=Close) > MA(BARS=50, STYLE=Exponential, CALC=Close) > MA(BARS=100, CALC=Close, STYLE=Exponential) > MA(BARS=150, STYLE=Exponential, CALC=Close) > MA(BARS=200, STYLE=Exponential, CALC=Close); v1 ChangeTo 1

            

Hi Deepak,

What do you mean by aligning? Can you please provide more information?

Also please try to format the scripts so they are a little easier for us all to read.

All the best

Mathew

Hiii Sir,

I wanted to know when the MA make the following condition true for the first time.

MA 21 > MA 50
MA 50 > MA 100
MA 100 > MA 150
MA 150 > MA 200

For this i have used following code.

v1=MA(STYLE=Exponential, BARS=21, CALC=Close) > MA(BARS=50, STYLE=Exponential, CALC=Close) > 
MA(BARS=100, CALC=Close, STYLE=Exponential) > MA(BARS=150, STYLE=Exponential, CALC=Close) > 
MA(BARS=200, STYLE=Exponential, CALC=Close); v1 ChangeTo 1

Regards,
Deepak


            

Hi,

You’re looking for several criteria to be true at once, so you need to have them connected via AND operators.

Example:

V1 = MA(BARS=21, STYLE=Exponential, CALC=Close) ;
V2 = MA(BARS=50, STYLE=Exponential, CALC=Close) ;
V3 = MA(BARS=100, STYLE=Exponential, CALC=Close) ;
V4 = MA(BARS=150, STYLE=Exponential, CALC=Close) ;
V5 = MA(BARS=200, STYLE=Exponential, CALC=Close) ;
V6 = V1  > V2 and V2 > V3 and V3 > V4 and V4 > V5;
BARSTRUE(V6) == 1

You can then use the BARSTRUE() function to find the first bar where this criteria swaps from False to True.

On a chart it looks like this (Show View along the bottom).

Ex5

After triggering, it won’t trigger again until the criteria goes back to False, then is met once more.

Hii Sir,

I used the suggested formula however the results are different.

MA alignment

Cant i use change to function.

Regards,
Deepak

Hi,

If you prefer to use ChangeTo you can. It’s a simple adjustment to the final line.

V1 = MA(BARS=21, STYLE=Exponential, CALC=Close) ;
V2 = MA(BARS=50, STYLE=Exponential, CALC=Close) ;
V3 = MA(BARS=100, STYLE=Exponential, CALC=Close) ;
V4 = MA(BARS=150, STYLE=Exponential, CALC=Close) ;
V5 = MA(BARS=200, STYLE=Exponential, CALC=Close) ;
V6 = V1 > V2 and V2 > V3 and V3 > V4 and V4 > V5;
V6 ChangeTo 1