Hi, Just wondered if anyone can assist me with the following criteria for a script for scans:-
50MA<20MA
20MA<7MA
Price< Highest High (Last 52weeks)
Price uptrending
Price uptrend change >10% (Last 14days)
I have attached the charts showing typically what I need. The current script I am using is including too many false +ves.
CLOSE(Day(PERIODAMOUNT=1), OFFSET=2) CROSSESABOVE MA(7)
You do not need to specify the daily time frame if you are using this on Day Charts and scanning on daily data ( which is the default).
I like to break up scans into separate items and put them in variables like “C1” which in my mind I call “Condition 1”
// 50MA<20MA
c1 = MA(Bars=50) < MA(Bars=20);
// 20MA<7MA
c2 = MA(Bars=20) < MA(Bars=7);
// Price< Highest High (Last 52weeks)
c3 = CLOSE() < HIGHESTHIGH(BACKTYPE=Weeks, BARS=52);
// Price uptrending
// I'm not sure how you define this. You could use ADX for trend strength, or a Gann Swing to define trend direction.
c4 = GANNSWING(SWINGCOUNT=2) IsUp;
//Price uptrend change >10% (Last 14days)
c5 = CHANGE(INT_COUNT=14, INT_TYPE=Day) > 10;
// now we combine them all with ANDS since we want all to be true
c1 AND c2 AND c3 AND c4 AND c5
What I like about using the variables is if there are any issues, I can go line by line and examine each item to be sure that it is right. eg If I wanted to check my Gann Swing rule, I can comment out the last line and just put c4 as the output like this
// 50MA<20MA
c1 = MA(Bars=50) < MA(Bars=20);
// 20MA<7MA
c2 = MA(Bars=20) < MA(Bars=7);
// Price< Highest High (Last 52weeks)
c3 = CLOSE() < HIGHESTHIGH(BACKTYPE=Weeks, BARS=52);
// Price uptrending
c4 = GANNSWING(SWINGCOUNT=2) IsUp;
//Price uptrend change >10% (Last 14days)
c5 = CHANGE(INT_COUNT=14, INT_TYPE=Day) > 10;
// now we combine them all with ANDS since we want all to be true
//c1 AND c2 AND c3 AND c4 AND c5
c4