Last one or two bar 8MA over 21MA


Category:
0
0

First of all i wanted to thank for your hard work for this community.
I am getting list of all the stocks which is already crossed 8MA over 21MA irrespective of number of previous bar.
Now I need your help on how to get list per below criteria.

  1. Last one or two bar crossed 8MA over 21MA

 

I am using below script,which is working perfectly fine except one above criteria.

input lengthOne = 8;
input lengthTwo = 21;
input maTypeOne = AverageType.EXPONENTIAL;
input maTypeTwo = AverageType.EXPONENTIAL;
input priceOne = close;
input priceTwo = close;
def maOne = MovingAverage(maTypeOne, priceOne, lengthOne);
def maTwo = MovingAverage(maTypeTwo, priceTwo, lengthTwo);
plot data = maOne > maTwo;

 

Thanks in advance for your help.

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on April 14, 2020 8:28 am
166 views
0
Private answer

Have you seen the easy way to build scans?

https://www.hahn-tech.com/thinkorswim-condition-wizard/

No need to write any code at all. Just a few clicks of the mouse. Screenshot below shows how to build this. Be sure to watch the full video so you can learn all the advanced techniques.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4087)
Answered on April 14, 2020 2:02 pm