Expansion Line

UncleTerry

New member
More specifically, Im trying to code a horizontal line that is auto drawn across the an intraday chart when the price chart crates a candle wick instead of just an arrow at the bottom of the wick. Is it possible to code using horizontal lines instead of arrows? It would look similar to Robert's on researchtrade.com and on the "Fun with thinkscript" thread but instead of peaks and valleys, it would be candle wicks of a specific body type. (I do not own the rights to this picture)

I created a code the draws an arrow when a candle wick is created on the TOS chart. When ever a candle wick is generated on anytime frame, it creates an arrow at the bottom of the candle. I am sorry if my explanation was unclear. The wick tail setting I have would be 1.5 times the body. I wanted to know if there is a line of code that creates a line extension across the chart from the wick candle signal to the right side of the chart to possibly create a future pridiction of possible inflection points.

gxXcPzh.png


Below is what I've been using that is the closet to what I was trying to describe.

#Start
input magnitude =30;

# define top and bottom of candle body
def bodytop = max(open, close);
def bodybottom = min(open, close);

# define and plot the most recent valley
def valley = bodybottom <= Lowest(bodybottom[1], magnitude) and bodybottom <= Lowest(bodybottom[-magnitude], magnitude);
def valleyValue = if BarNumber() < magnitude then Double.NaN else if valley then bodybottom else valleyValue[1];
plot valleyline = valleyValue;
valleyline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
valleyline.SetDefaultColor(Color.magenta);

# extend the current valley line to the right edge of the chart
def countt = if IsNaN(valley) and !IsNaN(valley[1]) then 1 else countt[1] + 1;
plot valleyext = if IsNaN(valley) then GetValue(valleyline, countt) else Double.NaN;
valleyext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
valleyext.SetDefaultColor(Color.magenta);

# continue the previous valley as a dashed line, but not all the way to the far right of the screen :(
def oldvalley = if BarNumber() < magnitude then Double.NaN else if valley then valleyValue[1] else oldvalley[1];
plot oldvalleyline = oldvalley;
oldvalleyline.SetPaintingStrategy(PaintingStrategy.DASHES);
oldvalleyline.SetDefaultColor(Color.magenta);

#End Code
 
Solution
More specifically, Im trying to code a horizontal line that is auto drawn across the an intraday chart when the price chart crates a candle wick instead of just an arrow at the bottom of the wick. Is it possible to code using horizontal lines instead of arrows? It would look similar to Robert's on researchtrade.com and on the "Fun with thinkscript" thread but instead of peaks and valleys, it would be candle wicks of a specific body type. (I do not own the rights to this picture)

I created a code the draws an arrow when a candle wick is created on the TOS chart. When ever a candle wick is generated on anytime frame, it creates an arrow at the bottom of the candle. I am sorry if my explanation was unclear. The wick tail setting I...
More specifically, Im trying to code a horizontal line that is auto drawn across the an intraday chart when the price chart crates a candle wick instead of just an arrow at the bottom of the wick. Is it possible to code using horizontal lines instead of arrows? It would look similar to Robert's on researchtrade.com and on the "Fun with thinkscript" thread but instead of peaks and valleys, it would be candle wicks of a specific body type. (I do not own the rights to this picture)

I created a code the draws an arrow when a candle wick is created on the TOS chart. When ever a candle wick is generated on anytime frame, it creates an arrow at the bottom of the candle. I am sorry if my explanation was unclear. The wick tail setting I have would be 1.5 times the body. I wanted to know if there is a line of code that creates a line extension across the chart from the wick candle signal to the right side of the chart to possibly create a future pridiction of possible inflection points.

gxXcPzh.png


Below is what I've been using that is the closet to what I was trying to describe.

#Start
input magnitude =30;

# define top and bottom of candle body
def bodytop = max(open, close);
def bodybottom = min(open, close);

# define and plot the most recent valley
def valley = bodybottom <= Lowest(bodybottom[1], magnitude) and bodybottom <= Lowest(bodybottom[-magnitude], magnitude);
def valleyValue = if BarNumber() < magnitude then Double.NaN else if valley then bodybottom else valleyValue[1];
plot valleyline = valleyValue;
valleyline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
valleyline.SetDefaultColor(Color.magenta);

# extend the current valley line to the right edge of the chart
def countt = if IsNaN(valley) and !IsNaN(valley[1]) then 1 else countt[1] + 1;
plot valleyext = if IsNaN(valley) then GetValue(valleyline, countt) else Double.NaN;
valleyext.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
valleyext.SetDefaultColor(Color.magenta);

# continue the previous valley as a dashed line, but not all the way to the far right of the screen :(
def oldvalley = if BarNumber() < magnitude then Double.NaN else if valley then valleyValue[1] else oldvalley[1];
plot oldvalleyline = oldvalley;
oldvalleyline.SetPaintingStrategy(PaintingStrategy.DASHES);
oldvalleyline.SetDefaultColor(Color.magenta);

#End Code

sorry, i am not sure what you are trying to do. you typed a lot of words talking about wicks and arrows but you never defined what condition you are looking for.
you mentioned a code that draws arrows, but didn't post it.
you mentioned a wick at some size compared to the body.

try starting over and just describe what condition(s) you want to look for.
then describe what you want to see on the chart.

a condition formula could be created that compares the wicks to the body.
that condition could be used to trigger a line to draw , from the trigger bar to the right to the last bar.
but, if you want more than one horizontal line, the study will have to have a plot and and supporting formulas , for each line.
 
Solution

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

sorry, i am not sure what you are trying to do. you typed a lot of words talking about wicks and arrows but you never defined what condition you are looking for.
you mentioned a code that draws arrows, but didn't post it.
you mentioned a wick at some size compared to the body.

try starting over and just describe what condition(s) you want to look for.
then describe what you want to see on the chart.

a condition formula could be created that compares the wicks to the body.
that condition could be used to trigger a line to draw , from the trigger bar to the right to the last bar.
but, if you want more than one horizontal line, the study will have to have a plot and and supporting formulas , for each line.
Hi Halcyonguy, do you have the codes for the chart shown above with the lines touching the high and low?
 
Hi Halcyonguy, do you have the codes for the chart shown above with the lines touching the high and low?
it's ok @MerryDay , i have read many of roberts posts and know where to find the code for the above image.

robert , peak valley horizontal lines

https://usethinkscript.com/threads/difference-between-two-zigzag-high-pivot-points.8460/#post-82340
Difference Between Two Zigzag High Pivot Points
post17
british43
Oct 14, 2021
halcyonguy
here is a link to a forum that robert payne hosted. this link should take you to a post that makes horz lines from peaks and valleys.
https://researchtrade.com/forum/read.php?7,2258,page=19

another link to the same post
https://researchtrade.com/forum/read.php?7,2258,4644#msg-4644

===========

updated version.
this adjusts the future length

https://usethinkscript.com/threads/peak-and-valley-indicator.901/#post-7935

robertpayne
The code you are basing your peaks / valleys on is from when I was first getting started. The way it is constructed works in the past, but results in a Double.NaN on the right edge of the charts. That is to say, it doesn't have a value on the most recent candle. That's why your scan isn't working.

I have since developed a better way of identifying swing highs / lows (peaks / valleys). Please see this example. It will work for you.

https://usethinkscript.com/threads/...ows-indefinitely-in-thinkorswim.930/post-7048
post10
ZigZag High Low with Supply & Demand Zones for ThinkorSwim
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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