Need Scan to find close between 50/21 moving averages

P

philsy13

New member
I'd like to find a code that will allow me to scan for price trending between two moving averages. EMA 50 and 21. Essentially, it would find stocks within two moving averages prior to a significant move in either direction. Any help would be most appreciated!
 
A

amcno03

New member
Hi @philsy13 here is the link with the scanner you've asked for: https://tos.mx/xcWRsK9



and also an indicator to show the candles that meet the criteria: https://tos.mx/I77rEEE

And the code. Bear in mind that it shows candles closing above EMA21 and below EMA50. IF you want it to show candles closing above EMA50 and below EMA21, just change the "def con1" for this line: def cond1= close is greater than AvgExp50 and close is less than avgexp21;
Code:
input price = close;
input length = 21;


plot AvgExp21 = ExpAverage(price, length);

input price1 = close;
input length1 = 50;


plot AvgExp50 = ExpAverage(price1, length1);

def cond1=  close is greater than AvgExp21 and close is less than avgexp50;
plot signal = cond1;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_aRROW_UP);
signal.SetDefaultColor(Color.White);
signal.SetLineWeight(5);

signal.DefineColor("signal", Color.darK_ORANGE);

AssignPriceColor(if signal == 1 then signal.color("Signal") else Color.CURRENT);


Hope It helps,
Best regards.
ps: English is not my mother tongue; please excuse any errors on my part.
 
Last edited:
P

philsy13

New member
Hi @philsy13 here is the link with the scanner you've asked for: https://tos.mx/xcWRsK9



and also an indicator to show the candles that meet the criteria: https://tos.mx/I77rEEE

And the code. Bear in mind that it shows candles closing above EMA21 and below EMA50. IF you want it to show candles closing above EMA50 and below EMA21, just change the "def con1" for this line: def cond1= close is greater than AvgExp50 and close is less than avgexp21;


Code:
input price = close;
input length = 21;


plot AvgExp21 = ExpAverage(price, length);

input price1 = close;
input length1 = 50;


plot AvgExp50 = ExpAverage(price1, length1);

def cond1=  close is greater than AvgExp21 and close is less than avgexp50;
plot signal = cond1;
signal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_aRROW_UP);
signal.SetDefaultColor(Color.White);
signal.SetLineWeight(5);

signal.DefineColor("signal", Color.darK_ORANGE);

AssignPriceColor(if signal == 1 then signal.color("Signal") else Color.CURRENT);


Hope It helps,
Best regards.
ps: English is not my mother tongue; please excuse any errors on my part.
You did a great job! Thank you! I'm adapting it to my trading style.
 

Similar threads

Top