# Range Extension of Previous Day Range
# tomsk
# 1.11.2020
# This study plots the 25% and 50% extension of the previous day's range
# To be used on intraday charts only
declare hide_on_daily;
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
# End Range Extension of Previous Day Range
perfect thank you, is it possible to add the previous day's midpoint?
# Range Extension of Previous Day Range
# tomsk
# 1.11.2020
# V1.0 - 01.11.2020 - tomsk - Range Extension of Previous Day Range
# V1.1 - 01.11.2020 - tomsk - Added plot of previous day range midpoint
# This study plots the 25% and 50% extension of the previous day's range
# To be used on intraday charts only
declare hide_on_daily;
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
plot PrevMid = prevLow + (prevRange / 2);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
PrevMid.SetDefaultColor(Color.Yellow);
PrevMid.SetStyle(Curve.Short_Dash);
PrevMid.SetLineWeight(3);
# End Range Extension of Previous Day Range
perfect, if I wanted to use that on a higher time frame like the weekly, what would I have to adjust in the code would it be simple?
# Range Extension of Previous Week Range
# tomsk
# 1.11.2020
# This study plots the 25% and 50% extension of the previous week's range
# To be used on intraday charts only
declare hide_on_daily;
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Week)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Week)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
plot PrevMid = prevLow + (prevRange / 2);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
PrevMid.SetDefaultColor(Color.Yellow);
PrevMid.SetStyle(Curve.Short_Dash);
PrevMid.SetLineWeight(3);
# End Range Extension of Previous Week Range
@tomsk thanks for taking the time and doing this, cheers mate!
I gave it a shot to add a label but I can tell I'm way off, this is what I have (addchartBubble price location" = PrevHigh, text = "+25% Ext " color = Color.White); Zero coding ability
# Range Extension of Previous Day Range
# tomsk
# 1.11.2020
# V1.0 - 01.11.2020 - tomsk - Range Extension of Previous Day Range
# V1.1 - 01.11.2020 - tomsk - Added plot of previous day range midpoint
# V1.2 - 01.11.2020 - tomsk - Added chart bubbles to identify all plot lines
# This study plots the 25% and 50% extension of the previous day's range
# To be used on intraday charts only
declare hide_on_daily;
input n = 3;
def bar = barNumber();
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
plot PrevMid = prevLow + (prevRange / 2);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
PrevMid.SetDefaultColor(Color.Yellow);
PrevMid.SetStyle(Curve.Short_Dash);
PrevMid.SetLineWeight(3);
def lastBar = if isNaN(close[-1]) and !isNaN(close) then bar else lastBar[1];
def UExt25Loc = if isNaN(close[-1]) and !isNaN(close) then UExt25 else UExt25Loc[1];
def UExt50Loc = if isNaN(close[-1]) and !isNaN(close) then UExt50 else UExt50Loc[1];
def PrevMidLoc = if isNaN(close[-1]) and !isNaN(close) then PrevMid else PrevMidLoc[1];
def LExt25Loc = if isNaN(close[-1]) and !isNaN(close) then LExt25 else LExt25Loc[1];
def LExt50Loc = if isNaN(close[-1]) and !isNaN(close) then LExt50 else LExt50Loc[1];
addChartBubble(bar == HighestAll(lastBar+n), UExt25Loc, "Upper 25%", UExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), UExt50Loc, "Upper 50%", UExt50.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), PrevMidLoc, "Prev Mid", PrevMid.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt25Loc, "Lower 25%", LExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt50Loc, "Lower 50%", LExt50.TakeValueColor());
# End Range Extension of Previous Day Range
I was way off, thanks@Trading51 Adding chart bubbles is a bit more involved than that. Since you asked, here then is Version 1.2 of the Range Extension of Previous Day Range study COMPLETE with chart bubbles added to all 5 plots. Have at it ...
Code:# Range Extension of Previous Day Range # tomsk # 1.11.2020 # V1.0 - 01.11.2020 - tomsk - Range Extension of Previous Day Range # V1.1 - 01.11.2020 - tomsk - Added plot of previous day range midpoint # V1.2 - 01.11.2020 - tomsk - Added chart bubbles to identify all plot lines # This study plots the 25% and 50% extension of the previous day's range # To be used on intraday charts only declare hide_on_daily; input n = 3; def bar = barNumber(); def CurrentDay = GetDay() == GetLastDay(); def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN; def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN; def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN; plot UExt25 = prevHigh + (prevRange * 0.25); plot UExt50 = prevHigh + (prevRange * 0.50); plot LExt25 = prevLow - (prevRange * 0.25); plot LExt50 = prevLow - (prevRange * 0.50); plot PrevMid = prevLow + (prevRange / 2); UExt25.SetDefaultColor(Color.Cyan); UExt50.SetDefaultColor(Color.Pink); LExt25.SetDefaultColor(Color.White); LExt50.SetDefaultColor(Color.Green); PrevMid.SetDefaultColor(Color.Yellow); PrevMid.SetStyle(Curve.Short_Dash); PrevMid.SetLineWeight(3); def lastBar = if isNaN(close[-1]) and !isNaN(close) then bar else lastBar[1]; def UExt25Loc = if isNaN(close[-1]) and !isNaN(close) then UExt25 else UExt25Loc[1]; def UExt50Loc = if isNaN(close[-1]) and !isNaN(close) then UExt50 else UExt50Loc[1]; def PrevMidLoc = if isNaN(close[-1]) and !isNaN(close) then PrevMid else PrevMidLoc[1]; def LExt25Loc = if isNaN(close[-1]) and !isNaN(close) then LExt25 else LExt25Loc[1]; def LExt50Loc = if isNaN(close[-1]) and !isNaN(close) then LExt50 else LExt50Loc[1]; addChartBubble(bar == HighestAll(lastBar+n), UExt25Loc, "Upper 25%", UExt25.TakeValueColor()); addChartBubble(bar == HighestAll(lastBar+n), UExt50Loc, "Upper 50%", UExt50.TakeValueColor()); addChartBubble(bar == HighestAll(lastBar+n), PrevMidLoc, "Prev Mid", PrevMid.TakeValueColor()); addChartBubble(bar == HighestAll(lastBar+n), LExt25Loc, "Lower 25%", LExt25.TakeValueColor()); addChartBubble(bar == HighestAll(lastBar+n), LExt50Loc, "Lower 50%", LExt50.TakeValueColor()); # End Range Extension of Previous Day Range
@tomsk could you add the option to add the previous high and low with the labels?
# Range Extension of Previous Day Range
# tomsk
# 1.12.2020
# https://usethinkscript.com/threads/plot-25-and-50-of-previous-day%E2%80%99s-range.1472/#post-13666
# V1.0 - 01.11.2020 - tomsk - Range Extension of Previous Day Range
# V1.1 - 01.11.2020 - tomsk - Added plot of previous day range midpoint
# V1.2 - 01.11.2020 - tomsk - Added chart bubbles to identify all plot lines
# V1.3 - 01.12.2020 - tomsk - Added labels for previous day's high/low
# This study plots the 25% and 50% extension of the previous day's range
# To be used on intraday charts only
declare hide_on_daily;
input n = 3;
def bar = barNumber();
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
plot PrevMid = prevLow + (prevRange / 2);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
PrevMid.SetDefaultColor(Color.Yellow);
PrevMid.SetStyle(Curve.Short_Dash);
PrevMid.SetLineWeight(3);
AddLabel(1, "Previous Day's High = " + prevHigh, Color.Yellow);
AddLabel(1, "Previous Day's Low = " + prevLow, Color.Pink);
def lastBar = if isNaN(close[-1]) and !isNaN(close) then bar else lastBar[1];
def UExt25Loc = if isNaN(close[-1]) and !isNaN(close) then UExt25 else UExt25Loc[1];
def UExt50Loc = if isNaN(close[-1]) and !isNaN(close) then UExt50 else UExt50Loc[1];
def PrevMidLoc = if isNaN(close[-1]) and !isNaN(close) then PrevMid else PrevMidLoc[1];
def LExt25Loc = if isNaN(close[-1]) and !isNaN(close) then LExt25 else LExt25Loc[1];
def LExt50Loc = if isNaN(close[-1]) and !isNaN(close) then LExt50 else LExt50Loc[1];
addChartBubble(bar == HighestAll(lastBar+n), UExt25Loc, "Upper 25%", UExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), UExt50Loc, "Upper 50%", UExt50.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), PrevMidLoc, "Prev Mid", PrevMid.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt25Loc, "Lower 25%", LExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt50Loc, "Lower 50%", LExt50.TakeValueColor());
# End Range Extension of Previous Day Range
# Range Extension of Previous Day Range
# tomsk
# 1.12.2020
# https://usethinkscript.com/threads/plot-25-and-50-of-previous-day%E2%80%99s-range.1472/#post-13757
# V1.0 - 01.11.2020 - tomsk - Range Extension of Previous Day Range
# V1.1 - 01.11.2020 - tomsk - Added plot of previous day range midpoint
# V1.2 - 01.11.2020 - tomsk - Added chart bubbles to identify all plot lines
# V1.3 - 01.12.2020 - tomsk - Added labels and plot lines for previous day's high/low
# This study plots the 25% and 50% extension of the previous day's range
# To be used on intraday charts only
declare hide_on_daily;
input n = 3;
input displayLabel = yes;
def bar = barNumber();
def CurrentDay = GetDay() == GetLastDay();
def prevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevLow = if CurrentDay then low(period = AggregationPeriod.Day)[1] else Double.NaN;
def prevRange = if CurrentDay then prevHigh - prevLow else Double.NaN;
plot UExt25 = prevHigh + (prevRange * 0.25);
plot UExt50 = prevHigh + (prevRange * 0.50);
plot LExt25 = prevLow - (prevRange * 0.25);
plot LExt50 = prevLow - (prevRange * 0.50);
plot PrevHigh_ = prevHigh;
plot PrevLow_ = prevLow;
plot PrevMid = prevLow + (prevRange / 2);
UExt25.SetDefaultColor(Color.Cyan);
UExt50.SetDefaultColor(Color.Pink);
LExt25.SetDefaultColor(Color.White);
LExt50.SetDefaultColor(Color.Green);
PrevHigh_.SetDefaultColor(Color.Green);
PrevHigh_.SetStyle(Curve.Short_Dash);
PrevHigh_.SetLineWeight(3);
PrevLow_.SetDefaultColor(Color.Red);
PrevLow_.SetStyle(Curve.Short_Dash);
PrevLow_.SetLineWeight(3);
PrevMid.SetDefaultColor(Color.Yellow);
PrevMid.SetStyle(Curve.Short_Dash);
PrevMid.SetLineWeight(3);
AddLabel(displayLabel, "Previous Day's High = " + prevHigh, Color.Yellow);
AddLabel(displayLabel, "Previous Day's Low = " + prevLow, Color.Pink);
def lastBar = if isNaN(close[-1]) and !isNaN(close) then bar else lastBar[1];
def UExt25Loc = if isNaN(close[-1]) and !isNaN(close) then UExt25 else UExt25Loc[1];
def UExt50Loc = if isNaN(close[-1]) and !isNaN(close) then UExt50 else UExt50Loc[1];
def PrevHighLoc = if isNaN(close[-1]) and !isNaN(close) then PrevHigh else PrevHighLoc[1];
def PrevLowLoc = if isNaN(close[-1]) and !isNaN(close) then PrevLow else PrevLowLoc[1];
def PrevMidLoc = if isNaN(close[-1]) and !isNaN(close) then PrevMid else PrevMidLoc[1];
def LExt25Loc = if isNaN(close[-1]) and !isNaN(close) then LExt25 else LExt25Loc[1];
def LExt50Loc = if isNaN(close[-1]) and !isNaN(close) then LExt50 else LExt50Loc[1];
addChartBubble(bar == HighestAll(lastBar+n), UExt25Loc, "Upper 25%", UExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), UExt50Loc, "Upper 50%", UExt50.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), PrevHighLoc, "Prev Day High", PrevHigh_.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), PrevLowLoc, "Prev Day Low", PrevLow_.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), PrevMidLoc, "Prev Mid", PrevMid.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt25Loc, "Lower 25%", LExt25.TakeValueColor());
addChartBubble(bar == HighestAll(lastBar+n), LExt50Loc, "Lower 50%", LExt50.TakeValueColor());
# End Range Extension of Previous Day Range
def prevPrevHigh = if CurrentDay then high(period = AggregationPeriod.Day)[2] else Double.NaN;
def prevPrevLow = if CurrentDay then low(period = AggregationPeriod.Day)[2] else Double.NaN;