I know this is probably fairly simple but I cant figure it out.
Im trying to create a scan to identify when a fast MA is at least a certain percent below a slow MA
For example:
5SMA(daily) is 10% below 10SMA(daily)
There is a MovingAverageScan in ToS where you can compare the price to a MA, but Im trying to compare a MA to an MA.
I tried messing around with the first line below in the code for Moving Avg scan but I cant get it to work.
So, can anyone help?
Basically just want to scan for stocks whose 5SMA is 10% below the 10SMA as above on daily agg.
Would be used as a mean reversion type strategy
thanks in advanced for any help!
input price = close;
input length = 20;
input AverageType = averageType.SIMPLE;
input percentdiff = 10.0;
input choice = {default "Above","Below"};
def avg = movingAverage(averageType,price,length);
plot scan;
switch (Choice){
case "Above":
scan = price >= avg * (1 + percentdiff / 100 );
case "Below":
scan = price <= avg * (1 - percentdiff / 100 );
}
Im trying to create a scan to identify when a fast MA is at least a certain percent below a slow MA
For example:
5SMA(daily) is 10% below 10SMA(daily)
There is a MovingAverageScan in ToS where you can compare the price to a MA, but Im trying to compare a MA to an MA.
I tried messing around with the first line below in the code for Moving Avg scan but I cant get it to work.
So, can anyone help?
Basically just want to scan for stocks whose 5SMA is 10% below the 10SMA as above on daily agg.
Would be used as a mean reversion type strategy
thanks in advanced for any help!
input price = close;
input length = 20;
input AverageType = averageType.SIMPLE;
input percentdiff = 10.0;
input choice = {default "Above","Below"};
def avg = movingAverage(averageType,price,length);
plot scan;
switch (Choice){
case "Above":
scan = price >= avg * (1 + percentdiff / 100 );
case "Below":
scan = price <= avg * (1 - percentdiff / 100 );
}