# Price Volume Anomoly by Anna Coulling for ThinkorSwim

#### Afghan1

##### New member
Has anyone ever tried creating the script by infamous Anna coulling?

Simply put it utilizes capitulations and only spits out hidden buyers and sellers. few diff variables but when price action is tanking and big volume bar comes in to stop it (hidden buyer etc).

Have been hunting for this code for ages, it does exist have seen few guys at hedge fund use it. would love to know if anyone else has it. the overall objective of script would be to find hidden seller, it just reduces some eye strain from looking at tape.

http://prntscr.com/pm17vu

Last edited by a moderator:
• Pahi

#### guga

##### New member
Try the one below. Adapt as you see fit.

Code:
``````input OpenTime = 0945;
input CloseTime = 1555;

def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;

def anomaly1 = if active then (close >= close ) and (close>close)and (close>close)and (close>close)and volume > (volume*1.33) else Double.NaN;

def anomaly2 =if active then (close <= close ) and (close<close)and (close<close)and (close>close) and volume > (volume*1.33) else Double.NaN;

plot H = if anomaly1 > 0 then high else Double.NaN;

plot L = if anomaly2 > 0 then low else Double.NaN;

H.SetStyle(Curve.POINTS);
H.SetDefaultColor(Color.red);

L.SetStyle(Curve.POINTS);
L.SetDefaultColor(Color.white);``````

#### tomsk

##### Well-known member
VIP
@guga while I have not seen any prior studies regarding Anna Couling, I have optimized the logic based on your script using a bunch of boolean constructs. Hope this is helpful

Code:
``````input OpenTime = 0945;
input CloseTime = 1555;

def active = SecondsFromTime(OpenTime) >= 0 and SecondsTillTime(CloseTime) > 0;
def anomaly1 = active and sum(close > close, 5) >= 5 and volume > (volume * 1.33);
def anomaly2 = active and sum(close < close, 5) >= 5 and volume > (volume * 1.33);

plot H = if anomaly1 then high else Double.NaN;
plot L = if anomaly2 then low else Double.NaN;

H.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
H.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
H.SetDefaultColor(Color.CYAN);
L.SetDefaultColor(Color.YELLOW);
H.SetLineWeight(3);
L.SetLineWeight(3);``````

#### zeek

##### Active member
2019 Donor
Doing some testing today using this indicator on the 5min timeframe and i can definitely see usefulness in this indicator to find hidden buyers/sellers. Very good stuff Thanks @guga for the code.

Btw, is it possible to add audio alerts as well for the signals?

Last edited:

#### tomsk

##### Well-known member
VIP

input OpenTime = 0945;
input CloseTime = 1555;

def active = SecondsFromTime(OpenTime) >= 0 and SecondsTillTime(CloseTime) > 0;
def anomaly1 = active and sum(close > close, 5) >= 5 and volume > (volume * 1.33);
def anomaly2 = active and sum(close < close, 5) >= 5 and volume > (volume * 1.33);

plot H = if anomaly1 then high else Double.NaN;
plot L = if anomaly2 then low else Double.NaN;

H.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
H.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
H.SetDefaultColor(Color.CYAN);
L.SetDefaultColor(Color.YELLOW);
H.SetLineWeight(3);
L.SetLineWeight(3);

• Pahi, jay2, markos and 2 others

#### guga

##### New member
I have updated the code to fine tune it to pick anomalies on 5-min charts. So far it works very well in pick reversals spots. Let me know what you guys find out.
Also, I'm told that TOS scanning is delays by around 3-min, is this true? if yes, does anyone know if it's possible to improve it? Thanks

Code:
``````input OpenTime = 0945;
input CloseTime = 1555;

def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;

def anomaly1 = if active then (close < hl2) and (close > open) and volume > (volume*1.5) else Double.NaN;

def anomaly2 =if active then (close > hl2)and (close < open)and volume > (volume*1.5) else Double.NaN;

plot H = if anomaly1 > 0 then high else Double.NaN;

plot L = if anomaly2 > 0 then low else Double.NaN;

H.SetStyle(Curve.POINTS);
H.SetDefaultColor(Color.red);

L.SetStyle(Curve.POINTS);
L.SetDefaultColor(Color.white);

• Pahi and zeek

#### BenTen

Staff member
Staff
VIP
@guga If you save the scanner as a watchlist then there is 3-5 mins delay.

#### guga

##### New member
Thanks Ben. is there a way to have it real-time or reduced delay?

#### BenTen

Staff member
Staff
VIP
@guga Not that I know of. You would have to click the Scan button whenever you want real-time result.

#### tomsk

##### Well-known member
VIP
I have updated the code to fine tune it to pick anomalies on 5-min charts. So far it works very well in pick reversals spots. Let me know what you guys find out.
Also, I'm told that TOS scanning is delays by around 3-min, is this true? if yes, does anyone know if it's possible to improve it? Thanks

Code:
``````input OpenTime = 0945;
input CloseTime = 1555;

def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;

def anomaly1 = if active then (close < hl2) and (close > open) and volume > (volume*1.5) else Double.NaN;

def anomaly2 =if active then (close > hl2)and (close < open)and volume > (volume*1.5) else Double.NaN;

plot H = if anomaly1 > 0 then high else Double.NaN;

plot L = if anomaly2 > 0 then low else Double.NaN;

H.SetStyle(Curve.POINTS);
H.SetDefaultColor(Color.red);

L.SetStyle(Curve.POINTS);
L.SetDefaultColor(Color.white);

@guga Just a minor point in your revised code, the variable "active" is intended to flag a bracketed time period.
It is a boolean expression which evaluates to true or false. Hence you don't need to increment the variable.

Code:
``````def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;``````

Just use the definition of "active" I gave you earlier.

• BenTen

#### guga

##### New member
@guga Just a minor point in your revised code, the variable "active" is intended to flag a bracketed time period.
It is a boolean expression which evaluates to true or false. Hence you don't need to increment the variable.

Code:
``````def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;``````

Just use the definition of "active" I gave you earlier.
Hi Tom - sorry, but i didn't quite get what you meant by using the 'active' definition...

#### tomsk

##### Well-known member
VIP
You want your condition to trigger only between the hours from 0945 - 1555
The way to do this is via the variable "active" which should evaluate to either true or false
True = 1, false = 0
Hence no need to increment the value of "active" like in your case.

#### DeusMecanicus

##### Active member

input OpenTime = 0945;
input CloseTime = 1555;

def active = SecondsFromTime(OpenTime) >= 0 and SecondsTillTime(CloseTime) > 0;
def anomaly1 = active and sum(close > close, 5) >= 5 and volume > (volume * 1.33);
def anomaly2 = active and sum(close < close, 5) >= 5 and volume > (volume * 1.33);

plot H = if anomaly1 then high else Double.NaN;
plot L = if anomaly2 then low else Double.NaN;

H.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
H.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
H.SetDefaultColor(Color.CYAN);
L.SetDefaultColor(Color.YELLOW);
H.SetLineWeight(3);
L.SetLineWeight(3);

H.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

Shoudn't this one be
L.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

#### zeek

##### Active member
2019 Donor
Now i am confused, is the updated code from @guga in post #9 the correct one or should i continue to use the older one?

#### tomsk

##### Well-known member
VIP
Now i am confused, is the updated code from @guga in post #9 the correct one or should i continue to use the older one?

@zeek it all really depends on what you're looking for. Here is the section of code I modified

def active = SecondsFromTime(OpenTime) >= 0 and SecondsTillTime(CloseTime) > 0;
def anomaly1 = active and sum(close > close, 5) >= 5 and volume > (volume * 1.33);
def anomaly2 = active and sum(close < close, 5) >= 5 and volume > (volume * 1.33);

Anomaly1 essentially is looking for a 33% increase in volume with 5 preceding bullish closes while anomaly2 just addresses the similar condition for the bearish case. At the end of the day it depends on what you're looking for. It's all math and logic.

#### tabs999

##### Member
what does this script actually show?

#### tomsk

##### Well-known member
VIP
Basically this either looks for either of the following conditions

5 consecutive GREEN candles and volume of the current bar exceeds the previous volume by 33%
5 consecutive RED candles and volume of the current bar exceeds the previous volume by 33%

#### Afghan1

##### New member
good job @guga & @tomsk How do i set it up, so its good for 3 mins?

Code:
``````input OpenTime = 0945;
input CloseTime = 1555;

def active = if SecondsFromTime(OpenTime) >= 0 and
SecondsTillTime(CloseTime) > 0
then active + 1
else 0;

def anomaly1 = if active then (close < hl2) and (close > open) and volume > (volume*1.5) else Double.NaN;

def anomaly2 =if active then (close > hl2)and (close < open)and volume > (volume*1.5) else Double.NaN;

plot H = if anomaly1 > 0 then high else Double.NaN;

plot L = if anomaly2 > 0 then low else Double.NaN;

H.SetStyle(Curve.POINTS);
H.SetDefaultColor(Color.red);

L.SetStyle(Curve.POINTS);
L.SetDefaultColor(Color.white);

#### wtf_dude

##### Active member
@Afghan1 Should just bring up the 3 minute chart. The market times don't change no matter what intraday time frame you use.

• Afghan1

#### Afghan1

##### New member
input OpenTime = 0945; input CloseTime = 1555; def active = if SecondsFromTime(OpenTime) >= 0 and SecondsTillTime(CloseTime) > 0 then active + 1 else 0; def anomaly1 = if active then (close < hl2) and (close > open) and volume > (volume*1.5) else Double.NaN; def anomaly2 =if active then (close > hl2)and (close < open)and volume > (volume*1.5) else Double.NaN; plot H = if anomaly1 > 0 then high else Double.NaN; plot L = if anomaly2 > 0 then low else Double.NaN; H.SetStyle(Curve.POINTS); H.SetDefaultColor(Color.red); L.SetStyle(Curve.POINTS); L.SetDefaultColor(Color.white); # Alerts Alert(anomaly1, "Price Volume Anomaly - High", Alert.BAR, Sound.RING); Alert(anomaly2, "Price Volume Anomaly - Low", Alert.BAR, Sound.DING);
beautifully done, is there a way to reduce the number of false positive? would be cool to let users pick through input.

i edited the the 1.5 to 1.8 in both situations. any other thing that could be changed?