# Pop, pull back, candle over candle strategy

#### berodney

##### New member
Has anyone wrote a strategy in thinkscript like below (or something similar)?

Note: This can be used for any timeframe, but I like to look at 1m and 5m charts.

Pop pull back candle over candle – Strong igniting bar at least 3 times the size of a normal bar, followed by a resting bar closing in the top 33% of the igniting bar (the pull back), entry when it looks like it will break the high of the pull back bar.

Conditions:
-Stock trending up
-Previous Candle has to have a range 33.33% larger than average (upward)
-1,2 or 3 pull back candles (need to stay in the top 50% of pop candle
-Buy condition when stock price passes the high of previous pull back candle and smi > smiavg and vol > 10,000
-Sell condition when stock price passes the high of the pop candle or smi < smiavg
Example

I know this is kind of a crazy ask and I'm not that good with coding in thinkscript (or in general) so any help would be appreciated.
---------------------------------------------------------------------------------------------------------------------------------------------------------------
This is what I have so far:

Thanks to redit user Mobius_ts for the starting point

Current Issues/changes:
-Instead of the buy and sell be on the Open/close of the candle change it so it would show when the condition is met
Currently just showing buy and sell on the same candle once the first condition is met

CODE:

# Conditions:

#-Stock trending up

#-Previous Candle has to have a range 33.33% larger than average (upward)

#-1,2 or 3 pull back candles (need to stay in the top 50% of pop candle

#-Buy condition when stock price passes the high of previous pull back candle

#-Sell condition when stock price passes the high of the pop candle

input length = 10;

def TR = TrueRange(high, close, low);

def ATR = Average(TR, length);

def cond_1 = TR >= ATR * 1.33;

def cond_1_High = if(cond_1, high, cond_1_High[1]);

def cond_1_HL2 = if(cond_1, HL2, cond_1_HL2[1]);

def cond_2 = high < cond_1_High and low > cond_1_HL2;

def cond_2_High = if(cond_1[1] and cond_2, high, cond_2_High[1]);

###################
#
# SMI
#
###################

input over_bought = 40.0;
input over_sold = -40.0;
input percentDLength = 3;
input percentKLength = 5;

def min_low = lowest(low, percentKLength);
def max_high = highest(high, percentKLength);
def rel_diff = close - (max_high + min_low)/2;
def diff = max_high - min_low;

def avgrel = expaverage(expaverage(rel_diff, percentDLength), percentDLength);
def avgdiff = expaverage(expaverage(diff, percentDLength), percentDLength);

def SMI = if avgdiff != 0 then avgrel / (avgdiff / 2) * 100 else 0;

def AvgSMI = expaverage(smi, percentDLength);

###################
#
#
###################

def vol = volume >= 10000;
def smi2 = smi >= avgsmi;
def smi3 = smi <= avgsmi;

addOrder(OrderType.BUY_TO_OPEN, cond_1[2] and cond_2[1]and vol and smi2 and close crosses above cond_2_High, cond_2_high);

addOrder(OrderType.SELL_TO_CLOSE, close crosses above cond_1_High or smi3, cond_1_High);

Last edited:
I am looking for an indicator/study/strategy that will mark when there is a "Candle over Candle" like in this video (
) where StockJock describes his trading strategy. I do not know what to call it other than candle over candle. If this hasn't been created, Can someone please help me to create a study that will mark and or alert when this scenario occurs. I am looking to use the same strategy as StockJock does. Just trying something different than I have been.
If there is a formal name for this candle action, please let me know.
As you can see in the video, When there is a Trend upwards or downwards and then there is a pull back, The very next candle that breaks the high of the last pull back candle is the entry point for scalping. Please let me know if I need to explain it further. Hopefully this will do.

I just found this in a thread. It looks like the same request. Maybe someone can take a look at it and get it to work.

I am looking for an indicator/study/strategy that will mark when there is a "Candle over Candle" like in this video , where StockJock describes his trading strategy. I do not know what to call it other than candle over candle. If this hasn't been created, Can someone please help me to create a study that will mark and or alert when this scenario occurs. I am looking to use the same strategy as StockJock does. Just trying something different than I have been.
If there is a formal name for this candle action, please let me know.
As you can see in the video, When there is a Trend upwards or downwards and then there is a pull back, The very next candle that breaks the high of the last pull back candle is the entry point for scalping. Please let me know if I need to explain it further. Hopefully this will do.

here is something to look at.

what i am seeing is the pullback usually happens near a peak, and it drops afterwards, so this appears to be too late to buy in. sometimes price reverses and continues up.
you would be better off watching my blue dots.

---------------------

determines an uptrend, based on higher highs.
looks for a lower high, then establishes sell and buy levels.

this means, need 2 higher highs in a row, to be called up trend
trend_qty = 2;

this means, if 3 not trendup (3 lower highs) happen out of (3+1) bars , then cancel
input cancel_qty = 3;

Code:
``````# pullback_entry_00

# Pop, pull back, candle over candle strategy
#  post2

# When there is a trend upwards,
#  higher highs,
#   the last seq higher high is the sell level.

# when there is a pull back candle,
#  a lower high,
#   the high of this lower candle is the buy level.

# if a candle after the pull back breaks the high of the pull back candle,  is the entry point for scalping.

# sell when price > target, high of last seq hihi.

# cancel if ...   x bars of lower highs?

def bn = barnumber();
def na = double.nan;

def hihi = high > high[1];
def trend_qty = 2;
def trendup = sum(hihi, trend_qty) == trend_qty;

input trendup_points = yes;
def upv = 1.002;
plot ztu = if trendup_points and trendup then high*upv else na;
ztu.SetPaintingStrategy(PaintingStrategy.points);
#ztu.setdefaultcolor(color.green);
ztu.setdefaultcolor(color.cyan);
ztu.setlineweight(3);
ztu.hidebubble();

def pullback = !trendup;
input cancel_qty = 3;
def cancel = sum(pullback, (cancel_qty + 1)) >= cancel_qty;

def toff = 0;
#def target = if bn == 1 then 0
#  else if cancel then 0
#  else if target[1] > 0 then target[1]
#  else if high crosses above target[1] then 0
#  else if pullback then high[1]
#  else target[1];

# get target line to start on target bar
def target = if bn == 1 then 0
else if cancel then 0
else if target[1] > 0 then target[1]
else if high crosses above target[1] then 0
else if pullback[-1] then high[0]
else target[1];

def entry = if cancel then 0
else if high crosses above target[1] then 0
else if entry[1] > 0 then entry[1]
else if pullback then high
else entry[1];

def buy = (entry > 0 and (close crosses above entry));
def sell = (target > 0 and (close crosses above target));

plot zc = if test_show_buy_sell_arrows and cancel and target[1] > 0 then high*1.001 else na;
zc.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zc.setdefaultcolor(color.yellow);
zc.setlineweight(3);
zc.hidebubble();

zu.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zu.setdefaultcolor(color.green);
zu.setlineweight(3);
zu.hidebubble();

plot zd = if test_show_buy_sell_arrows and sell then high*1.001 else na;
zd.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zd.setdefaultcolor(color.red);
zd.setlineweight(3);
zd.hidebubble();

#---------------------

# draw a green line for entry price
plot zlong = if entry > 0 then entry else na;
zlong.SetDefaultColor(Color.green);
zlong.setlineweight(2);
zlong.hidebubble();

# sell price
plot zlow = if target > 0 then target else na;
zlow.SetDefaultColor(Color.magenta);
zlow.setlineweight(1);
zlow.hidebubble();
#``````

blue dots = a trend up , for x bars
purple line = target , sell level
green line = entry , buy level
yellow arrow = cancel , down trend

This looks interesting can you make it for down trending also?

here is something to look at.

what i am seeing is the pullback usually happens near a peak, and it drops afterwards, so this appears to be too late to buy in. sometimes price reverses and continues up.
you would be better off watching my blue dots.

---------------------

determines an uptrend, based on higher highs.
looks for a lower high, then establishes sell and buy levels.

this means, need 2 higher highs in a row, to be called up trend
trend_qty = 2;

this means, if 3 not trendup (3 lower highs) happen out of (3+1) bars , then cancel
input cancel_qty = 3;

Code:
``````# pullback_entry_00

# Pop, pull back, candle over candle strategy
#  post2

# When there is a trend upwards,
#  higher highs,
#   the last seq higher high is the sell level.

# when there is a pull back candle,
#  a lower high,
#   the high of this lower candle is the buy level.

# if a candle after the pull back breaks the high of the pull back candle,  is the entry point for scalping.

# sell when price > target, high of last seq hihi.

# cancel if ...   x bars of lower highs?

def bn = barnumber();
def na = double.nan;

def hihi = high > high[1];
def trend_qty = 2;
def trendup = sum(hihi, trend_qty) == trend_qty;

input trendup_points = yes;
def upv = 1.002;
plot ztu = if trendup_points and trendup then high*upv else na;
ztu.SetPaintingStrategy(PaintingStrategy.points);
#ztu.setdefaultcolor(color.green);
ztu.setdefaultcolor(color.cyan);
ztu.setlineweight(3);
ztu.hidebubble();

def pullback = !trendup;
input cancel_qty = 3;
def cancel = sum(pullback, (cancel_qty + 1)) >= cancel_qty;

def toff = 0;
#def target = if bn == 1 then 0
#  else if cancel then 0
#  else if target[1] > 0 then target[1]
#  else if high crosses above target[1] then 0
#  else if pullback then high[1]
#  else target[1];

# get target line to start on target bar
def target = if bn == 1 then 0
else if cancel then 0
else if target[1] > 0 then target[1]
else if high crosses above target[1] then 0
else if pullback[-1] then high[0]
else target[1];

def entry = if cancel then 0
else if high crosses above target[1] then 0
else if entry[1] > 0 then entry[1]
else if pullback then high
else entry[1];

def buy = (entry > 0 and (close crosses above entry));
def sell = (target > 0 and (close crosses above target));

plot zc = if test_show_buy_sell_arrows and cancel and target[1] > 0 then high*1.001 else na;
zc.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zc.setdefaultcolor(color.yellow);
zc.setlineweight(3);
zc.hidebubble();

zu.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zu.setdefaultcolor(color.green);
zu.setlineweight(3);
zu.hidebubble();

plot zd = if test_show_buy_sell_arrows and sell then high*1.001 else na;
zd.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zd.setdefaultcolor(color.red);
zd.setlineweight(3);
zd.hidebubble();

#---------------------

# draw a green line for entry price
plot zlong = if entry > 0 then entry else na;
zlong.SetDefaultColor(Color.green);
zlong.setlineweight(2);
zlong.hidebubble();

# sell price
plot zlow = if target > 0 then target else na;
zlow.SetDefaultColor(Color.magenta);
zlow.setlineweight(1);
zlow.hidebubble();
#``````

blue dots = a trend up , for x bars
purple line = target , sell level
green line = entry , buy level
yellow arrow = cancel , down trend
Interesting. Thank you. Does this indicator re-paint?

here is something to look at.

what i am seeing is the pullback usually happens near a peak, and it drops afterwards, so this appears to be too late to buy in. sometimes price reverses and continues up.
you would be better off watching my blue dots.

---------------------

determines an uptrend, based on higher highs.
looks for a lower high, then establishes sell and buy levels.

this means, need 2 higher highs in a row, to be called up trend
trend_qty = 2;

this means, if 3 not trendup (3 lower highs) happen out of (3+1) bars , then cancel
input cancel_qty = 3;

Code:
``````# pullback_entry_00

# Pop, pull back, candle over candle strategy
#  post2

# When there is a trend upwards,
#  higher highs,
#   the last seq higher high is the sell level.

# when there is a pull back candle,
#  a lower high,
#   the high of this lower candle is the buy level.

# if a candle after the pull back breaks the high of the pull back candle,  is the entry point for scalping.

# sell when price > target, high of last seq hihi.

# cancel if ...   x bars of lower highs?

def bn = barnumber();
def na = double.nan;

def hihi = high > high[1];
def trend_qty = 2;
def trendup = sum(hihi, trend_qty) == trend_qty;

input trendup_points = yes;
def upv = 1.002;
plot ztu = if trendup_points and trendup then high*upv else na;
ztu.SetPaintingStrategy(PaintingStrategy.points);
#ztu.setdefaultcolor(color.green);
ztu.setdefaultcolor(color.cyan);
ztu.setlineweight(3);
ztu.hidebubble();

def pullback = !trendup;
input cancel_qty = 3;
def cancel = sum(pullback, (cancel_qty + 1)) >= cancel_qty;

def toff = 0;
#def target = if bn == 1 then 0
#  else if cancel then 0
#  else if target[1] > 0 then target[1]
#  else if high crosses above target[1] then 0
#  else if pullback then high[1]
#  else target[1];

# get target line to start on target bar
def target = if bn == 1 then 0
else if cancel then 0
else if target[1] > 0 then target[1]
else if high crosses above target[1] then 0
else if pullback[-1] then high[0]
else target[1];

def entry = if cancel then 0
else if high crosses above target[1] then 0
else if entry[1] > 0 then entry[1]
else if pullback then high
else entry[1];

def buy = (entry > 0 and (close crosses above entry));
def sell = (target > 0 and (close crosses above target));

plot zc = if test_show_buy_sell_arrows and cancel and target[1] > 0 then high*1.001 else na;
zc.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zc.setdefaultcolor(color.yellow);
zc.setlineweight(3);
zc.hidebubble();

zu.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zu.setdefaultcolor(color.green);
zu.setlineweight(3);
zu.hidebubble();

plot zd = if test_show_buy_sell_arrows and sell then high*1.001 else na;
zd.SetPaintingStrategy(PaintingStrategy.ARROw_down);
zd.setdefaultcolor(color.red);
zd.setlineweight(3);
zd.hidebubble();

#---------------------

# draw a green line for entry price
plot zlong = if entry > 0 then entry else na;
zlong.SetDefaultColor(Color.green);
zlong.setlineweight(2);
zlong.hidebubble();

# sell price
plot zlow = if target > 0 then target else na;
zlow.SetDefaultColor(Color.magenta);
zlow.setlineweight(1);
zlow.hidebubble();
#``````

blue dots = a trend up , for x bars
purple line = target , sell level
green line = entry , buy level
yellow arrow = cancel , down trend
After a bit more assessment, I am not sure if any study/indicator will be fast enough for this trading method as I will need to get in right at breaking above the last pullback candle and sell at high of "Pop" candle. This would probably very difficult to accomplish with indicators. If anyone has any experience to the contrary, please let us know.

This looks interesting can you make it for down trending also?

i think this will work, i think i got everything in second half changed correctly....
i copied the original code and changed it to do the opposite , for down trends.

Code:
``````# pullback_entry_01

# Pop, pull back, candle over candle strategy

# When there is a trend upwards,
#  higher highs,
#   the last seq higher high is the sell level.

# when there is a pull back candle,
#  a lower high,
#   the high of this lower candle is the buy level.

# if a candle after the pull back breaks the high of the pull back candle,  is the entry point for scalping.
# sell when price > target, high of last seq hihi.
# cancel if ...   x bars of lower highs?

def bn = BarNumber();
def na = Double.NaN;

#--------------------------

def hihi = high > high[1];
def trendup_qty = 2;
def trendup = Sum(hihi, trendup_qty) == trendup_qty;

input trendup_dots = yes;
def upv = 1.002;
plot ztu = if trendup_dots and trendup then high * upv else na;
ztu.SetPaintingStrategy(PaintingStrategy.POINTS);
#ztu.setdefaultcolor(color.green);
ztu.SetDefaultColor(Color.CYAN);
ztu.SetLineWeight(3);
ztu.HideBubble();

def uppullback = !trendup;
input upcancel_qty = 3;
def upcancel = Sum(uppullback, (upcancel_qty + 1)) >= upcancel_qty;

# get target line to start on target bar
def uptarget = if bn == 1 then 0
else if upcancel then 0
else if uptarget[1] > 0 then uptarget[1]
else if high crosses above uptarget[1] then 0
else if uppullback[-1] then high[0]
else uptarget[1];

def upentry = if upcancel then 0
else if high crosses above uptarget[1] then 0
else if upentry[1] > 0 then upentry[1]
else if uppullback then high
else upentry[1];

def upbuy = (upentry > 0 and (close crosses above upentry));
def upsell = (uptarget > 0 and (close crosses above uptarget));

plot zc = if show_buy_sell_arrows and upcancel and uptarget[1] > 0 then high * 1.001 else na;
zc.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zc.SetDefaultColor(Color.YELLOW);
zc.SetLineWeight(3);
zc.HideBubble();

plot zu = if show_buy_sell_arrows and upbuy then low * 0.999 else na;
zu.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zu.SetDefaultColor(Color.GREEN);
zu.SetLineWeight(3);
zu.HideBubble();

plot zd = if show_buy_sell_arrows and upsell then high * 1.001 else na;
zd.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zd.SetDefaultColor(Color.RED);
zd.SetLineWeight(3);
zd.HideBubble();

# draw a green line for entry price
plot zlong = if upentry > 0 then upentry else na;
zlong.SetDefaultColor(Color.GREEN);
zlong.SetLineWeight(2);
zlong.HideBubble();

# sell price
plot zlow = if uptarget > 0 then uptarget else na;
zlow.SetDefaultColor(Color.cyan);
zlow.SetLineWeight(1);
zlow.HideBubble();
#

#----------------------------------
#----------------------------------

def lolo = low < low[1];
def trenddwn_qty = 2;
def trenddwn = Sum(lolo, trenddwn_qty) == trenddwn_qty;

input trenddwn_dots = yes;
#def vup = 1.002;
def vdwn = 0.998;
plot ztdwn = if trenddwn_dots and trenddwn then low * vdwn else na;
ztdwn.SetPaintingStrategy(PaintingStrategy.POINTS);
#ztdwn.setdefaultcolor(color.green);
ztdwn.SetDefaultColor(Color.CYAN);
ztdwn.SetLineWeight(3);
ztdwn.HideBubble();

def dwnpullback = !trenddwn;
input dwncancel_qty = 3;
def dwncancel = Sum(dwnpullback, (dwncancel_qty + 1)) >= dwncancel_qty;

# get target line to start on target bar
def dwntarget = if bn == 1 then 0
else if dwncancel then 0
else if dwntarget[1] > 0 then dwntarget[1]
else if low crosses below dwntarget[1] then 0
else if dwnpullback[-1] then low[0]
else dwntarget[1];

def dwnentry = if dwncancel then 0
else if low crosses below dwntarget[1] then 0
else if dwnentry[1] > 0 then dwnentry[1]
else if dwnpullback then low
else dwnentry[1];

def dwnbuy = (dwnentry > 0 and (close crosses below dwnentry));
def dwnsell = (dwntarget > 0 and (close crosses below dwntarget));

plot zcdwn = if show_buy_sell_arrows and dwncancel and dwntarget[1] > 0 then low * 0.999 else na;
zcdwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zcdwn.SetDefaultColor(Color.YELLOW);
zcdwn.SetLineWeight(3);
zcdwn.HideBubble();

plot zudwn = if show_buy_sell_arrows and dwnbuy then high * 1.001 else na;
zudwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
zudwn.SetDefaultColor(Color.REd);
zudwn.SetLineWeight(3);
zudwn.HideBubble();

plot zddwn = if show_buy_sell_arrows and dwnsell then low * 0.999 else na;
zddwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zddwn.SetDefaultColor(Color.green);
zddwn.SetLineWeight(3);
zddwn.HideBubble();

# draw a red line for entry price
plot zlongdwn = if dwnentry > 0 then dwnentry else na;
zlongdwn.SetDefaultColor(Color.REd);
zlongdwn.SetLineWeight(2);
zlongdwn.HideBubble();

# sell price
plot zlowdwn = if dwntarget > 0 then dwntarget else na;
zlowdwn.SetDefaultColor(Color.yellow);
zlowdwn.SetLineWeight(1);
zlowdwn.HideBubble();
#
#``````

i think this will work, i think i got everything in second half changed correctly....
i copied the original code and changed it to do the opposite , for down trends.

Code:
``````# pullback_entry_01

# Pop, pull back, candle over candle strategy

# When there is a trend upwards,
#  higher highs,
#   the last seq higher high is the sell level.

# when there is a pull back candle,
#  a lower high,
#   the high of this lower candle is the buy level.

# if a candle after the pull back breaks the high of the pull back candle,  is the entry point for scalping.
# sell when price > target, high of last seq hihi.
# cancel if ...   x bars of lower highs?

def bn = BarNumber();
def na = Double.NaN;

#--------------------------

def hihi = high > high[1];
def trendup_qty = 2;
def trendup = Sum(hihi, trendup_qty) == trendup_qty;

input trendup_dots = yes;
def upv = 1.002;
plot ztu = if trendup_dots and trendup then high * upv else na;
ztu.SetPaintingStrategy(PaintingStrategy.POINTS);
#ztu.setdefaultcolor(color.green);
ztu.SetDefaultColor(Color.CYAN);
ztu.SetLineWeight(3);
ztu.HideBubble();

def uppullback = !trendup;
input upcancel_qty = 3;
def upcancel = Sum(uppullback, (upcancel_qty + 1)) >= upcancel_qty;

# get target line to start on target bar
def uptarget = if bn == 1 then 0
else if upcancel then 0
else if uptarget[1] > 0 then uptarget[1]
else if high crosses above uptarget[1] then 0
else if uppullback[-1] then high[0]
else uptarget[1];

def upentry = if upcancel then 0
else if high crosses above uptarget[1] then 0
else if upentry[1] > 0 then upentry[1]
else if uppullback then high
else upentry[1];

def upbuy = (upentry > 0 and (close crosses above upentry));
def upsell = (uptarget > 0 and (close crosses above uptarget));

plot zc = if show_buy_sell_arrows and upcancel and uptarget[1] > 0 then high * 1.001 else na;
zc.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zc.SetDefaultColor(Color.YELLOW);
zc.SetLineWeight(3);
zc.HideBubble();

plot zu = if show_buy_sell_arrows and upbuy then low * 0.999 else na;
zu.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
zu.SetDefaultColor(Color.GREEN);
zu.SetLineWeight(3);
zu.HideBubble();

plot zd = if show_buy_sell_arrows and upsell then high * 1.001 else na;
zd.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
zd.SetDefaultColor(Color.RED);
zd.SetLineWeight(3);
zd.HideBubble();

# draw a green line for entry price
plot zlong = if upentry > 0 then upentry else na;
zlong.SetDefaultColor(Color.GREEN);
zlong.SetLineWeight(2);
zlong.HideBubble();

# sell price
plot zlow = if uptarget > 0 then uptarget else na;
zlow.SetDefaultColor(Color.cyan);
zlow.SetLineWeight(1);
zlow.HideBubble();
#

#----------------------------------
#----------------------------------

def lolo = low < low[1];
def trenddwn_qty = 2;
def trenddwn = Sum(lolo, trenddwn_qty) == trenddwn_qty;

input trenddwn_dots = yes;
#def vup = 1.002;
def vdwn = 0.998;
plot ztdwn = if trenddwn_dots and trenddwn then low * vdwn else na;
ztdwn.SetPaintingStrategy(PaintingStrategy.POINTS);
#ztdwn.setdefaultcolor(color.green);
ztdwn.SetDefaultColor(Color.CYAN);
ztdwn.SetLineWeight(3);
ztdwn.HideBubble();

def dwnpullback = !trenddwn;
input dwncancel_qty = 3;
def dwncancel = Sum(dwnpullback, (dwncancel_qty + 1)) >= dwncancel_qty;

# get target line to start on target bar
def dwntarget = if bn == 1 then 0
else if dwncancel then 0
else if dwntarget[1] > 0 then dwntarget[1]
else if low crosses below dwntarget[1] then 0
else if dwnpullback[-1] then low[0]
else dwntarget[1];

def dwnentry = if dwncancel then 0
else if low crosses below dwntarget[1] then 0
else if dwnentry[1] > 0 then dwnentry[1]
else if dwnpullback then low
else dwnentry[1];

def dwnbuy = (dwnentry > 0 and (close crosses below dwnentry));
def dwnsell = (dwntarget > 0 and (close crosses below dwntarget));

plot zcdwn = if show_buy_sell_arrows and dwncancel and dwntarget[1] > 0 then low * 0.999 else na;
zcdwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zcdwn.SetDefaultColor(Color.YELLOW);
zcdwn.SetLineWeight(3);
zcdwn.HideBubble();

plot zudwn = if show_buy_sell_arrows and dwnbuy then high * 1.001 else na;
zudwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
zudwn.SetDefaultColor(Color.REd);
zudwn.SetLineWeight(3);
zudwn.HideBubble();

plot zddwn = if show_buy_sell_arrows and dwnsell then low * 0.999 else na;
zddwn.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zddwn.SetDefaultColor(Color.green);
zddwn.SetLineWeight(3);
zddwn.HideBubble();

# draw a red line for entry price
plot zlongdwn = if dwnentry > 0 then dwnentry else na;
zlongdwn.SetDefaultColor(Color.REd);
zlongdwn.SetLineWeight(2);
zlongdwn.HideBubble();

# sell price
plot zlowdwn = if dwntarget > 0 then dwntarget else na;
zlowdwn.SetDefaultColor(Color.yellow);
zlowdwn.SetLineWeight(1);
zlowdwn.HideBubble();
#
#``````
Wow. Tis looks somewhat promising. I will test this out and get back.

87k+ Posts
321 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

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?