# Price and Range Lines

#### abraham

##### New member
Hi Ben / @korygill , Talented Team,
• Line in the sand (LIS). I want an aqua colored line drawn using the closing price of the first 5 minute candle in after hours trading (the one from 16:00-16:05). Wherever this candle closes, a horizontal line is drawn in aqua that shows LIS and Price. Based on SHAK today, that line would be at 102.66. No matter what timeframe we move to I want this line to be permanent for the next trading day only. Each day a new line is generated and we don’t see any prior lines.
• For weekly range lines. I want to a yellow horizontal line drawn from Sunday to Saturday of the next week based on the following. For SHAK this week, the lines would be at 104.82 and 97.79 based on last weeks numbers.
(Prior weekly Range x 0.775) - Prior Range = X
X / 2 = Y
Prior Weekly High - Y = New upper weekly horizontal line
Prior weekly Low + Y = New lower Weekly horizontal line

Last weeks range was 9.07. The high was 105.84 and the low 96.77. So..

[(9.07x0.775)-9.07=2.04
2.04/2=1.02
105.84-1.02=104.82
96.77+1.02=97.79
• If we can figure this first one out, then the coding for the monthly lines will be easy. The multiplier for monthly is 0.784 and just referencing prior monthly ranges and high/lows. For SHAK, the lines would be at 97.82 and 75.52 based on last months numbers.
• (Prior Monthly Range x 0.784) - Prior Range = X
X / 2 = Y
Prior Monthly High - Y = New upper Monthly horizontal line in pink
• Prior Monthly Low + Y = New lower Monthly horizontal line in pink
• For yearly, The multiplier for Yearly is 0.774 and just referencing prior yearly ranges and high/lows. For SHAK, the lines would be at 64.99 and 41.71 based on last years numbers.

• (Prior Yearly Range x 0.774) - Prior Range = X
X / 2 = Y
Prior Yearly High - Y = New upper Yearly horizontal line in blue
• Prior Yearly Low + Y = New lower Yearly horizontal line in blue

Last edited:
Solution
Hello,

I'm assuming you want to replicate someones "proprietary" indicator. I actually know who you're referring to lol. Well I'm more than happy to assist you with this. Copy and paste the code below into a new indicator.

Now, I know my math is sound but your values that you stated for the yearly don't match up. So I'm not sure if the multiplier you mentioned is correct or not.

Code:
``````# Weekly Monthly & Yearly Range Lines
# Developed by MrFib - Twitter @PSenas03
# Last updated: 9/22/2019

input timeFrame = {default WEEK, MONTH, YEAR};
input showOnlyToday = no;

def H = high(period = timeFrame)[1];
def L = low(period = timeFrame)[1];

# Calculating range
def multiplier; # multiplier is a variable that changes based on timeframe input
if...``````
Hello,

I'm assuming you want to replicate someones "proprietary" indicator. I actually know who you're referring to lol. Well I'm more than happy to assist you with this. Copy and paste the code below into a new indicator.

Now, I know my math is sound but your values that you stated for the yearly don't match up. So I'm not sure if the multiplier you mentioned is correct or not.

Code:
``````# Weekly Monthly & Yearly Range Lines
# Developed by MrFib - Twitter @PSenas03
# Last updated: 9/22/2019

input timeFrame = {default WEEK, MONTH, YEAR};
input showOnlyToday = no;

def H = high(period = timeFrame)[1];
def L = low(period = timeFrame)[1];

# Calculating range
def multiplier; # multiplier is a variable that changes based on timeframe input
if timeFrame == timeframe.WEEK
then {
multiplier = 0.775;
}
else if timeframe == timeframe.MONTH
then {
multiplier = 0.784;
}
else {
multiplier = 0.774;
}

def range = H-L;
def X = range - range*multiplier;
def Y = X/2;

#resistance formula
def calc_R1 =  H - Y;

#support formula
def calc_S1 = L + Y;

plot R1;
plot S1;

if (showOnlyToday and !IsNaN(close(period = timeFrame)[-1])) or
(getAggregationPeriod() > if timeframe == timeframe.WEEK then AggregationPeriod.WEEK
else if timeframe == timeframe.MONTH
then AggregationPeriod.MONTH
else AggregationPeriod.YEAR)

then {

R1 = Double.NaN;

S1 = Double.NaN;

}
else {

R1 = calc_R1;

S1 = calc_S1;
}

R1.SetDefaultColor(color.yellow);
S1.SetDefaultColor(color.yellow);

R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````

Wow! You are the BEST my friend!! Thank you very much. So you inputted the values as is or did you correct the math? I just imported and still reviewing it.

I left the values as is. I was too lazy to do the math lol simple enough to figure out though. I wasn't sure if the pivot values were mistyped or the multiplier. I'll leave that for you to figure out. As for the indicator, I built it just for one range to overlay. If you want all 3 then just put it on the chart 3x and change the aggregation period for each one.

How do you use this info?

I didn't make the LIS yet, its simple enough though. I'll get to it when I have time. @abraham

@Shrum I reversed engineered an indicator made from a specific trade group. TBH I'm not sure how they use it. I would assume you would use it as pivot levels based on the weekly, monthly, and yearly range values.

Wow again @MrFib You certainly have the TOS coding skills!! Thank you very much. This is in addition to other indicators and used as a pivot levels based on the weekly, monthly, and yearly range values as you rightly pointed out. Incredible and talented members we have here.

@abraham hey bud, im curious if you know the conditions required for their bars painting strategy. Like what conditions make their bars green/white/red. How about their PMZ?

Hi Again! Happy to hear from you. Actually I am not 100% sure. Based on your experience can you provide any suggestions? I see so many choices and options provided by different traders (looks like they all work fine for their "own" strategy). I was thinking in terms of FIB levels and Kelt ranges. Appreciate it.

Hello,

I'm assuming you want to replicate someones "proprietary" indicator. I actually know who you're referring to lol. Well I'm more than happy to assist you with this. Copy and paste the code below into a new indicator.

Now, I know my math is sound but your values that you stated for the yearly don't match up. So I'm not sure if the multiplier you mentioned is correct or not.

Code:
``````# Weekly Monthly & Yearly Range Lines
# Developed by MrFib - Twitter @PSenas03
# Last updated: 9/22/2019

input timeFrame = {default WEEK, MONTH, YEAR};
input showOnlyToday = no;

def H = high(period = timeFrame)[1];
def L = low(period = timeFrame)[1];

# Calculating range
def multiplier; # multiplier is a variable that changes based on timeframe input
if timeFrame == timeframe.WEEK
then {
multiplier = 0.775;
}
else if timeframe == timeframe.MONTH
then {
multiplier = 0.784;
}
else {
multiplier = 0.774;
}

def range = H-L;
def X = range - range*multiplier;
def Y = X/2;

#resistance formula
def calc_R1 =  H - Y;

#support formula
def calc_S1 = L + Y;

plot R1;
plot S1;

if (showOnlyToday and !IsNaN(close(period = timeFrame)[-1])) or
(getAggregationPeriod() > if timeframe == timeframe.WEEK then AggregationPeriod.WEEK
else if timeframe == timeframe.MONTH
then AggregationPeriod.MONTH
else AggregationPeriod.YEAR)

then {

R1 = Double.NaN;

S1 = Double.NaN;

}
else {

R1 = calc_R1;

S1 = calc_S1;
}

R1.SetDefaultColor(color.yellow);
S1.SetDefaultColor(color.yellow);

R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);``````
awesome how can this be done to have a label calculate in \$ amount the range between th hi and low of the 5 min opening range.... as a label

