Could someone edit this code for Reversal candles?

Trigun1127

Member
I'm trying to get this code made by SleepyZ to draw an arrow when a red candles high (wick/tail) 2x,3x,4x bigger then its low at the minimum and the candle closing at a certain % near its low like 85%. Vice versa for green candles Close>Open with Low tail 2x bigger then the high and the candle closing at a certain percentage of the candle.

plot retracement_bull = if close > open and
close > low + (.50 * (high - low))
then 1 else 0;
retracement_bull.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
plot retracement_bear = if close < open and
close < high - (.50 * (high - low))
then 1 else 0;
retracement_bear.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

##Testing Bull Code
input testing = yes;
plot retrace_bull = if close > open
then low + (.50 * (high - low))
else Double.NaN;
retrace_bull.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
retrace_bull.SetDefaultColor(Color.WHITE);
retrace_bull.SetLineWeight(3);
retrace_bull.SetHiding(!testing);



##Testing Bear Code
plot retrace_bear = if close < open
then high - (.50 * (high - low))
else Double.NaN;
retrace_bear.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
retrace_bear.SetDefaultColor(Color.WHITE);
retrace_bear.SetLineWeight(3);
retrace_bear.SetHiding(!testing);


;
 
Last edited:
Solution
Its working very well! Only 1 issue I'm seeing currently and an exception. I want the reversal candles only to be labeled with a down arrow if the candle is red and up when the candle is green. (I may have missed a couple in picture)
Below I highlighted Fridays chart for /MES on candles that weren't technically reversal candles. An exception I would like to add is not to draw an arrow at all if the candle is a Doji.

modified , per post5,
up arrows only on green candles, down arrows only on red cables


Code:
# reversal_candles_02

def na = double.nan;
input wick_ratio = 3.0;
input close_within_per = 15.0;

def isup = (open < close);
def isdwn = (open > close);

def bodytop = max(open, close);
def bodybot = min(open, close);

def...
I'm trying to get this code made by SleepyZ to draw an arrow when a red candles high (wick/tail) 2x,3x,4x bigger then its low at the minimum and the candle closing at a certain % near its low like 85%. Vice versa for green candles Close>Open with Low tail 2x bigger then the high and the candle closing at a certain percentage of the candle.

EDIT
i removed the multiplier for placing the arrows. on some stocks the arrows get drawn far from candles.


i ignored your code and followed your rules. see if this is what you want


Code:
def na = double.nan;
input wick_ratio = 3.0;
input close_within_per = 15.0;

def bodytop = max(open, close);
def bodybot = min(open, close);

def topwick2 = high - bodytop;
def botwick2 = bodybot - low;

def topwick = if topwick2 == 0 then 0.001 else topwick2;
def botwick = if botwick2 == 0 then 0.001 else botwick2;

def dwn = (topwick/botwick > wick_ratio) and ((100*(close - low)/low)< close_within_per);
def up = (botwick/topwick > wick_ratio) and ((100*(high - close)/high)< close_within_per);

plot zdwn = if dwn then high * 1.0 else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(3);
zdwn.hidebubble();

plot zup = if up then low * 1.0 else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();
 
Last edited:

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

Mine is doing this for some reason

in the future, describe what is happening and what you want changed. 'this' and a picture with several studies loaded, isn't always clear.

sorry about that. those multipliers worked for the priced stocks i looked at.
i edited my code, and removed the arrow offsets. try it again.
 
Last edited:
Its working very well! Only 1 issue I'm seeing currently and an exception. I want the reversal candles only to be labeled with a down arrow if the candle is red and up when the candle is green. (I may have missed a couple in picture)
Below I highlighted Fridays chart for /MES on candles that weren't technically reversal candles. An exception I would like to add is not to draw an arrow at all if the candle is a Doji.
 
Its working very well! Only 1 issue I'm seeing currently and an exception. I want the reversal candles only to be labeled with a down arrow if the candle is red and up when the candle is green. (I may have missed a couple in picture)
Below I highlighted Fridays chart for /MES on candles that weren't technically reversal candles. An exception I would like to add is not to draw an arrow at all if the candle is a Doji.

modified , per post5,
up arrows only on green candles, down arrows only on red cables


Code:
# reversal_candles_02

def na = double.nan;
input wick_ratio = 3.0;
input close_within_per = 15.0;

def isup = (open < close);
def isdwn = (open > close);

def bodytop = max(open, close);
def bodybot = min(open, close);

def topwick2 = high - bodytop;
def botwick2 = bodybot - low;

def topwick = if topwick2 == 0 then 0.001 else topwick2;
def botwick = if botwick2 == 0 then 0.001 else botwick2;

def dwn = isdwn and (topwick/botwick > wick_ratio) and ((100*(close - low)/low)< close_within_per);
def up = isup and (botwick/topwick > wick_ratio) and ((100*(high - close)/high)< close_within_per);

input vert_off = 0.002;
plot zdwn = if dwn then high * (1 + vert_off) else na;
zdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
zdwn.SetDefaultColor(Color.red);
zdwn.setlineweight(3);
zdwn.hidebubble();

plot zup = if up then low * (1 - vert_off) else na;
zup.SetPaintingStrategy(PaintingStrategy.ARROW_up);
zup.SetDefaultColor(Color.green);
zup.setlineweight(3);
zup.hidebubble();
#
#
 
Solution

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
469 Online
Create Post

Similar threads

Similar threads

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