Optuma Forums › Optuma Scripting › Script Assistance
- This topic has 2 replies, 3 voices, and was last updated 1 week, 2 days ago by
Matthew.
-
AuthorPosts
-
January 11, 2021 at 9:54 am #61977
Marie
- Topics: 2
- Replies: 0
- Posts: 2
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)Many thanks and appreciate any assistance.
Attachments:
You must be logged in to access attached files.
January 12, 2021 at 12:04 pm #61989Mathew
- Topics: 32
- Replies: 1,650
- Posts: 1,682
Hi Marie,
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”
1234567891011121314151617181920// 50MA<20MAc1 = MA(Bars=50) < MA(Bars=20);// 20MA<7MAc2 = 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 truec1 AND c2 AND c3 AND c4 AND c5What 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
1234567891011121314151617181920// 50MA<20MAc1 = MA(Bars=50) < MA(Bars=20);// 20MA<7MAc2 = MA(Bars=20) < MA(Bars=7);// Price< Highest High (Last 52weeks)c3 = CLOSE() < HIGHESTHIGH(BACKTYPE=Weeks, BARS=52);// Price uptrendingc4 = 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 c5c4Hope that helps point you in the right direction
Mathew
1 user thanked author for this post.
January 12, 2021 at 12:44 pm #61991Matthew
- Topics: 4
- Replies: 12
- Posts: 16
That’s a great example of best-practice scripting. Thanks Matthew.
-
AuthorPosts
- You must be logged in to reply to this topic.