NexusFi: Find Your Edge


Home Menu

 





Mark a candle which is above 30% of the average length


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,230 views
    2. thumb_up 1 thanks given
    3. group 2 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread

Mark a candle which is above 30% of the average length

  #1 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1

Hi
Could anyone help me with a thinkorswim script that marks a candle with a number that shows its candle size (high to low) if its above 30% of the average candle size length of the time frame I'm in? So if I'm in a 1min 3 days, its shows marks only the candles with length of the ones that are 30% longer (high to low) than the average length, if I chance it to 10 days, 5min, same thing.

I want a yellow box with the candle length like its in this thread (this tread shows the price, I want the length of the candle)
See the post in this forum called: Candlestick Size Indicator Improved

Also if its possible to have a text box and the bottom showing what the average candle length is, that would be great!

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Cheap historycal L1 data for stocks
Stocks and ETFs
Trade idea based off three indicators.
Traders Hideout
Quant vue
Trading Reviews and Vendors
REcommedations for programming help
Sierra Chart
 
  #2 (permalink)
VanDriver
Jackson, MS
 
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5

Candle size is range. Average candle size is the average range of a specific number of prior candles. How many candles do use in the average you are requesting (14, 20, 50, etc.)?

Reply With Quote
  #3 (permalink)
thinkorn00b
stavanger
 
Posts: 19 since Sep 2020
Thanks Given: 1
Thanks Received: 1


Is it possible to chose that is use the current timeframe that I use the chart? Like it takes the range for 10 days if Im on a 10 days timerframe and then 3 days range if I use a 3 days time frame? If not, then 60 candles would ne nice since I use 1min

Reply With Quote
  #4 (permalink)
VanDriver
Jackson, MS
 
Posts: 34 since Dec 2015
Thanks Given: 1
Thanks Received: 5

Hello, enjoy the scripts. I have created an upper and lower study for you to use. Your criteria is listed by default and must use a defined average length and percent, but has inputs for you to modify them. There is a way to make them plot using all the bars on the chart but that requires more time than I have.

This study will mark the candles whose range expands > 30% of the N value average range. This examines average range (high - low), not ATR, and excludes the current candle to ensure the average range is anchored. The current bar is not included with the average range so that the average range does not change while the current bar is forming its range.

By default the upper study shows the labels with expansion %, average range, and current bar range, and the dots above the bars that are outside the range %. Both can be turned off to avoid hiding candles. I created a lower study to keep your price chart clean and help you visualize the range compared to the average range. Certain elements can be turned off on it as well. Copy and paste the following scripts into your platform. I have attached an image to show how these look as of the time I post them.

UPPER STUDY
# Begin script

#VanDriver @ Futures.io on Sept 22, 2020.
# Request: mark candle range whose range expands > 30% of the N value average range. This examines average range, not ATR, and excludes the current candle to ensure the average range is anchored. This is the upper study that goes with the lower.


input Bubbles = yes;
input dots = yes;
input length = 60;
input percent = 30;
def ph = high[1];
def pl = low[1];
def range = high - low;
def avgrange = Sum(ph - pl, length) / length ;
def rangeX = range >= avgrange * (1 + percent /100);
def avgrp = (avgrange - range) / avgrange * -1;
def na = double.nan;

Plot Dot = if dots and rangeX then high else na;
dot.setdefaultColor(color.yellow);
dot.setpaintingStrategy(PaintingStrategy.TRIANGLES);
dot.HideBubble();
dot.hideTitle();
dot.setLineWeight(3);


AddChartBubble(bubbles and rangeX, high, text = "Stretch " + AsPercent(avgrp) + "\n AvgRange " + Round((avgrange), 2) + "\n Range Size " + Round((range), 2), Color.light_gray);

# end script

---
LOWER STUDY

# Begin script

#VanDriver @ Futures.io on Sept 22, 2020.
# Request: mark candle range whose range expands > 30% of the N value average range. This examines average range, not ATR, and excludes the current candle to ensure the average range is anchored. This is the lower study and requires the upper to see plots on the candles.

declare lower;
input Bubbles = yes;
input length = 60;
input percent = 30;
def ph = high[1];
def pl = low[1];
plot range = high - low;
def avgrange = Sum(ph - pl, length) / length ;
def rangeX = range >= avgrange * (1 + percent /100);
def avgrp = (avgrange - range) / avgrange * -1;

plot UpperBand = avgrange * (1 + percent / 100);
UpperBand.SetDefaultColor(color.magenta);
range.setdefaultColor(color.dark_green);
range.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);

AddChartBubble(bubbles and rangeX, range, text = "Stretch " + AsPercent(avgrp) + "\n AvgRange " + Round((avgrange), 2) + "\n Range Size " + Round((range), 2), Color.light_gray);
# end script

Attached Thumbnails
Click image for larger version

Name:	range.png
Views:	408
Size:	47.8 KB
ID:	305228  
Reply With Quote
Thanked by:




Last Updated on September 23, 2020


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts