I have worked all day today to try to build upon the scans posted earlier to create one that will identify stocks whose 8 EMA is rising and is within 2% of crossing its 21 EMA from below, and vice versa. I took some code from before and came up with this:
def a = ExpAverage(close, 8);
def b = ExpAverage(close, 21);
def d = a - b;
plot p = (d / b) * 100;
input center_line = 0;
plot CenterLine = center_line;
input upper_line = .2;
plot UpperLine = upper_line;
input lower_line = -.2;
plot LowerLine = lower_line;
That generates this study, with arrows pointing at the points in the price action where I would like my scan to I.D. the stocks having that characteristic (in two separate scans, one going up and v.v.).
My intent is to get a jump on the time when the 8 EMA is about to cross the 21 EMA from either direction, depending on the scan I'm using. I just can't figure out after struggling for about six hours how to code it. Another way to describe it is I would like the scan to pick up on what stocks have the blue line crossing the yellow -2% line from below or the blue line crossing the white +2% line from above. The red line is where the 8 and the 21 cross. I put the study into a scan and got this, but I'm not sure if it is working how I want.
def a = ExpAverage(close, 8);
def b = ExpAverage(close, 21);
def d = a - b;
plot p = (d / b) * 100;
input center_line = 0;
plot CenterLine = center_line;
input upper_line = .2;
plot UpperLine = upper_line;
input lower_line = -.2;
plot LowerLine = lower_line;
That generates this study, with arrows pointing at the points in the price action where I would like my scan to I.D. the stocks having that characteristic (in two separate scans, one going up and v.v.).
My intent is to get a jump on the time when the 8 EMA is about to cross the 21 EMA from either direction, depending on the scan I'm using. I just can't figure out after struggling for about six hours how to code it. Another way to describe it is I would like the scan to pick up on what stocks have the blue line crossing the yellow -2% line from below or the blue line crossing the white +2% line from above. The red line is where the 8 and the 21 cross. I put the study into a scan and got this, but I'm not sure if it is working how I want.