Alternate Normalization Study (Not Complex) For ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
Alternate normalization study, not complex

EDIT ------------
the new study assumes there are less than 1000 bars on the chart. if it has more, then the 2 instances of this,
def barsBack = 1000;
will have to be adjusted. (each in a sub script)


I was looking for a normalization script to use in a project and was looking at various studies.
the studies I found, used highestall() and lowestall() on every bar, and were complex.

I recently found a post that listed a study by mobius, for a different way to make a priceline. thank you @Pensar for posting it.
https://usethinkscript.com/threads/current-price-line-indicator-for-thinkorswim.8793/
I ended up modifying it to find a lowest low. post #9

I went back to the normalization studies and combined it with the above and came up with the second study below, what I am calling the alternate method.
it does not use highestall() or lowestall().
it is not complex.
it finds the highest and lowest numbers only on barnumber 1, then reuses them for the remaining bars.


the first study is what I am calling a standard normalization study.
the second study is my modified version.

=========================================================

example of standard normalize code
https://usethinkscript.com/threads/how-to-compare-stock-charts-in-thinkorswim.1249/page-2#post-53385
post 35


it scales a set of numbers (prices) to be within a new range of numbers.
it uses highestall() and lowestall(), on every bar
it is complex

Ruby:
# normalize_std_00
#https://usethinkscript.com/threads/how-to-compare-stock-charts-in-thinkorswim.1249/page-2#post-53385
#post 35
declare lower;

script normalizePlot {
  input data = close;
#  input newRngMin = -1;
#  input newRngMax = 1;
  input newRngMin = 0;
  input newRngMax = 100;
  def HHData = HighestAll( data );
  def LLData = LowestAll( data );
  plot nr = ((( newRngMax - newRngMin ) * ( data - LLData )) / ( HHData - LLData )) + newRngMin;
}

plot z = normalizePlot();
z.SetStyle(Curve.MEDIUM_DASH);
z.SetDefaultColor(Color.yellow);
z.setlineweight(1);
z.hidebubble();
#


=========================================================

alternate code

it scales a set of numbers (prices) to be within a new range of numbers.
it uses a large negative offset, to create a variable that has the highest high value, set in every bar. similar to a priceline study. same is done for lowest low.
it does not use highestall() or lowestall()
it is not complex


Ruby:
# normalize_alt_00_cln

#-------------------------
# halcyonguy
# 21-11-28
# rescale a data set
# create normalize formulas without highestall(), lowestall()
#-------------------------

# ref
# https://usethinkscript.com/threads/current-price-line-indicator-for-thinkorswim.8793/
#  Line At Price   Mobius
#input barsBack = 1000;
#def c = if !IsNaN(close) and IsNaN(close[-1])
#        then close
#        else c[1];
#plot line = if isNaN(close[-barsBack])
#            then c[-barsBack]
#            else Double.NaN;
# ------------------------------------------------------


# if bar 1 then
# .. find the highest and lowest price levels on the chart.
# .. calculate a scaled price.
# else (if not the first bar)
# .. use the previous highest and lowest price levels to calculate a scaled price.

declare lower;

#-----------------------------------------
#   find highest high
#-----------------------------------------
script hi_level {
def barsBack = 1000;
def high1 = if barnumber() == 1 then high else if high > high1[1] then high else high1[1];
def high2 = if !IsNaN(close) and IsNaN(close[-1]) then high1 else high2[1];
def highline = if isNaN(close[-barsBack]) then high2[-barsBack] else Double.NaN;
plot zh = highline;
}


#-----------------------------------------
#  find lowest low
#-----------------------------------------
script lo_level {
def barsBack = 1000;
def low1 = if barnumber() == 1 then low else if low < low1[1] then low else low1[1];
def low2 = if !IsNaN(close) and IsNaN(close[-1]) then low1 else low2[1];
def lowline = if isNaN(close[-barsBack]) then low2[-barsBack] else Double.NaN;
plot zl = lowline;
}


