Select Page

# Thin out scan list where a stocks Technical Indicator does not score >=4

Optuma Forums Optuma Scripting Thin out scan list where a stocks Technical Indicator does not score >=4

This topic contains 6 replies, has 3 voices, and was last updated by  Mark 9 months, 4 weeks ago.

Viewing 7 posts - 1 through 7 (of 7 total)
• Author
Posts
• #47379

Mark
• Topics: 1
• Replies: 3
• Posts: 4

// ———-Creating a Technical Ranking System Scan – not using Watch Lists————

// Inspired by Darren Hawkins Blogs

// Scanning for a number of patterns and assigning points for each pattern
// This is a stripped down version of patterns and points – will add more can thin out the scan list based on the Technical Rank Value

//————Scanning for a MA12 touch————

// Set RG1 to 30% of the last day range
RG1 = ATR(Day(PERIODAMOUNT=1), BARS=1) * 30/100;
// Set MA1 and MA2 ranges to plus/minus RG1
MA1 = MA(BARS=12, STYLE=Exponential, CALC=HL Average) + RG1 ;
MA2 = MA(BARS=12, STYLE=Exponential, CALC=HL Average) – RG1;
// Check if the High or Low falls within these ranges
H1 = (HIGH() <= MA1 and HIGH() >= MA2);
L1 = (LOW() <= MA1 and LOW() >= MA2);
// Check if any of these conditions are true
Z1 = H1 or L1;
// Set this Technical Indicator to 2 points
V1 = 2;

//————Scan for a Gartley————

G1 = GPS(SCANTYPE=Both) Matches;
Z2 = G1;
// Set this Technical Indicator to 2 points
V2 = 2;

//————Scanning for Oliver’s Wedge————

W1 = SWINGSTART( OLIVERWEDGESCAN(INSIDESWING=Three) ) Matches;
Z3 = W1;
// Set this Technical Indicator to 2 points
V3 = 2;

//————Scanning for 3 Higher Lows————

// Check for 3 Higher Lows and the third one is noy yet confirmed -set of stairs possibility
GS1 = GANNSWING(METHOD=USE NEXT BAR);
3HL = SWINGDOWN(GS1) AND ((SWINGEND(GS1) > SWINGEND(GS1,OFFSET=2))
AND
((SWINGEND(GS1,OFFSET=2) > SWINGEND(GS1,OFFSET=4))
AND
(SWINGEND(GS1,OFFSET=1) > SWINGEND(GS1,OFFSET=3))))
AND
LOW() > (SWINGEND(GS1,OFFSET=2));
//Check both conditions are true
Z4 = 3HL;
// Set this Technical Indicator to 2 points
V4 = 2;

//————Scan for 3 Lower Tops————

// Check for 3 Lower Tops and the third one is not yet confirmed – set of stairs possibility
GS2 = GANNSWING(METHOD=USE NEXT BAR);
3LT = SWINGUP(GS2) AND ((SWINGEND(GS2) < SWINGEND(GS2,OFFSET=2))
AND
((SWINGEND(GS2,OFFSET=2) < SWINGEND(GS2,OFFSET=4))
AND
(SWINGEND(GS2,OFFSET=1) < SWINGEND(GS2,OFFSET=3))))
AND
SWINGEND(GS2,OFFSET=2) > HIGH();
//Check that both conditions are true
Z5 = 3LT;
// Set this Technical Indicator to 2 points
V5 = 2;

// Check that the stock has and ADX greater or equal to 20

//————Only choose stocks that fit the scan criteria————

(Z1 or Z2 or Z3 or Z4 or Z5) and DX;

TECH = V1+V2+V3+V4+V5;

//————Only select Stocks with a score of 4 or higher (This does not work)

TECH >= #Value:4;

#47383

Matthew
• Topics: 4
• Replies: 127
• Posts: 131

Hi Mark,

In your script the individual items are using a static value whether they are passing or not.  To setup a rank system you need to only have the values when the criteria passes using an IF() function.

Here is an example with your first criteria…

With this adjustment, the criteria will have a value of 2 when it passes and a value of 0 when it does not.

The scan should work.

#47391

Mark
• Topics: 1
• Replies: 3
• Posts: 4

