• Get $30 off VIP with code SUMMER30. Ends July 27. Happy trading!

Awesome request for range lines indicator


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..

  • 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:


New member

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.

# 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;




New member
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.


New member
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.


New member
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.


New member
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.


New member
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.

Similar threads