#-----------------------------------------
#  normalize
#-----------------------------------------
# start with a copy of code from post #1 https://usethinkscript.com/threads/how-to-plot-a-study-as-a-normalized-index-that-has-0-100-values-e-g-like-moneyflowindex.4289/
# plot a study as a normalized index that has 0-100% values   lmk99

script normalizePlot {
input hi = 0;
input lo = 0;
input data = close;
input RngMin = 0;
input RngMax = 100;

def en = if (hi == 0 or lo == 0 ) then 0 else 1;
# if en , then calc stuff
plot nr = if !en then double.nan else ((( RngMax - RngMin ) * ( data - lo )) / ( hi - lo )) + RngMin;
}


#-----------------------------------------
# main section
#-----------------------------------------
def bn = barnumber();
def na = double.nan;
# find the highest and lowest levels of original data

def hi;
def lo;
def nz;
if bn == 1 then {
  # call sub scripts to find highest and lowest prices on chart
  hi = hi_level();
  lo = lo_level();
  # rescale the close
  # normalizePlot( data hi, data lo, price (default is close), new Rng Min (default 0), new Rng Max (default 100) )
  nz = normalizePlot( hi, lo, close);
} else {
  hi = hi[1];
  lo = lo[1];
  nz = normalizePlot( hi, lo, close);
}

#-----------------------
# plot normalized line
plot nz2 = nz;

# plot the highest and lowest levels of original data
input plot_highest_lowest_lines = no;
plot zhi = if plot_highest_lowest_lines then hi else na;
plot zlo = if plot_highest_lowest_lines then lo else na;

addlabel(1, "Original data, Highest: " + hi + " , Lowest: " + lo, color.yellow);
#

=========================================================

compare the standard method and this alternative method. the lines are the same.
gph5NZC.jpg

hal_norm
 
Last edited:
Alternate normalization study, not complex

I was looking for a normalization script to use in a project and was looking at various studies.
the studies I found, used highestall() and lowestall() on every bar, and were complex.

I recently found a post that listed a study by mobius, for a different way to make a priceline. thank you @Pensar for posting it.
https://usethinkscript.com/threads/current-price-line-indicator-for-thinkorswim.8793/
I ended up modifying it to find a lowest low. post #9

I went back to the normalization studies and combined it with the above and came up with the second study below, what I am calling the alternate method.
it does not use highestall() or lowestall().
it is not complex.
it finds the highest and lowest numbers only on barnumber 1, then reuses them for the remaining bars.

Thanks so much for this. I'd like to confirm that I understand the syntax for converting existing scripts to use this code. There are three instances where conversion would be needed:

1) Replace "HighestAll"
2) Replace "LowestAll"
3) Replace old "script normalizePlot"

I realize this is probably very obvious for many of us but I'd like to make sure I'm not confused.

First, for cases (1) and (2), I'll use a real example of the code for the Auto-Fibonacci indicator. This is the section of the code that uses "HighestAll" and "LowestAll":

Code:
def n1  = n + 1;
def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

With your alternate code, my understanding is that I would first paste the entirety of these two sections into the Auto-Fibonacci script:

Code:
#-----------------------------------------
#   find highest high
#-----------------------------------------
script hi_level {
def barsBack = 1000;
def high1 = if barnumber() == 1 then high else if high > high1[1] then high else high1[1];
def high2 = if !IsNaN(close) and IsNaN(close[-1]) then high1 else high2[1];
def highline = if isNaN(close[-barsBack]) then high2[-barsBack] else Double.NaN;
plot zh = highline;
}


#-----------------------------------------
#  find lowest low
#-----------------------------------------
script lo_level {
def barsBack = 1000;
def low1 = if barnumber() == 1 then low else if low < low1[1] then low else low1[1];
def low2 = if !IsNaN(close) and IsNaN(close[-1]) then low1 else low2[1];
def lowline = if isNaN(close[-barsBack]) then low2[-barsBack] else Double.NaN;
plot zl = lowline;
}