#### Still find the thin out does not work

/ ———-Creating a Technical Ranking System Scan – not using Watch Lists————

// I have restricted this scan to 3 patterns – it works fine up to the code Z1 or Z2 or Z3 – looking for the patterns – these are correct for the ASX100

// As soon as add the score for each pattern to Variable TECH and then filter out the list end up with a much greater number of hits

// Scanning for a number of patterns and assigning points for each pattern
// This is a stripped down version of patterns and points – will add more when the scan works

//————Scanning for a MA12 touch————

// Set RG1 to 30% of the last day range
RG1 = ATR(Day(PERIODAMOUNT=1), BARS=1) * 30/100;
// Set MA1 and MA2 ranges to plus/minus RG1
MA1 = MA(BARS=12, STYLE=Exponential, CALC=HL Average) + RG1 ;
MA2 = MA(BARS=12, STYLE=Exponential, CALC=HL Average) – RG1;
// Check if the High or Low falls within these ranges
H1 = (HIGH() <= MA1 and HIGH() >= MA2);
L1 = (LOW() <= MA1 and LOW() >= MA2);
// Check that the stock has an ADX greater or equal to 20
// Check if any of these conditions are true
Z1 = ( H1 or L1 ) and DX1;
// Set this Technical Indicator to 2 points
V1 = IF(Z1 == 1,2,0) ;

//————Scan for a Gartley————

G1 = GPS(SCANTYPE=Both) Matches;
// Check that the stock has an ADX greater or equal to 20
// Check if any of these conditions are true
Z2 = G1 and DX2;
// Set this Technical Indicator to 2 points
V2 = IF(Z2 == 1,2,0) ;

//————Scanning for Oliver’s Wedge————

W1 = SWINGSTART( OLIVERWEDGESCAN(INSIDESWING=Three) ) Matches;
// Check that the stock has an ADX greater or equal to 20
// Check if any of these conditions are true
Z3 = W1;
// Set this Technical Indicator to 2 points
V3 = IF(Z3 == 1,2,0) ;

//————Only choose stocks that fit the scan criteria———— For today get 25 results which is correct

Z1 or Z2 or Z3;

//———-Add up the Technical Indicators – when uncomment the code below get 97 results and
//———- lots of stocks that no not fullfill the scan criteria

TECH = V1+V2+V3;

//————Only select Stocks with a score of 2 or higher (This does not work)

TECH >= 2;

#47395

Darren
• Topics: 34
• Replies: 194
• Posts: 228

Hi Mark,

Try commenting out the “Z1 or Z2 or Z3;” line as they are being included in the results.

Also IF statements take more processing, so to speed things up try changing the V1 = IF(Z1 == 1,2,0) lines to V1 = Z1*2 which will give the same result but quicker.

#47403

Mark
• Topics: 1
• Replies: 3
• Posts: 4

#### Still find the thin out does not work

Hi Darren

I tried your suggestion but the results are incorrect.

If I leave in the  “Z1 or Z2 or Z3;” line and comment out TECH = V1+V2+V3; and TECH >= 2; – this is just so that I know how many stocks in the ASX100 are selected for the scan – run this morning I get 25 – which is correct.

I then commented out the “Z1 or Z2 or Z3;” line, changed the IF statements as suggested, included the 2 lines of code for TECH and ran the scan again – this time I get 94 results of which so many stocks do not have any of the patterns.

I am totally confused.

Cheers, Mark

#47415

Matthew
• Topics: 4
• Replies: 127
• Posts: 131

Hi Mark,

I’ve attached a workbook which has a Watchlist containing 5 custom scripted columns.

• The first 3 are your individual criteria
• The 4th is the total rank score
• The 5th is the script you’d use in scanning, where a rank score of 2 or more shows a True result.

I’ve tested this script with a scan of the Top 100 (same list as the Watchlist) and can confirm the two match.

#47431

Mark
• Topics: 1
• Replies: 3
• Posts: 4

#### Many thanks

Hi Matthew

Many thanks for supplying the Workbook with the custom scripts.

I have done a cursory test and it is looking good. I will spend more time building up scripts for other patterns. The watch list with scripts for each pattern is a great way to test ones code.

Cheers,

Mark

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.