Gap Identifier tool

Hi,

I often thought if Optuma had a gap analyzer tool that it would be useful on a chart layout.

For example, open/unfilled gaps could be shown visually with a color-specific horizontal line or shaded region. Vice-versa, closed/filled gaps would have an option to display with separate color.

I was reminded of this by a tweet today I saw, see attached.

Additionally, if there were script functions, they would be useful in the signal tester. Example: what are results of a signal if there is an open gap below current price. Etc

OpenGapBelow (true/false)

OpenGapAbove (true/false)

 

Jeff

Hi Jeff,

I suspect those horizontal lines may have been drawn manually, although we can use the following to identify gaps:

Gap up: OPEN() > HIGH()[1] and LOW()>HIGH()[1]

Gap down: OPEN() < LOW()[1] and HIGH()<LOW()[1]

These will identify individual bars, as the per the Show Bar tools here:

Capture

However, we could then draw the price levels using a Show Plot to see if they were crossed. Here’s the levels for gap ups:

//Gap Up;
V1=OPEN() > HIGH()[1] and LOW()>HIGH()[1];
//Get value of high candle before the gap:
VALUEWHEN(HIGH()[1],V1)

Capture

Hi Jeff,

Leave this with us - it won’t make 1.6 but it is something we can look at for 1.7.

The key issue will be to only show unfilled gaps - or show the zone until it gets filled.

All the best

Mathew

Darren - thanks for these scripts on gaps!

Mathew - Yes, I agree its the unfilled gaps to identify. Thanks for considering this! : )

 

Jeff

 

 

Hi Mathew & Darren,

I’m trying to find a way to compare one stock to another based solely on past tendency for a stock to have gaps. I have been thinking of a method to be able to add a ‘gap risk’ component into a risk model but I don’t know if there is a way to script something like this. Here is what I have thought of:

A) A variable that adds up all gap space in percentages, up or down ( example: 15% )
B) A variable that adds up all non-gap space in percentages, up or down (example: 1000%)

Then with those data points:
Divide A into B = .015

Lets say this .015 is compared to a competitor’s stock that came up with .035 , then a conclusion could be the first stock has less ‘gap-risk’ and can a factor into a model… The comparisons probably would have to start at the same time, example - last 10 years of data, contingent that both stocks have at least that much history.

Is this possible in scripting? Or maybe there is a better way to think about this with a different method?

Jeff

Hi Jeff,

I think what you’re after is possible with a script. I’ve included some sample code below and have attached a workbook using the S&P100 constituents to try it on.

//Set Measure Points
V1 = OPEN() ;
V1a = HIGH() ;
V2 = HIGH(1) ;
V2a = LOW(1) ;
//Look for Gaps where Open and Low of current bar is higher than previous bars high
V3 = V1 > V2 and LOW() > V2;
//Look for Gaps where the Open and High of current bar is lower than previous low
V3a = V1 < V2a and V1a < V2a ;
//Find the percentage difference between the Open and Previous High
V4 = 100 * abs(V2 - V1)/V1 ;
//Find the percentage difference between the Open and the Previous Low
V4a = 100 * abs(V2a- V1)/V1 ;
//Find Percent Value for Gap Up and Down
V5 = IF(V3 == 1,V4,0);
V5a = IF(V3a == 1,V4a,0);
//Find Percent Value for non Gap
V6a = V3a == 0 and V3a == 0;
V6 = IF(V6a == 1,V4,0);
//Accumulate All Values
V7 = ACC(V5);
V7a = ACC(V5a) ;
V8 = ACC(V6);
//Add Gap Up and Gap Down Values together and divide by non gap value to build ratio
(V7a + V7a)  / V8

Not sure if it’s 100% what you were wanting to do but should point you in the right direction in building your own script.

JeffExample-2.owb (60.9 KB)

Hi Matthew,

This is perfect! I think it was setup to evaluate down-side gaps, but I believe I was able to adjust to capture both.

Thanks so much so sharing this.

Jeff

[postquote quote=58125]

Hi Matthew

HNY to you and the team !

I was doing some work on gaps today and was going to post up a question as described by Jeff above ie. is it possible to display a visual horizontal shaded ‘gap’ where a script identifies a gap up/down.

I draw them manually at present and can’t shade between the lines, would be a neat visual feature for gaps to display horizontally and shaded if achievable and not too difficult.

Just thought I’d add my voice to Jeff’s request.

Best wishes
Andrew

Gaps.owb (20.5 KB)

Hi Jeff,

Just to let you know that the Gap Finder tool has been added to Optuma 2 - you’ll be able to sign up to be a beta tester soon!

https://help.optuma.com/kb/faq.php?id=1253

I’m so happy this made it! You guys are the best.