Awesome @Nari2007 . Can we have LIS defined as previous day low, week low, and monthly low so that we can choose one of the options?

Awesome @Nari2007 . Can we have LIS defined as previous day low, week low, and monthly low so that we can choose one of the options?
not sure, i just want a label that shows the RANGE in dollar amount using the ORB strategy,

I would like to create an indicator that can plot the following ranges in a mutli time frame capability: 1. Calculate the individual ranges of the last X periods (default=14); 2. Add the 14 ranges together and divide by 14 obtain the 14 day avg range; 3. Divide this 14 period avg. range by 2; 4. Add this result to the close (or gap open); 5. Subtract this result from the same close; So on a daily chart I would like to plot the daily, weekly, and monthly ranges simultaneously.

Last edited by a moderator:
I would like to create an indicator that can plot the following ranges in a mutli time frame capability: 1. Calculate the individual ranges of the last X periods (default=14); 2. Add the 14 ranges together and divide by 14 obtain the 14 day avg range; 3. Divide this 14 period avg. range by 2; 4. Add this result to the close (or gap open); 5. Subtract this result from the same close; So on a daily chart I would like to plot the daily, weekly, and monthly ranges simultaneously.
You might be able to modify this code to do what you want:

that gets close but it doesnt calculate the 14 period average True Range as the True Range calculation . Thanks very much....its goes a long way to getting there.

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