Anna Coulling Volume Price Analysis For ThinkOrSwim

Cwparker23

Member
W54Z4tN.png


I created this indicator after reading Anna Coulling book on volume price analysis. https://www.amazon.com/Complete-Gui...t=&hvlocphy=9051671&hvtargid=pla-432422856366

The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish ad magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

Here is the link to the indicator: https://tos.mx/uSOXiHe Click here for --> Easiest way to load shared links
Ruby:
# Anna Coulling Volume Price Analysis For ThinkOrSwim
# Original script by Cwparker23
AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = expAverage(volume);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
plot IR_BODY = if BODY_RANGE < BODY_RANGE[1] and volume > volume[1] then 1 else 0 ;
def IR_BODYG  = if IR_BODY and close>open then 1 else 0;
def IR_BODYR  = if IR_BODY and close<open then 1 else 0;

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );


Vol.AssignValueColor(
if close > open and IR_BODYG and Vol >VolAvg  then Vol.color("Up3") else if

close > open and IR_BODYG  then Vol.color("Up4")

else if close < open and IR_BODYR and Vol >VolAvg then Vol.color("Down3")

else if close < open and IR_BODYR then Vol.color("Down4")

else if close > open and Vol >VolAvg  then Vol.color("Up")

else if close < open and Vol >VolAvg then Vol.color("Down")

else if close > open then Vol.color("Up2")

else if close < open then Vol.color("Down2")

else GetColor(1));



input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);

DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );
AssignPriceColor(if !paintBars then Color.CURRENT

else if close > open and IR_BODYG and Vol >VolAvg then GlobalColor("CAM_UP3")
else if close < open and IR_BODYR and Vol >VolAvg then GlobalColor("CAM_DN3")

else if close > open and IR_BODYG then GlobalColor("CAM_UP4")
else if close < open and IR_BODYR then GlobalColor("CAM_DN4")

else if close > open and Vol >VolAvg then GlobalColor("CAM_UP")
else if close < open and Vol >VolAvg then GlobalColor("CAM_DN")

else if close > open then GlobalColor("CAM_UP2")
else if close < open then GlobalColor("CAM_DN2")

else Color.CURRENT);
 
Last edited by a moderator:
It's certainly a recommended read, even if she has a really long winded way of getting to the point, but I consider it one of the better TA books written. This is a great indicator.

Run this on the 5m and a cyan candle is usually preceded by a nice run, assuming you can filter out choppy periods. A combo of ADX and MTF can help with this.

I'm struggling to find a chart today where cyan candles failed (other than choppy periods).

Nice work
 
Awesome study. I also noticed that cyan candles are followed by a nice reversal. Is it possible to only have those candles colored?
 
Neat indicator!
I added signals based off the cyan and magenta bars represented by green/red vertical lines and an adjustable multiplier to specify how much above the average they must be before triggering a signal. You can also choose to allow/disallow opposing volume. In back testing the default settings here seemed to work best.

Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames.

And I reworked the code a little bit to reduce redundancy and make it easier to modify in the future.
Thanks @Cwparker23 !

Update: My latest version of this indicator can be found at:
https://usethinkscript.com/threads/...rice-analysis-for-thinkorswim.8882/post-86921

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#
# v2.1

#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = expAverage(volume);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else GetColor(1));


input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if up3 and vol >= (volAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and (vol >= (volAvg * multiplier)) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else double.nan;
def bear =
    if down3 and vol >= (volAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and (vol >= (volAvg * multiplier)) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else double.nan;

addVerticalLine(bull[1],"bull",color.green,curve.short_dash);
addverticalLine(bear[1],"bear",color.red,curve.short_dash);

# end of script


And here is a quick strategy if you'd like to back test it

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Strategy for back testing
# v2.1


#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.WHITE);

#declare lower;
#declare zerobase;

def Vol = volume;
def VolAvg = expAverage(volume);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.LIGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.CYAN);
DefineGlobalColor("CAM_UP4", Color.BLUE);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.DARK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.MAGENTA );
DefineGlobalColor("CAM_DN4", Color.PLUM );

