Horizontal Line plot based on DOJI

StewyT

New member
Looking to plot a horizontal line spanning 10 bars to the right using the following code. Thanks in advance!!

Code:
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
    IsUp[2] and
    IsUp[1] and
    IsDown[0];

plot greentored = PatternPlot  from -1 bars ago;
 
Last edited by a moderator:
Solution
Looking to plot a horizontal line spanning 10 bars to the right using the following code. Thanks in advance!!

Code:
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
    IsUp[2] and
    IsUp[1] and
    IsDown[0];

plot greentored = PatternPlot  from -1 bars ago;

here is my guess on what you want,
..a horizontal line,
..that extends for a few bars,
..that starts from some close price.

line length in bars , line_width = 4
line starting point, from last bar , line_offset = 1

default line starts 1 bar after the last bar. 0 would start the line on the last bar.
can enter negative numbers for the offset, to start a line before the last bar...
Looking to plot a horizontal line spanning 10 bars to the right using the following code. Thanks in advance!!

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
IsUp[2] and
IsUp[1] and
IsDown[0];

plot greentored = PatternPlot from -1 bars ago;

that looks like jibberish that a wizard spits out.
doji isn't used.
the average isn't used
it is plotting a logic signal

can you explain,
..where you want to see something? ( main chart, lower chart ?)
..what do you think you want to see ? ( a line at the price level of current close price?)
 
Looking to plot a horizontal line spanning 10 bars to the right using the following code. Thanks in advance!!

Code:
def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def PatternPlot =
    IsUp[2] and
    IsUp[1] and
    IsDown[0];

plot greentored = PatternPlot  from -1 bars ago;

here is my guess on what you want,
..a horizontal line,
..that extends for a few bars,
..that starts from some close price.

line length in bars , line_width = 4
line starting point, from last bar , line_offset = 1

default line starts 1 bar after the last bar. 0 would start the line on the last bar.
can enter negative numbers for the offset, to start a line before the last bar.

can show vertical lines, to verify the range of bars for the line.


Code:
# horz_priceline_after_00b

def na = Double.NaN;
def bn = barnumber();
def lastbar = !isnan(close) and isnan(close[-1]);

input line_width = 4;
input line_offset = 1;
def off =  line_offset - 1;
#  define a range of bars for the horz line
def x = (!isnan(close[line_width + off]) and isnan(close[off]));

def clsx = if bn == 1 then na
  else if !isnan(clsx[1]) then clsx[1]
  else if lastbar then close
  else if !x[1] and x and isnan(clsx[1]) then close
  else clsx[1];

plot z = if x then clsx else na;
#z.SetStyle(Curve.MEDIUM_DASH);
z.setdefaultcolor(color.white);
z.setlineweight(1);
#z.hidebubble();

#----------------------
input test1_vert_lines = no;
addverticalline(test1_vert_lines and x, "-");
#

hE078Jf.jpg
 
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
367 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