To Scan stocks when the plot line changes Green to Red

Nick

Active member
2019 Donor
VIP
Hi, this ATR_Mod was provided by one of our members and what I want is to customize a SCAN when the PLOT Line changes from GREEN to RED. I tried to build when ATRM crosses zero within 1 bar but the results generated is not accurate.

Request if anyone can help me with this.
Thanks

Code:
###  ATR Mod   ###
declare lower;
input length = 20;
input length2 = 5;
input averageType = AverageType.WILDERS;
def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);
def ATRA = MovingAverage(averageType, atr, length2);
plot zeroline=0;
plot ATRM = ((ATR- ATRA) /close)*100;
ATRM.SetPaintingStrategy(PaintingStrategy.LiNE);
ATRM.AssignValueColor(if ATRM >= 0 then Color.downtick else Color.uptick);

gUn85D4.jpg
 

BenTen

Administrative
Staff
VIP
Take a look at the last line:

Code:
ATRM.AssignValueColor(if ATRM >= 0 then Color.downtick else Color.uptick);

If ATRM (the ATR line) is higher than or equal to 0, then it will turn red else, it will stay green. Follow that condition to set up your scanner.
 

Nick

Active member
2019 Donor
VIP
@BenTen Thanks for the prompt reply. I think I found the error why i am not getting the right scan results. I have used the condition to find the ATRM "is greater or equal to" 0 but instead I should have used "crosses above" 0 to find the ATRM crosses above 0 within 1 Bar to get the right scan. Just to confirm if that is right. Thank you

rkAVSo2.jpeg
 

Similar threads

Top