Then, I would make the following modifications to the section of the Auto-Fibonacci code that uses HighestAll and LowestAll:

Code:
def n1  = n + 1;
def a = hi_level(high);
def b = lo_level(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = hi_level(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = lo_level(lownumber);

Is this all I'd have to do to convert this script correctly?

OK, moving on now for case (3), of replacing the old method of "normalizePlot," I will use the real example of a normalized Cumulative Volume Delta from this post:

Code:
script normalizePlot {
    input data = close;
    input newRngMin =  -1;
    input newRngMax = 1;
    def hhData = HighestAll( data );
    def llData = LowestAll( data );
    plot nr = ((( newRngMax - newRngMin ) * ( data - llData )) / ( hhData - llData )) + newRngMin;
}

input CVDlength = 10;
input CMFlength = 21;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
def Delt = buying - selling;

plot Delta = normalizePlot(Delt, -0.4, 0.4);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.hide();

plot zero = 0;
Zero.SetDefaultColor(GetColor(5));

plot CumulativeVolumeDelta = normalizePlot(sum(Delta,CVDlength), -0.4, 0.4);
CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

To replace that with your alternate method, I understand that I must first delete the bracketed script "normalizePlot" in the above code and replace it with the following in its entirety (i.e. all four subsections with the headers "find highest high", "find lowest low", "normalize", and "main section"):

Code:
#-----------------------------------------
#   find highest high
#-----------------------------------------
script hi_level {
def barsBack = 1000;
def high1 = if barnumber() == 1 then high else if high > high1[1] then high else high1[1];
def high2 = if !IsNaN(close) and IsNaN(close[-1]) then high1 else high2[1];
def highline = if isNaN(close[-barsBack]) then high2[-barsBack] else Double.NaN;
plot zh = highline;
}


#-----------------------------------------
#  find lowest low
#-----------------------------------------
script lo_level {
def barsBack = 1000;
def low1 = if barnumber() == 1 then low else if low < low1[1] then low else low1[1];
def low2 = if !IsNaN(close) and IsNaN(close[-1]) then low1 else low2[1];
def lowline = if isNaN(close[-barsBack]) then low2[-barsBack] else Double.NaN;
plot zl = lowline;
}


#-----------------------------------------
#  normalize
#-----------------------------------------
# start with a copy of code from post #1 https://usethinkscript.com/threads/how-to-plot-a-study-as-a-normalized-index-that-has-0-100-values-e-g-like-moneyflowindex.4289/
# plot a study as a normalized index that has 0-100% values   lmk99

script normalizePlot {
input hi = 0;
input lo = 0;
input data = close;
input RngMin = 0;
input RngMax = 100;

def en = if (hi == 0 or lo == 0 ) then 0 else 1;
# if en , then calc stuff
plot nr = if !en then double.nan else ((( RngMax - RngMin ) * ( data - lo )) / ( hi - lo )) + RngMin;
}


#-----------------------------------------
# main section
#-----------------------------------------
def bn = barnumber();
def na = double.nan;
# find the highest and lowest levels of original data

def hi;
def lo;
def nz;
if bn == 1 then {
  # call sub scripts to find highest and lowest prices on chart
  hi = hi_level();
  lo = lo_level();
  # rescale the close
  # normalizePlot( data hi, data lo, price (default is close), new Rng Min (default 0), new Rng Max (default 100) )
  nz = normalizePlot( hi, lo, close);
} else {
  hi = hi[1];
  lo = lo[1];
  nz = normalizePlot( hi, lo, close);
}

But then, for the normalized Cumulative Volume Delta code, I don't understand how I would need to update the code to update/replace "normalizePlot(Delt, -0.4, 0.4)" and "normalizePlot(sum(Delta,CVDlength), -0.4, 0.4)":

Code:
plot Delta = normalizePlot(Delt, -0.4, 0.4);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.hide();

plot zero = 0;
Zero.SetDefaultColor(GetColor(5));

plot CumulativeVolumeDelta = normalizePlot(sum(Delta,CVDlength), -0.4, 0.4);
CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

I can't just use the normalization script under the "normalize" section header, right, because that does not call the subscripts for highest high and lowest low and those are needed? But the code under the "main section" header doesn't appear to be a named script that can be referenced with one word (such as "newnormalizationScript", in which case for the above Cumulative Volume Delta script we could just write "newnormalizationScript(Delt, -0.4,0.4)" to replace "normalizePlot").

Sorry for being a bit dense, can you clarify if my understanding for how to replace "HighestAll" and "LowestAll" as described earlier in this post is already correct, but then also, what would be the correct way to replace the old "normalizePlot" code with your new alternative?
 
Thanks so much for this. I'd like to confirm that I understand the syntax for converting existing scripts to use this code. There are three instances where conversion would be needed:

1) Replace "HighestAll"
2) Replace "LowestAll"
3) Replace old "script normalizePlot"