AssignPriceColor(if !paintBars then Color.CURRENT
else if up3 then GlobalColor("CAM_UP3")
else if down3 then GlobalColor("CAM_DN3")
else if up4 then GlobalColor("CAM_UP4")
else if down4 then GlobalColor("CAM_DN4")
else if up then GlobalColor("CAM_UP")
else if down then GlobalColor("CAM_DN")
else if up2 then GlobalColor("CAM_UP2")
else if down2 then GlobalColor("CAM_DN2")
else Color.CURRENT);


def bull =
    if up3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else Double.NaN;
def bear =
    if down3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else Double.NaN;

AddVerticalLine(bull[1], "bull", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(bear[1], "bear", Color.RED, Curve.SHORT_DASH);



# strategy
def uptrigger = if bull then close else double.nan;
def dnTrigger = if bear then close else double.nan;
input positionSize = 100;
input stopBars = 1; #2
input useMaTarget = yes;
input targetMaLength = 14;
def tradePrice = close;
def stopTarget = movingAverage(averageType.exponential,close,targetMaLength);
def longStopLoss = low[stopBars]; # [2]
def shortStopLoss = high[stopBars]; # [2]
# Longs
def longSell = if useMaTarget and close crosses below stopTarget then tradePrice else Double.NaN;
def LongStop = if close crosses below longStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.BUY_TO_OPEN, upTrigger, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna Buy");
AddOrder(OrderType.SELL_TO_CLOSE, longSell, tradePrice, positionSize, Color.pink, Color.pink, "Anna Sell");
AddOrder(OrderType.SELL_TO_CLOSE, LongStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna long stoploss");

# Shorts
def shortBuy = if useMaTarget and close crosses above stopTarget then tradePrice else Double.NaN;
def shortStop = if close crosses above shortStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.SELL_TO_OPEN, dnTrigger, tradePrice, positionSize, Color.pink, Color.pink, "Anna short");
AddOrder(OrderType.BUY_TO_CLOSE, shortBuy, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna cover");
AddOrder(OrderType.BUY_TO_CLOSE, shortStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna short stoploss");

# end of script
 
Last edited by a moderator:
Trying to debug an anomaly in this script where a cyan bar(up3) is being printed even though its not exceeding the volAvg.
Code:
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;

RHozQAF.jpg


Any ideas?
 
Last edited:
Neat indicator!
I added signals based off the cyan and magenta bars represented by green/red vertical lines and an adjustable multiplier to specify how much above the average they must be before triggering a signal. You can also choose to allow/disallow opposing volume. In back testing the default settings here seemed to work best.

Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames.

And I reworked the code a little bit to reduce redundancy and make it easier to modify in the future.
Thanks @Cwparker23 !

anna.png


Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#
# v2.1

#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = expAverage(volume);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else GetColor(1));


input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if up3 and vol >= (volAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and (vol >= (volAvg * multiplier)) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else double.nan;
def bear =
    if down3 and vol >= (volAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and (vol >= (volAvg * multiplier)) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else double.nan;

addVerticalLine(bull[1],"bull",color.green,curve.short_dash);
addverticalLine(bear[1],"bear",color.red,curve.short_dash);

# end of script


And here is a quick strategy if you'd like to back test it

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Strategy for back testing
# v2.1


#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.WHITE);

#declare lower;
#declare zerobase;

def Vol = volume;
def VolAvg = expAverage(volume);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.LIGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.CYAN);
DefineGlobalColor("CAM_UP4", Color.BLUE);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.DARK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.MAGENTA );
DefineGlobalColor("CAM_DN4", Color.PLUM );

AssignPriceColor(if !paintBars then Color.CURRENT
else if up3 then GlobalColor("CAM_UP3")
else if down3 then GlobalColor("CAM_DN3")
else if up4 then GlobalColor("CAM_UP4")
else if down4 then GlobalColor("CAM_DN4")
else if up then GlobalColor("CAM_UP")
else if down then GlobalColor("CAM_DN")
else if up2 then GlobalColor("CAM_UP2")
else if down2 then GlobalColor("CAM_DN2")
else Color.CURRENT);


def bull =
    if up3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else Double.NaN;
def bear =
    if down3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else Double.NaN;

AddVerticalLine(bull[1], "bull", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(bear[1], "bear", Color.RED, Curve.SHORT_DASH);



# strategy
def uptrigger = if bull then close else double.nan;
def dnTrigger = if bear then close else double.nan;
input positionSize = 100;
input stopBars = 1; #2
input useMaTarget = yes;
input targetMaLength = 14;
def tradePrice = close;
def stopTarget = movingAverage(averageType.exponential,close,targetMaLength);
def longStopLoss = low[stopBars]; # [2]
def shortStopLoss = high[stopBars]; # [2]
# Longs
def longSell = if useMaTarget and close crosses below stopTarget then tradePrice else Double.NaN;
def LongStop = if close crosses below longStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.BUY_TO_OPEN, upTrigger, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna Buy");
AddOrder(OrderType.SELL_TO_CLOSE, longSell, tradePrice, positionSize, Color.pink, Color.pink, "Anna Sell");
AddOrder(OrderType.SELL_TO_CLOSE, LongStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna long stoploss");

# Shorts
def shortBuy = if useMaTarget and close crosses above stopTarget then tradePrice else Double.NaN;
def shortStop = if close crosses above shortStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.SELL_TO_OPEN, dnTrigger, tradePrice, positionSize, Color.pink, Color.pink, "Anna short");
AddOrder(OrderType.BUY_TO_CLOSE, shortBuy, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna cover");
AddOrder(OrderType.BUY_TO_CLOSE, shortStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna short stoploss");

# end of script
this script shows signal on daily time Frame only. I tired on 1hr frame no signal.
 
this script shows signal on daily time Frame only. I tired on 1hr frame no signal.
As mentioned:
"Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames."

It works fine for me on the hourly. But since its calculating signals based off 2x the average volume you may find fewer signals. Try reducing the value from 2 to 1.
 
As mentioned:
"Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames."

It works fine for me on the hourly. But since its calculating signals based off 2x the average volume you may find fewer signals. Try reducing the value from 2 to 1.
thanks I will check on update you .
 
Do a search for Volume Price Analysis or Volume Spread Analysis.
High Growth Stock investor uses VPA in it's software
 
My entire system is based on Volume Spread Analysis. I have a complete system that I'm going to present hereafter I work out all the kinks;
I really appreciate all of your comments and feedback. They have helped me to grow and to understand the needs of other traders, which is my goal that we all prosper, become better traders, and investors.
Look forward to it and thank you for sharing this indicator. I am a huge fan of volume & supply/demand too, it's always interesting to see new ways of analyzing volume and finding new indicators to help with this.
 
Neat indicator!
I added signals based off the cyan and magenta bars represented by green/red vertical lines and an adjustable multiplier to specify how much above the average they must be before triggering a signal. You can also choose to allow/disallow opposing volume. In back testing the default settings here seemed to work best.

Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames.

And I reworked the code a little bit to reduce redundancy and make it easier to modify in the future.
Thanks @Cwparker23 !

anna.png


Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#
# v2.1

#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = expAverage(volume);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else GetColor(1));


input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if up3 and vol >= (volAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and (vol >= (volAvg * multiplier)) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else double.nan;
def bear =
    if down3 and vol >= (volAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and (vol >= (volAvg * multiplier)) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else double.nan;

addVerticalLine(bull[1],"bull",color.green,curve.short_dash);
addverticalLine(bear[1],"bear",color.red,curve.short_dash);

# end of script


And here is a quick strategy if you'd like to back test it

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Strategy for back testing
# v2.1


#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.WHITE);

#declare lower;
#declare zerobase;

def Vol = volume;
def VolAvg = expAverage(volume);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.LIGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.CYAN);
DefineGlobalColor("CAM_UP4", Color.BLUE);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.DARK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.MAGENTA );
DefineGlobalColor("CAM_DN4", Color.PLUM );

AssignPriceColor(if !paintBars then Color.CURRENT
else if up3 then GlobalColor("CAM_UP3")
else if down3 then GlobalColor("CAM_DN3")
else if up4 then GlobalColor("CAM_UP4")
else if down4 then GlobalColor("CAM_DN4")
else if up then GlobalColor("CAM_UP")
else if down then GlobalColor("CAM_DN")
else if up2 then GlobalColor("CAM_UP2")
else if down2 then GlobalColor("CAM_DN2")
else Color.CURRENT);


def bull =
    if up3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else Double.NaN;
def bear =
    if down3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else Double.NaN;

AddVerticalLine(bull[1], "bull", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(bear[1], "bear", Color.RED, Curve.SHORT_DASH);



# strategy
def uptrigger = if bull then close else double.nan;
def dnTrigger = if bear then close else double.nan;
input positionSize = 100;
input stopBars = 1; #2
input useMaTarget = yes;
input targetMaLength = 14;
def tradePrice = close;
def stopTarget = movingAverage(averageType.exponential,close,targetMaLength);
def longStopLoss = low[stopBars]; # [2]
def shortStopLoss = high[stopBars]; # [2]
# Longs
def longSell = if useMaTarget and close crosses below stopTarget then tradePrice else Double.NaN;
def LongStop = if close crosses below longStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.BUY_TO_OPEN, upTrigger, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna Buy");
AddOrder(OrderType.SELL_TO_CLOSE, longSell, tradePrice, positionSize, Color.pink, Color.pink, "Anna Sell");
AddOrder(OrderType.SELL_TO_CLOSE, LongStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna long stoploss");

# Shorts
def shortBuy = if useMaTarget and close crosses above stopTarget then tradePrice else Double.NaN;
def shortStop = if close crosses above shortStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.SELL_TO_OPEN, dnTrigger, tradePrice, positionSize, Color.pink, Color.pink, "Anna short");
AddOrder(OrderType.BUY_TO_CLOSE, shortBuy, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna cover");
AddOrder(OrderType.BUY_TO_CLOSE, shortStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna short stoploss");

# end of script
I found your mod interesting and altered it to create an upper indicator with arrows. However, upon observation the signals repaint until the next bar closes, and upon inspection of the code this makes sense since your signal in fact relies on the bar after the anomaly. Can you share how you use the signals in light of the repainting? Do you simply wait for the next bar to close or perhaps enter in the middle of the bar?
 
I found your mod interesting and altered it to create an upper indicator with arrows. However, upon observation the signals repaint until the next bar closes, and upon inspection of the code this makes sense since your signal in fact relies on the bar after the anomaly. Can you share how you use the signals in light of the repainting? Do you simply wait for the next bar to close or perhaps enter in the middle of the bar?
I tend to wait for the next bar to close. If price is divergence with disparity index then I take the trade.
 
I tend to wait for the next bar to close. If price is divergence with disparity index then I take the trade.
Ok, waiting for that next candle to close makes sense, especially on a 1 min. chart where it's not too much delay. Do you mind explaining your second sentence in more detail? When is "price divergence with disparity index" and what is the disparity index you refer to?

Thanks for your help.
 
Ok, waiting for that next candle to close makes sense, especially on a 1 min. chart where it's not too much delay. Do you mind explaining your second sentence in more detail? When is "price divergence with disparity index" and what is the disparity index you refer to?

Thanks for your help.
I can't upload an image to this site from my phone, but divergence in the disparityIndex is much like rsi or macd divergence except it seems to show them earlier and in more detail. The disparity index I use is one I customized to include Bollinger bands, but you can use the factory one that is available in TOS.
When I see a cyan or magenta bar on the Anna Coulling VPA I check to see if the price is in divergence with the disparity index indicator.
 
I created this indicator after reading Anna Coulling book on volume price analysis. https://www.amazon.com/Complete-Gui...t=&hvlocphy=9051671&hvtargid=pla-432422856366

The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish ad magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

Here is the link to the indicator: https://tos.mx/uSOXiHe Click here for --> Easiest way to load shared links

Here are some other indicators I created: https://www.youtube.com/channel/UCX4CpcAoeGoFCFeOIzWlLqA
Can you add me on twitter; afghanrebel

Dm me & tell me Anna couling, I have been trading for +14 years. I believe we can help each other. I love your work ethic, nice YouTube videos
 
Hi Best wishes: good work: you thread has me thinking re the following Brain Storm: a look at the Tickprofile indicator at TOS. also TSM, time segmented volume indicator. Your interest in volume : it reminds me of a basic Chemistry common concept a. Irregular bodies- specimens are brought into a lab: size is determined by measuring volume in chemistry laboratory studies by immersing it in a volume of water in a graduated cylinder Example. Step 1 measure the level of liquid in the cyclinder before immersion. Step 2 Immerse the object Step 3. Notice the difference in Volume from step 1 to step 2 and you have the change in volume.
look at Perry Kaufman's indicator:
Price change/ Volume Change %: Perrry Kaufman's Averages also measure degrees of Efficiency Ratio which measures following Efficiency Ratio = Change in Price/ Volitility.
The higher the Eff Ratio the more linear the movement in the stock (wave,function,option, future, etc). to summarize: charts with Candles which are basically analagous to a cyclinder. and you are looking at price changes reflected over time. You also want volume changes to give you indications of directional change:
So now you want Efficiency Ratio of Net Change in Price/Volume in a specific time and you want to see if this variable is increasing or decreasing.. Try Rate of Change in Volume vs Rate of Change in Price, also look at Benoit Mendelbrot's concept of Fractal Energy which measures degree of linear movement in any period of a time/space in a particular function (stock, option, wave). That is what occurs to me in spending time on this thread. Best to all.
 
Neat indicator!
I added signals based off the cyan and magenta bars represented by green/red vertical lines and an adjustable multiplier to specify how much above the average they must be before triggering a signal. You can also choose to allow/disallow opposing volume. In back testing the default settings here seemed to work best.

Note: My mods are geared towards use on a 1d/1min chart. You may need to make adjustments for higher time frames.

And I reworked the code a little bit to reduce redundancy and make it easier to modify in the future.
Thanks @Cwparker23 !

anna.png


Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Updates:
#    Further reduced redundancy
#
# v2.1

#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.white);

declare lower;
declare zerobase;

plot Vol = volume;
plot VolAvg = expAverage(volume);
VolAvg .SetPaintingStrategy(PaintingStrategy.squared_HISTOGRAM);
VolAvg .SetDefaultColor(Color.GRAY);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.green);
Vol.DefineColor("Down", Color.red);
Vol.DefineColor("Up2", Color.light_green);
Vol.DefineColor("Down2", Color.dark_ORANGE );
Vol.DefineColor("Up3", Color.cyan);
Vol.DefineColor("Up4", Color.blue);
Vol.DefineColor("Down3", Color.mAGENTA );
Vol.DefineColor("Down4", Color.plum );

Vol.AssignValueColor(
    if up3 then Vol.color("Up3")
    else if up4  then Vol.color("Up4")
    else if down3 then Vol.color("Down3")
    else if down4 then Vol.color("Down4")
    else if up  then Vol.color("Up")
    else if down then Vol.color("Down")
    else if up2 then Vol.color("Up2")
    else if down2 then Vol.color("Down2")
    else GetColor(1));


input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.liGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.cyan);
DefineGlobalColor("CAM_UP4", Color.blue);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.darK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.mAGENTA );
DefineGlobalColor("CAM_DN4", Color.plum );

AssignPriceColor(
    if !paintBars then Color.CURRENT
    else if up3 then GlobalColor("CAM_UP3")
    else if down3 then GlobalColor("CAM_DN3")
    else if up4 then GlobalColor("CAM_UP4")
    else if down4 then GlobalColor("CAM_DN4")
    else if up then GlobalColor("CAM_UP")
    else if down then GlobalColor("CAM_DN")
    else if up2 then GlobalColor("CAM_UP2")
    else if down2 then GlobalColor("CAM_DN2")
    else Color.CURRENT);


def bull =
    if up3 and vol >= (volAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and (vol >= (volAvg * multiplier)) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else double.nan;
def bear =
    if down3 and vol >= (volAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and (vol >= (volAvg * multiplier)) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else double.nan;

addVerticalLine(bull[1],"bull",color.green,curve.short_dash);
addverticalLine(bear[1],"bear",color.red,curve.short_dash);

# end of script


And here is a quick strategy if you'd like to back test it

Code:
# Original script by Cwparker23
# Mods/additions by Tidan
# Strategy for back testing
# v2.1


#hint: The indicator finds irregular bodies based on candle size and volume it colors price to indicate irregular bodies below volume average (blue bullish and plum bearish) and indicate bodies above-average volume (cyan bullish and magenta bearish). Also colors price with above-average volume (green bullish and red bearish) and below-average volume (light green bullish and orange bearish).

input multiplier = 2;
input allowOpposingVolume = yes;


AddLabel(yes, "Day_volume: " + volume (period = "DAY" ), Color.LIGHT_GRAY);
AddLabel(yes, "volume: " + volume, Color.WHITE);

#declare lower;
#declare zerobase;

def Vol = volume;
def VolAvg = expAverage(volume);
def BODY_RANGE = max(oPEN,cLOSE) - min(oPEN,cLOSE);
def IR_BODY = if (BODY_RANGE < BODY_RANGE[1]) and (volume > volume[1]) then 1 else 0 ;
def IR_BODYG  = if IR_BODY and (close > open) then 1 else 0;
def IR_BODYR  = if IR_BODY and (close < open) then 1 else 0;

####
def up3 = if IR_BODYG and (Vol > VolAvg) then 1 else 0;
def up4 = if IR_BODYG then 1 else 0;
def down3 = if IR_BODYR and (Vol > VolAvg) then 1 else 0;
def down4 = if IR_BODYR then 1 else 0;
def up = if (close > open) and (Vol > VolAvg)  then 1 else 0;
def down = if (close < open) and (Vol > VolAvg) then 1 else 0;
def up2 = if (close > open) then 1 else 0;
def down2 = if (close < open) then 1 else 0;
####

input paintBars = yes;

DefineGlobalColor("CAM_UP", Color.GREEN);
DefineGlobalColor("CAM_UP2", Color.LIGHT_GREEN);
DefineGlobalColor("CAM_UP3", Color.CYAN);
DefineGlobalColor("CAM_UP4", Color.BLUE);
DefineGlobalColor("CAM_DN", Color.RED);
DefineGlobalColor("CAM_DN2", Color.DARK_ORANGE );
DefineGlobalColor("CAM_DN3", Color.MAGENTA );
DefineGlobalColor("CAM_DN4", Color.PLUM );

AssignPriceColor(if !paintBars then Color.CURRENT
else if up3 then GlobalColor("CAM_UP3")
else if down3 then GlobalColor("CAM_DN3")
else if up4 then GlobalColor("CAM_UP4")
else if down4 then GlobalColor("CAM_DN4")
else if up then GlobalColor("CAM_UP")
else if down then GlobalColor("CAM_DN")
else if up2 then GlobalColor("CAM_UP2")
else if down2 then GlobalColor("CAM_DN2")
else Color.CURRENT);


def bull =
    if up3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else if allowOpposingVolume and down3 and Vol >= (VolAvg * multiplier) and (up3[-1] or up4[-1] or up[-1] or up2[-1]) then yes
    else Double.NaN;
def bear =
    if down3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else if allowOpposingVolume and up3 and Vol >= (VolAvg * multiplier) and (down3[-1] or down4[-1] or down[-1] or down2[-1]) then yes
    else Double.NaN;

AddVerticalLine(bull[1], "bull", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(bear[1], "bear", Color.RED, Curve.SHORT_DASH);



# strategy
def uptrigger = if bull then close else double.nan;
def dnTrigger = if bear then close else double.nan;
input positionSize = 100;
input stopBars = 1; #2
input useMaTarget = yes;
input targetMaLength = 14;
def tradePrice = close;
def stopTarget = movingAverage(averageType.exponential,close,targetMaLength);
def longStopLoss = low[stopBars]; # [2]
def shortStopLoss = high[stopBars]; # [2]
# Longs
def longSell = if useMaTarget and close crosses below stopTarget then tradePrice else Double.NaN;
def LongStop = if close crosses below longStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.BUY_TO_OPEN, upTrigger, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna Buy");
AddOrder(OrderType.SELL_TO_CLOSE, longSell, tradePrice, positionSize, Color.pink, Color.pink, "Anna Sell");
AddOrder(OrderType.SELL_TO_CLOSE, LongStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna long stoploss");

# Shorts
def shortBuy = if useMaTarget and close crosses above stopTarget then tradePrice else Double.NaN;
def shortStop = if close crosses above shortStopLoss then tradePrice else Double.NaN;
AddOrder(OrderType.SELL_TO_OPEN, dnTrigger, tradePrice, positionSize, Color.pink, Color.pink, "Anna short");
AddOrder(OrderType.BUY_TO_CLOSE, shortBuy, tradePrice, positionSize, Color.cyan, Color.cyan, "Anna cover");
AddOrder(OrderType.BUY_TO_CLOSE, shortStop, tradePrice, positionSize, Color.ORANGE, Color.ORANGE, "Anna short stoploss");

# end of script
Can you please provide the code for the top image with the clouds? Thanks
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
195 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top