I realize this is probably very obvious for many of us but I'd like to make sure I'm not confused.

First, for cases (1) and (2), I'll use a real example of the code for the Auto-Fibonacci indicator. This is the section of the code that uses "HighestAll" and "LowestAll":

Code:
def n1  = n + 1;
def a = HighestAll(high);
def b = LowestAll(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = HighestAll(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = LowestAll(lownumber);

With your alternate code, my understanding is that I would first paste the entirety of these two sections into the Auto-Fibonacci script:

Code:
#-----------------------------------------
#   find highest high
#-----------------------------------------
script hi_level {
def barsBack = 1000;
def high1 = if barnumber() == 1 then high else if high > high1[1] then high else high1[1];
def high2 = if !IsNaN(close) and IsNaN(close[-1]) then high1 else high2[1];
def highline = if isNaN(close[-barsBack]) then high2[-barsBack] else Double.NaN;
plot zh = highline;
}


#-----------------------------------------
#  find lowest low
#-----------------------------------------
script lo_level {
def barsBack = 1000;
def low1 = if barnumber() == 1 then low else if low < low1[1] then low else low1[1];
def low2 = if !IsNaN(close) and IsNaN(close[-1]) then low1 else low2[1];
def lowline = if isNaN(close[-barsBack]) then low2[-barsBack] else Double.NaN;
plot zl = lowline;
}

Then, I would make the following modifications to the section of the Auto-Fibonacci code that uses HighestAll and LowestAll:

Code:
def n1  = n + 1;
def a = hi_level(high);
def b = lo_level(low);
def barnumber = barNumber();
def c = if high == a then barnumber else double.nan;
def d = if low == b then barnumber else double.nan;
rec highnumber = compoundValue(1, if IsNaN(c) then highnumber[1] else c, c);
def highnumberall = hi_level(highnumber);
rec lownumber = compoundValue(1, if IsNaN(d) then lownumber[1] else d, d);
def lownumberall = lo_level(lownumber);

Is this all I'd have to do to convert this script correctly?

OK, moving on now for case (3), of replacing the old method of "normalizePlot," I will use the real example of a normalized Cumulative Volume Delta from this post:

Code:
script normalizePlot {
    input data = close;
    input newRngMin =  -1;
    input newRngMax = 1;
    def hhData = HighestAll( data );
    def llData = LowestAll( data );
    plot nr = ((( newRngMax - newRngMin ) * ( data - llData )) / ( hhData - llData )) + newRngMin;
}

input CVDlength = 10;
input CMFlength = 21;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);
def Delt = buying - selling;

plot Delta = normalizePlot(Delt, -0.4, 0.4);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.hide();

plot zero = 0;
Zero.SetDefaultColor(GetColor(5));

plot CumulativeVolumeDelta = normalizePlot(sum(Delta,CVDlength), -0.4, 0.4);
CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

To replace that with your alternate method, I understand that I must first delete the bracketed script "normalizePlot" in the above code and replace it with the following in its entirety (i.e. all four subsections with the headers "find highest high", "find lowest low", "normalize", and "main section"):

Code:
#-----------------------------------------
#   find highest high
#-----------------------------------------
script hi_level {
def barsBack = 1000;
def high1 = if barnumber() == 1 then high else if high > high1[1] then high else high1[1];
def high2 = if !IsNaN(close) and IsNaN(close[-1]) then high1 else high2[1];
def highline = if isNaN(close[-barsBack]) then high2[-barsBack] else Double.NaN;
plot zh = highline;
}


#-----------------------------------------
#  find lowest low
#-----------------------------------------
script lo_level {
def barsBack = 1000;
def low1 = if barnumber() == 1 then low else if low < low1[1] then low else low1[1];
def low2 = if !IsNaN(close) and IsNaN(close[-1]) then low1 else low2[1];
def lowline = if isNaN(close[-barsBack]) then low2[-barsBack] else Double.NaN;
plot zl = lowline;
}


#-----------------------------------------
#  normalize
#-----------------------------------------
# start with a copy of code from post #1 https://usethinkscript.com/threads/how-to-plot-a-study-as-a-normalized-index-that-has-0-100-values-e-g-like-moneyflowindex.4289/
# plot a study as a normalized index that has 0-100% values   lmk99

script normalizePlot {
input hi = 0;
input lo = 0;
input data = close;
input RngMin = 0;
input RngMax = 100;

def en = if (hi == 0 or lo == 0 ) then 0 else 1;
# if en , then calc stuff
plot nr = if !en then double.nan else ((( RngMax - RngMin ) * ( data - lo )) / ( hi - lo )) + RngMin;
}


#-----------------------------------------
# main section
#-----------------------------------------
def bn = barnumber();
def na = double.nan;
# find the highest and lowest levels of original data

def hi;
def lo;
def nz;
if bn == 1 then {
  # call sub scripts to find highest and lowest prices on chart
  hi = hi_level();
  lo = lo_level();
  # rescale the close
  # normalizePlot( data hi, data lo, price (default is close), new Rng Min (default 0), new Rng Max (default 100) )
  nz = normalizePlot( hi, lo, close);
} else {
  hi = hi[1];
  lo = lo[1];
  nz = normalizePlot( hi, lo, close);
}

But then, for the normalized Cumulative Volume Delta code, I don't understand how I would need to update the code to update/replace "normalizePlot(Delt, -0.4, 0.4)" and "normalizePlot(sum(Delta,CVDlength), -0.4, 0.4)":

Code:
plot Delta = normalizePlot(Delt, -0.4, 0.4);
Delta.AssignValueColor(if Delta > 0 then Color.GREEN else Color.RED);
Delta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Delta.hide();

plot zero = 0;
Zero.SetDefaultColor(GetColor(5));

plot CumulativeVolumeDelta = normalizePlot(sum(Delta,CVDlength), -0.4, 0.4);
CumulativeVolumeDelta.AssignValueColor(if CumulativeVolumeDelta > 0 then Color.GREEN else Color.RED);
CumulativeVolumeDelta.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

I can't just use the normalization script under the "normalize" section header, right, because that does not call the subscripts for highest high and lowest low and those are needed? But the code under the "main section" header doesn't appear to be a named script that can be referenced with one word (such as "newnormalizationScript", in which case for the above Cumulative Volume Delta script we could just write "newnormalizationScript(Delt, -0.4,0.4)" to replace "normalizePlot").

Sorry for being a bit dense, can you clarify if my understanding for how to replace "HighestAll" and "LowestAll" as described earlier in this post is already correct, but then also, what would be the correct way to replace the old "normalizePlot" code with your new alternative?
i will look this over and get back to you.
 
i will look this over and get back to you.

Thanks! I am pretty sure that for replacing "HighestAll" and "LowestAll" it's self-explanatory and I've already got it right, but the part that is really unclear for me is replacing instances of the old "script normalizePlot" in existing studies. Looking forward to your feedback!
 
i will look this over and get back to you.

Hey I appreciate your offer to look at this and I'm happy to wait until you've had time to spare. However, I thought that a better simplification of my main question is, can the alternate normalization code that you created be "containerized" in " { } " so that to normalize, we can just replace the old "script normalizePlot(.....)" with "script "halcyonguynormalizePlot(...)"? I couldn't see a straightforward way to just make a substitution of the old version with your new version in existing studies that are using the old version. I'm still really interested to hear if there's a simple answer.
 
Hey I appreciate your offer to look at this and I'm happy to wait until you've had time to spare. However, I thought that a better simplification of my main question is, can the alternate normalization code that you created be "containerized" in " { } " so that to normalize, we can just replace the old "script normalizePlot(.....)" with "script "halcyonguynormalizePlot(...)"? I couldn't see a straightforward way to just make a substitution of the old version with your new version in existing studies that are using the old version. I'm still really interested to hear if there's a simple answer.
take a look at this mod i did, to normalize ttm squeeze
https://usethinkscript.com/threads/turning-ttm-squeeze-bars-into-a-line.9194/#post-84794

sorry i haven't got back to your questions. i hope to on tuesday.
 
I'm trying to make a watchlist indicator that shows where price is relative to its all time high and all time low using normalized values between 0-100 and, if applicable, using log prices. Essentially, I want to see where the price is relative to its total range as a normalized rating. I.e. a stock near its highs would have a score of 90+, whereas a stock sitting at the middle of its range would have a score of 50.

I only worked up the following so far but have no idea if I'm even on the right track. Any pointers would be appreciated.


input aggregationPeriod = AggregationPeriod.WEEK;

def ATH = Highest(high(period = "WEEK"), 2000);
def ATL = Lowest(low(period = "WEEK"), 2000);
def range = (ATH - ATL);
def price = close - ATL;
def position = Log(price / range);
 
I'm trying to make a watchlist indicator that shows where price is relative to its all time high and all time low using normalized values between 0-100 and, if applicable, using log prices. Essentially, I want to see where the price is relative to its total range as a normalized rating. I.e. a stock near its highs would have a score of 90+, whereas a stock sitting at the middle of its range would have a score of 50.
Moved your post here... Should give you direction
 
I'm trying to make a watchlist indicator that shows where price is relative to its all time high and all time low using normalized values between 0-100 and, if applicable, using log prices. Essentially, I want to see where the price is relative to its total range as a normalized rating. I.e. a stock near its highs would have a score of 90+, whereas a stock sitting at the middle of its range would have a score of 50.

I only worked up the following so far but have no idea if I'm even on the right track. Any pointers would be appreciated.


input aggregationPeriod = AggregationPeriod.WEEK;

def ATH = Highest(high(period = "WEEK"), 2000);
def ATL = Lowest(low(period = "WEEK"), 2000);
def range = (ATH - ATL);
def price = close - ATL;
def position = Log(price / range);
2000 weeks is 38 years. i don't think you can read that much history data on a chart.
for a column i think you are limited to 1 or 2 years?

i copied your code and added a plot.
with some experimenting on a chart, with KO on a max year week chart,
i picked KO because it IPO'd in 1919.
with length = 500 , data is plotted back to 2001 (21 years)
with length = 1000 , data is plotted back to 2004
with length = 1800 , data is plotted back to 2019

not sure why you want to use log. ( i haven't used log in a log time)

--------------------------
sorry, @lmk99 i forgot to get back to this thread.
i will look at it next week.
 

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