Futures Range Dashboard

jonesjb

New member
VIP
I've tried to create a Script, but can't figure out why it's not rendering the data correctly. What I'm trying to achieve here:

1. A lower indicator that can sit on any chart
2. 3 lines of data
3. Each line of data corresponds with an index (specifically SPY, QQQ, IWM), and the current proximity to the yesterday daily range.
4. The color of this line indicates if the current bar (and current timeframe) of the referenced index indicator is:
-above yesterday's daily high (of the referenced indicator)
-above yesterday's daily open or close (whichever is higher), but not above yesterday's high
-in the range of yesterday's open/close
-below yesterday's daily open or close (whichever is lower), but not below yesterday's low
-below yesterday's daily low
5. I've plotted each of the above as a separate plot so it can also work on mobile.

Here is where I'm at with the script, can anyone help me out here and point out what I'm missing, or make some adjustments?:
Ruby:
declare lower;
declare hide_on_daily;

#SPY Open

input agg = AggregationPeriod.DAY;
def NA = Double.NaN;

#SPY

def SPY_prevDayOpen = open( "SPY", "period"=agg)[1];
def SPY_prevDayClose = close( "SPY", "period"=agg)[1];
def SPY_prevDayLow = low("SPY", "period"=agg)[1];
def SPY_prevDayHigh = high("SPY", "period"=agg)[1];

def SPY_barhigh = max(SPY_prevDayOpen, SPY_prevDayClose);
def SPY_Barlow = min(SPY_prevDayOpen, SPY_prevDayClose);

def SpyCandle = close("SPY");

plot SVs_Y_OverHighest = if SpyCandle > SPY_prevDayHigh then 3 else na;

plot SVs_Y_OverHigh = if SpyCandle > SPY_barhigh and SpyCandle <= SPY_prevDayHigh then 3 else na;

plot SVs_Y_InRange = if SpyCandle <= SPY_barhigh and SpyCandle >= SPY_Barlow then 3 else na;

Plot SVs_Y_UnderLowest = if SpyCandle < SPY_prevDayLow then 3 else na;

plot SVs_Y_UnderLow = if SpyCandle < SPY_Barlow and SpyCandle >= SPY_prevDayLow then 3 else na;

SVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHighest.SetLineWeight(3);
SVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
SVs_Y_OverHighest.HideBubble();
SVs_Y_OverHighest.HideTitle();

SVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHigh.SetLineWeight(3);
SVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
SVs_Y_OverHigh.HideBubble();
SVs_Y_OverHigh.HideTitle();

SVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_InRange.SetLineWeight(3);
SVs_Y_InRange.SetDefaultColor(Color.gray);
SVs_Y_InRange.HideBubble();
SVs_Y_InRange.HideTitle();

SVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLow.SetLineWeight(3);
SVs_Y_UnderLow.SetDefaultColor(Color.pink);
SVs_Y_UnderLow.HideBubble();
SVs_Y_UnderLow.HideTitle();

SVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLowest.SetLineWeight(3);
SVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
SVs_Y_UnderLowest.HideBubble();
sVs_Y_UnderLowest.HideTitle();



#QQQ

def QQQ_prevDayOpen = open( "QQQ", "period"=agg)[1];
def QQQ_prevDayClose = close( "QQQ", "period"=agg)[1];
def QQQ_prevDayLow = low("QQQ", "period"=agg)[1];
def QQQ_prevDayHigh = high("QQQ", "period"=agg)[1];

def QQQbarhigh = max(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQbarlow = min(QQQ_prevDayOpen, QQQ_prevDayClose);

def QQQCandle = close("QQQ");

plot QVs_Y_OverHighest = if QQQCandle > QQQ_prevDayHigh then 2 else na;

plot QVs_Y_OverHigh = if QQQCandle > QQQbarhigh and QQQCandle <= QQQ_prevDayHigh then 2 else na;

plot QVs_Y_InRange = if QQQCandle <= QQQbarhigh and QQQCandle >= QQQbarlow then 2 else na;

Plot QVs_Y_UnderLowest = if QQQCandle < QQQ_prevDayLow then 2 else na;

plot QVs_Y_UnderLow = if QQQCandle < QQQbarlow and QQQCandle >= QQQ_prevDayLow then 2 else na;

QVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHighest.SetLineWeight(3);
QVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
QVs_Y_OverHighest.HideBubble();
QVs_Y_OverHighest.HideTitle();

QVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHigh.SetLineWeight(3);
QVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
QVs_Y_OverHigh.HideBubble();
QVs_Y_OverHigh.HideTitle();

QVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_InRange.SetLineWeight(3);
QVs_Y_InRange.SetDefaultColor(Color.gray);
QVs_Y_InRange.HideBubble();
QVs_Y_InRange.HideTitle();

QVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLow.SetLineWeight(3);
QVs_Y_UnderLow.SetDefaultColor(Color.pink);
QVs_Y_UnderLow.HideBubble();
QVs_Y_UnderLow.HideTitle();

QVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLowest.SetLineWeight(3);
QVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
QVs_Y_UnderLowest.HideBubble();
QVs_Y_UnderLowest.HideTitle();



#IWM

def IWM_prevDayOpen = open( "IWM", "period"=agg)[1];
def IWM_prevDayClose = close( "IWM", "period"=agg)[1];
def IWM_prevDayLow = low("IWM", "period"=agg)[1];
def IWM_prevDayHigh = high("IWM", "period"=agg)[1];

def IWMbarhigh = max(IWM_prevDayOpen, IWM_prevDayClose);
def IWMbarlow = min(IWM_prevDayOpen, IWM_prevDayClose);

def IWMCandle = close("IWM");

plot IVs_Y_OverHighest = if IWMCandle > IWM_prevDayHigh then 1 else na;

plot IVs_Y_OverHigh = if (IWMCandle > IWMbarhigh) and (IWMCandle <= IWM_prevDayHigh) then 1 else na;

plot IVs_Y_InRange = if IWMCandle <= IWMbarhigh and IWMCandle >= IWMbarlow then 1 else na;

plot IVs_Y_UnderLow = if (IWMCandle < IWMbarlow) and (IWMCandle >= IWM_prevDayLow) then 1 else na;

Plot IVs_Y_UnderLowest = if IWMCandle < IWM_prevDayLow then 1 else na;

IVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHighest.SetLineWeight(3);
IVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
IVs_Y_OverHighest.HideBubble();
IVs_Y_OverHighest.HideTitle();

IVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHigh.SetLineWeight(3);
IVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
IVs_Y_OverHigh.HideBubble();
IVs_Y_OverHigh.HideTitle();

IVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_InRange.SetLineWeight(3);
IVs_Y_InRange.SetDefaultColor(Color.gray);
IVs_Y_InRange.HideBubble();
IVs_Y_InRange.HideTitle();

IVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLow.SetLineWeight(3);
IVs_Y_UnderLow.SetDefaultColor(Color.pink);
IVs_Y_UnderLow.HideBubble();
IVs_Y_UnderLow.HideTitle();

IVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLowest.SetLineWeight(3);
IVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
IVs_Y_UnderLowest.HideBubble();
IVs_Y_UnderLowest.HideTitle();
 
Last edited by a moderator:
Solution
I've tried to create a Script, but can't figure out why it's not rendering the data correctly. What I'm trying to achieve here:

1. A lower indicator that can sit on any chart
2. 3 lines of data
3. Each line of data corresponds with an index (specifically SPY, QQQ, IWM), and the current proximity to the yesterday daily range.
4. The color of this line indicates if the current bar (and current timeframe) of the referenced index indicator is:
-above yesterday's daily high (of the referenced indicator)
-above yesterday's daily open or close (whichever is higher), but not above yesterday's high
-in the range of yesterday's open/close
-below yesterday's daily open or close (whichever is lower), but not below...
I've tried to create a Script, but can't figure out why it's not rendering the data correctly. What I'm trying to achieve here:

1. A lower indicator that can sit on any chart
2. 3 lines of data
3. Each line of data corresponds with an index (specifically SPY, QQQ, IWM), and the current proximity to the yesterday daily range.
4. The color of this line indicates if the current bar (and current timeframe) of the referenced index indicator is:
-above yesterday's daily high (of the referenced indicator)
-above yesterday's daily open or close (whichever is higher), but not above yesterday's high
-in the range of yesterday's open/close
-below yesterday's daily open or close (whichever is lower), but not below yesterday's low
-below yesterday's daily low
5. I've plotted each of the above as a separate plot so it can also work on mobile.

Here is where I'm at with the script, can anyone help me out here and point out what I'm missing, or make some adjustments?:





declare lower;
declare hide_on_daily;

#SPY Open

input agg = AggregationPeriod.DAY;
def NA = Double.NaN;

#SPY

def SPY_prevDayOpen = open( "SPY", "period"=agg)[1];
def SPY_prevDayClose = close( "SPY", "period"=agg)[1];
def SPY_prevDayLow = low("SPY", "period"=agg)[1];
def SPY_prevDayHigh = high("SPY", "period"=agg)[1];

def SPY_barhigh = max(SPY_prevDayOpen, SPY_prevDayClose);
def SPY_Barlow = min(SPY_prevDayOpen, SPY_prevDayClose);

def SpyCandle = close("SPY");

plot SVs_Y_OverHighest = if SpyCandle > SPY_prevDayHigh then 3 else na;

plot SVs_Y_OverHigh = if SpyCandle > SPY_barhigh and SpyCandle <= SPY_prevDayHigh then 3 else na;

plot SVs_Y_InRange = if SpyCandle <= SPY_barhigh and SpyCandle >= SPY_Barlow then 3 else na;

Plot SVs_Y_UnderLowest = if SpyCandle < SPY_prevDayLow then 3 else na;

plot SVs_Y_UnderLow = if SpyCandle < SPY_Barlow and SpyCandle >= SPY_prevDayLow then 3 else na;

SVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHighest.SetLineWeight(3);
SVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
SVs_Y_OverHighest.HideBubble();
SVs_Y_OverHighest.HideTitle();

SVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHigh.SetLineWeight(3);
SVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
SVs_Y_OverHigh.HideBubble();
SVs_Y_OverHigh.HideTitle();

SVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_InRange.SetLineWeight(3);
SVs_Y_InRange.SetDefaultColor(Color.gray);
SVs_Y_InRange.HideBubble();
SVs_Y_InRange.HideTitle();

SVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLow.SetLineWeight(3);
SVs_Y_UnderLow.SetDefaultColor(Color.pink);
SVs_Y_UnderLow.HideBubble();
SVs_Y_UnderLow.HideTitle();

SVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLowest.SetLineWeight(3);
SVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
SVs_Y_UnderLowest.HideBubble();
sVs_Y_UnderLowest.HideTitle();



#QQQ

def QQQ_prevDayOpen = open( "QQQ", "period"=agg)[1];
def QQQ_prevDayClose = close( "QQQ", "period"=agg)[1];
def QQQ_prevDayLow = low("QQQ", "period"=agg)[1];
def QQQ_prevDayHigh = high("QQQ", "period"=agg)[1];

def QQQbarhigh = max(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQbarlow = min(QQQ_prevDayOpen, QQQ_prevDayClose);

def QQQCandle = close("QQQ");

plot QVs_Y_OverHighest = if QQQCandle > QQQ_prevDayHigh then 2 else na;

plot QVs_Y_OverHigh = if QQQCandle > QQQbarhigh and QQQCandle <= QQQ_prevDayHigh then 2 else na;

plot QVs_Y_InRange = if QQQCandle <= QQQbarhigh and QQQCandle >= QQQbarlow then 2 else na;

Plot QVs_Y_UnderLowest = if QQQCandle < QQQ_prevDayLow then 2 else na;

plot QVs_Y_UnderLow = if QQQCandle < QQQbarlow and QQQCandle >= QQQ_prevDayLow then 2 else na;

QVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHighest.SetLineWeight(3);
QVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
QVs_Y_OverHighest.HideBubble();
QVs_Y_OverHighest.HideTitle();

QVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHigh.SetLineWeight(3);
QVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
QVs_Y_OverHigh.HideBubble();
QVs_Y_OverHigh.HideTitle();

QVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_InRange.SetLineWeight(3);
QVs_Y_InRange.SetDefaultColor(Color.gray);
QVs_Y_InRange.HideBubble();
QVs_Y_InRange.HideTitle();

QVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLow.SetLineWeight(3);
QVs_Y_UnderLow.SetDefaultColor(Color.pink);
QVs_Y_UnderLow.HideBubble();
QVs_Y_UnderLow.HideTitle();

QVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLowest.SetLineWeight(3);
QVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
QVs_Y_UnderLowest.HideBubble();
QVs_Y_UnderLowest.HideTitle();



#IWM

def IWM_prevDayOpen = open( "IWM", "period"=agg)[1];
def IWM_prevDayClose = close( "IWM", "period"=agg)[1];
def IWM_prevDayLow = low("IWM", "period"=agg)[1];
def IWM_prevDayHigh = high("IWM", "period"=agg)[1];

def IWMbarhigh = max(IWM_prevDayOpen, IWM_prevDayClose);
def IWMbarlow = min(IWM_prevDayOpen, IWM_prevDayClose);

def IWMCandle = close("IWM");

plot IVs_Y_OverHighest = if IWMCandle > IWM_prevDayHigh then 1 else na;

plot IVs_Y_OverHigh = if (IWMCandle > IWMbarhigh) and (IWMCandle <= IWM_prevDayHigh) then 1 else na;

plot IVs_Y_InRange = if IWMCandle <= IWMbarhigh and IWMCandle >= IWMbarlow then 1 else na;

plot IVs_Y_UnderLow = if (IWMCandle < IWMbarlow) and (IWMCandle >= IWM_prevDayLow) then 1 else na;

Plot IVs_Y_UnderLowest = if IWMCandle < IWM_prevDayLow then 1 else na;

IVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHighest.SetLineWeight(3);
IVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
IVs_Y_OverHighest.HideBubble();
IVs_Y_OverHighest.HideTitle();

IVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHigh.SetLineWeight(3);
IVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
IVs_Y_OverHigh.HideBubble();
IVs_Y_OverHigh.HideTitle();

IVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_InRange.SetLineWeight(3);
IVs_Y_InRange.SetDefaultColor(Color.gray);
IVs_Y_InRange.HideBubble();
IVs_Y_InRange.HideTitle();

IVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLow.SetLineWeight(3);
IVs_Y_UnderLow.SetDefaultColor(Color.pink);
IVs_Y_UnderLow.HideBubble();
IVs_Y_UnderLow.HideTitle();

IVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLowest.SetLineWeight(3);
IVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
IVs_Y_UnderLowest.HideBubble();
IVs_Y_UnderLowest.HideTitle();

it looks like it works? it plots lines of colors ?
when asking questions, be specific. don't say it doesn't work.

what is the real question?

here is a modified version,
changed to use variables for symbols
added bubbles at the end to display symbol names and prices for symbol1

(another idea, change this to an upper and plot the price lines for comparing to current price)

Code:
#symbols_diff_lines

#https://usethinkscript.com/threads/futures-range-dashboard.18781/
#Futures Range Dashboard
#jonesjb  5/18

#I've tried to create a Script, but can't figure out why it's not rendering the data correctly. What I'm trying to achieve here:

#1. A lower indicator that can sit on any chart
#2. 3 lines of data
#3. Each line of data corresponds with an index (specifically SPY, QQQ, IWM), and the current proximity to the yesterday daily range.
#4. The color of this line indicates if the current bar (and current timeframe) of the referenced index indicator is:

# cyan    - above yesterday's daily high (of the referenced indicator)
# green   - above yesterday's daily open or close (whichever is higher), but not above yesterday's high
# gray    - in the range of yesterday's open/close
# pink    - below yesterday's daily open or close (whichever is lower), but not below yesterday's low
# magenta - below yesterday's daily low

#5. I've plotted each of the above as a separate plot so it can also work on mobile.

#Here is where I'm at with the script, can anyone help me out here and point out what I'm missing, or make some adjustments?:



declare lower;
declare hide_on_daily;

#SPY Open

input agg = AggregationPeriod.DAY;

def na = double.nan;
def bn = barnumber();


input sym1 = "SPY";
input sym2 = "QQQ";
input sym3 = "IWM";

# sym1 = SPY
def line1 = 1;

def SPY_prevDayOpen = open(symbol = sym1, period = agg)[1];
def SPY_prevDayClose = close(symbol = sym1, period = agg)[1];
def SPY_prevDayLow = low(symbol = sym1, period = agg)[1];
def SPY_prevDayHigh = high(symbol = sym1, period = agg)[1];

def SPY_barhigh = max(SPY_prevDayOpen, SPY_prevDayClose);
def SPY_Barlow = min(SPY_prevDayOpen, SPY_prevDayClose);
def SpyCandle = close(symbol = sym1);

plot SVs_Y_OverHighest = if SpyCandle > SPY_prevDayHigh then line1 else na;
plot SVs_Y_OverHigh = if SpyCandle > SPY_barhigh and SpyCandle <= SPY_prevDayHigh then line1 else na;
plot SVs_Y_InRange = if SpyCandle <= SPY_barhigh and SpyCandle >= SPY_Barlow then line1 else na;
plot SVs_Y_UnderLow = if SpyCandle < SPY_Barlow and SpyCandle >= SPY_prevDayLow then line1 else na;
Plot SVs_Y_UnderLowest = if SpyCandle < SPY_prevDayLow then line1 else na;

SVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHighest.SetLineWeight(3);
SVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
SVs_Y_OverHighest.HideBubble();
SVs_Y_OverHighest.HideTitle();

SVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHigh.SetLineWeight(3);
SVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
SVs_Y_OverHigh.HideBubble();
SVs_Y_OverHigh.HideTitle();

SVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_InRange.SetLineWeight(3);
SVs_Y_InRange.SetDefaultColor(Color.gray);
SVs_Y_InRange.HideBubble();
SVs_Y_InRange.HideTitle();

SVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLow.SetLineWeight(3);
SVs_Y_UnderLow.SetDefaultColor(Color.pink);
SVs_Y_UnderLow.HideBubble();
SVs_Y_UnderLow.HideTitle();

SVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLowest.SetLineWeight(3);
SVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
SVs_Y_UnderLowest.HideBubble();
sVs_Y_UnderLowest.HideTitle();



# sym2 = QQQ

def line2 = 2;
def QQQ_prevDayOpen = open( symbol = sym2, period = agg)[1];
def QQQ_prevDayClose = close( symbol = sym2, period = agg)[1];
def QQQ_prevDayLow = low( symbol = sym2, period = agg)[1];
def QQQ_prevDayHigh = high( symbol = sym2, period = agg)[1];

def QQQbarhigh = max(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQbarlow = min(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQCandle = close(symbol = sym2);

plot QVs_Y_OverHighest = if QQQCandle > QQQ_prevDayHigh then line2 else na;
plot QVs_Y_OverHigh = if QQQCandle > QQQbarhigh and QQQCandle <= QQQ_prevDayHigh then line2 else na;
plot QVs_Y_InRange = if QQQCandle <= QQQbarhigh and QQQCandle >= QQQbarlow then line2 else na;
plot QVs_Y_UnderLow = if QQQCandle < QQQbarlow and QQQCandle >= QQQ_prevDayLow then line2 else na;
Plot QVs_Y_UnderLowest = if QQQCandle < QQQ_prevDayLow then line2 else na;

QVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHighest.SetLineWeight(3);
QVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
QVs_Y_OverHighest.HideBubble();
QVs_Y_OverHighest.HideTitle();

QVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHigh.SetLineWeight(3);
QVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
QVs_Y_OverHigh.HideBubble();
QVs_Y_OverHigh.HideTitle();

QVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_InRange.SetLineWeight(3);
QVs_Y_InRange.SetDefaultColor(Color.gray);
QVs_Y_InRange.HideBubble();
QVs_Y_InRange.HideTitle();

QVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLow.SetLineWeight(3);
QVs_Y_UnderLow.SetDefaultColor(Color.pink);
QVs_Y_UnderLow.HideBubble();
QVs_Y_UnderLow.HideTitle();

QVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLowest.SetLineWeight(3);
QVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
QVs_Y_UnderLowest.HideBubble();
QVs_Y_UnderLowest.HideTitle();



# sym3 = IWM

def line3 = 3;
def IWM_prevDayOpen = open( symbol = sym3, period = agg)[1];
def IWM_prevDayClose = close( symbol = sym3, period = agg)[1];
def IWM_prevDayLow = low( symbol = sym3, period = agg)[1];
def IWM_prevDayHigh = high( symbol = sym3, period = agg)[1];

def IWMbarhigh = max(IWM_prevDayOpen, IWM_prevDayClose);
def IWMbarlow = min(IWM_prevDayOpen, IWM_prevDayClose);
def IWMCandle = close(symbol = sym3);

plot IVs_Y_OverHighest = if IWMCandle > IWM_prevDayHigh then line3 else na;
plot IVs_Y_OverHigh = if (IWMCandle > IWMbarhigh) and (IWMCandle <= IWM_prevDayHigh) then line3 else na;
plot IVs_Y_InRange = if IWMCandle <= IWMbarhigh and IWMCandle >= IWMbarlow then line3 else na;
plot IVs_Y_UnderLow = if (IWMCandle < IWMbarlow) and (IWMCandle >= IWM_prevDayLow) then line3 else na;
Plot IVs_Y_UnderLowest = if IWMCandle < IWM_prevDayLow then line3 else na;

IVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHighest.SetLineWeight(3);
IVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
IVs_Y_OverHighest.HideBubble();
IVs_Y_OverHighest.HideTitle();

IVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHigh.SetLineWeight(3);
IVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
IVs_Y_OverHigh.HideBubble();
IVs_Y_OverHigh.HideTitle();

IVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_InRange.SetLineWeight(3);
IVs_Y_InRange.SetDefaultColor(Color.gray);
IVs_Y_InRange.HideBubble();
IVs_Y_InRange.HideTitle();

IVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLow.SetLineWeight(3);
IVs_Y_UnderLow.SetDefaultColor(Color.pink);
IVs_Y_UnderLow.HideBubble();
IVs_Y_UnderLow.HideTitle();

IVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLowest.SetLineWeight(3);
IVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
IVs_Y_UnderLowest.HideBubble();
IVs_Y_UnderLowest.HideTitle();

#---------------------------------


def spac1 = line2 - line1;
def spac2 = spac1/2;
def spac4 = spac2/2;

plot z1 = line1 - spac2;
plot z2 = line3 + spac2;
z1.SetDefaultColor(Color.black);
z2.SetDefaultColor(Color.black);


# symbol names right of lines
def bub1 = 2;
def xbub = (!isnan(close[bub1]) and isnan(close[bub1-1]));
addchartbubble(xbub, line1, sym1, color.white, yes);
addchartbubble(xbub, line2, sym2, color.white, yes);
addchartbubble(xbub, line3, sym3, color.white, yes);


# show 4 prices 
def bub2 = 12;
def xbub2 = (!isnan(close[bub2]) and isnan(close[bub2-1]));
addchartbubble(xbub2, (line1 - spac1), 
 SPY_prevDayHigh[bub2] + "\n" +
 spY_barhigh[bub2] + "\n" +
 SPY_Barlow[bub2] + "\n" + 
 SPY_prevDayLow[bub2]
, color.white, yes);


# show price
def bub3 = 24;
def xbub3 = (!isnan(close[bub3]) and isnan(close[bub3-1]));
addchartbubble(xbub3, (line2 - (spac1+spac2)), 
SpyCandle[bub3]
, color.white, yes);

#
 

Attachments

  • img1.JPG
    img1.JPG
    95.8 KB · Views: 59
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

it looks like it works? it plots lines of colors ?
when asking questions, be specific. don't say it doesn't work.

what is the real question?

here is a modified version,
changed to use variables for symbols
added bubbles at the end to display symbol names and prices for symbol1

(another idea, change this to an upper and plot the price lines for comparing to current price)

Code:
#symbols_diff_lines

#https://usethinkscript.com/threads/futures-range-dashboard.18781/
#Futures Range Dashboard
#jonesjb  5/18

#I've tried to create a Script, but can't figure out why it's not rendering the data correctly. What I'm trying to achieve here:

#1. A lower indicator that can sit on any chart
#2. 3 lines of data
#3. Each line of data corresponds with an index (specifically SPY, QQQ, IWM), and the current proximity to the yesterday daily range.
#4. The color of this line indicates if the current bar (and current timeframe) of the referenced index indicator is:

# cyan    - above yesterday's daily high (of the referenced indicator)
# green   - above yesterday's daily open or close (whichever is higher), but not above yesterday's high
# gray    - in the range of yesterday's open/close
# pink    - below yesterday's daily open or close (whichever is lower), but not below yesterday's low
# magenta - below yesterday's daily low

#5. I've plotted each of the above as a separate plot so it can also work on mobile.

#Here is where I'm at with the script, can anyone help me out here and point out what I'm missing, or make some adjustments?:



declare lower;
declare hide_on_daily;

#SPY Open

input agg = AggregationPeriod.DAY;

def na = double.nan;
def bn = barnumber();


input sym1 = "SPY";
input sym2 = "QQQ";
input sym3 = "IWM";

# sym1 = SPY
def line1 = 1;

def SPY_prevDayOpen = open(symbol = sym1, period = agg)[1];
def SPY_prevDayClose = close(symbol = sym1, period = agg)[1];
def SPY_prevDayLow = low(symbol = sym1, period = agg)[1];
def SPY_prevDayHigh = high(symbol = sym1, period = agg)[1];

def SPY_barhigh = max(SPY_prevDayOpen, SPY_prevDayClose);
def SPY_Barlow = min(SPY_prevDayOpen, SPY_prevDayClose);
def SpyCandle = close(symbol = sym1);

plot SVs_Y_OverHighest = if SpyCandle > SPY_prevDayHigh then line1 else na;
plot SVs_Y_OverHigh = if SpyCandle > SPY_barhigh and SpyCandle <= SPY_prevDayHigh then line1 else na;
plot SVs_Y_InRange = if SpyCandle <= SPY_barhigh and SpyCandle >= SPY_Barlow then line1 else na;
plot SVs_Y_UnderLow = if SpyCandle < SPY_Barlow and SpyCandle >= SPY_prevDayLow then line1 else na;
Plot SVs_Y_UnderLowest = if SpyCandle < SPY_prevDayLow then line1 else na;

SVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHighest.SetLineWeight(3);
SVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
SVs_Y_OverHighest.HideBubble();
SVs_Y_OverHighest.HideTitle();

SVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_OverHigh.SetLineWeight(3);
SVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
SVs_Y_OverHigh.HideBubble();
SVs_Y_OverHigh.HideTitle();

SVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_InRange.SetLineWeight(3);
SVs_Y_InRange.SetDefaultColor(Color.gray);
SVs_Y_InRange.HideBubble();
SVs_Y_InRange.HideTitle();

SVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLow.SetLineWeight(3);
SVs_Y_UnderLow.SetDefaultColor(Color.pink);
SVs_Y_UnderLow.HideBubble();
SVs_Y_UnderLow.HideTitle();

SVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
SVs_Y_UnderLowest.SetLineWeight(3);
SVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
SVs_Y_UnderLowest.HideBubble();
sVs_Y_UnderLowest.HideTitle();



# sym2 = QQQ

def line2 = 2;
def QQQ_prevDayOpen = open( symbol = sym2, period = agg)[1];
def QQQ_prevDayClose = close( symbol = sym2, period = agg)[1];
def QQQ_prevDayLow = low( symbol = sym2, period = agg)[1];
def QQQ_prevDayHigh = high( symbol = sym2, period = agg)[1];

def QQQbarhigh = max(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQbarlow = min(QQQ_prevDayOpen, QQQ_prevDayClose);
def QQQCandle = close(symbol = sym2);

plot QVs_Y_OverHighest = if QQQCandle > QQQ_prevDayHigh then line2 else na;
plot QVs_Y_OverHigh = if QQQCandle > QQQbarhigh and QQQCandle <= QQQ_prevDayHigh then line2 else na;
plot QVs_Y_InRange = if QQQCandle <= QQQbarhigh and QQQCandle >= QQQbarlow then line2 else na;
plot QVs_Y_UnderLow = if QQQCandle < QQQbarlow and QQQCandle >= QQQ_prevDayLow then line2 else na;
Plot QVs_Y_UnderLowest = if QQQCandle < QQQ_prevDayLow then line2 else na;

QVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHighest.SetLineWeight(3);
QVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
QVs_Y_OverHighest.HideBubble();
QVs_Y_OverHighest.HideTitle();

QVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_OverHigh.SetLineWeight(3);
QVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
QVs_Y_OverHigh.HideBubble();
QVs_Y_OverHigh.HideTitle();

QVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_InRange.SetLineWeight(3);
QVs_Y_InRange.SetDefaultColor(Color.gray);
QVs_Y_InRange.HideBubble();
QVs_Y_InRange.HideTitle();

QVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLow.SetLineWeight(3);
QVs_Y_UnderLow.SetDefaultColor(Color.pink);
QVs_Y_UnderLow.HideBubble();
QVs_Y_UnderLow.HideTitle();

QVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
QVs_Y_UnderLowest.SetLineWeight(3);
QVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
QVs_Y_UnderLowest.HideBubble();
QVs_Y_UnderLowest.HideTitle();



# sym3 = IWM

def line3 = 3;
def IWM_prevDayOpen = open( symbol = sym3, period = agg)[1];
def IWM_prevDayClose = close( symbol = sym3, period = agg)[1];
def IWM_prevDayLow = low( symbol = sym3, period = agg)[1];
def IWM_prevDayHigh = high( symbol = sym3, period = agg)[1];

def IWMbarhigh = max(IWM_prevDayOpen, IWM_prevDayClose);
def IWMbarlow = min(IWM_prevDayOpen, IWM_prevDayClose);
def IWMCandle = close(symbol = sym3);

plot IVs_Y_OverHighest = if IWMCandle > IWM_prevDayHigh then line3 else na;
plot IVs_Y_OverHigh = if (IWMCandle > IWMbarhigh) and (IWMCandle <= IWM_prevDayHigh) then line3 else na;
plot IVs_Y_InRange = if IWMCandle <= IWMbarhigh and IWMCandle >= IWMbarlow then line3 else na;
plot IVs_Y_UnderLow = if (IWMCandle < IWMbarlow) and (IWMCandle >= IWM_prevDayLow) then line3 else na;
Plot IVs_Y_UnderLowest = if IWMCandle < IWM_prevDayLow then line3 else na;

IVs_Y_OverHighest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHighest.SetLineWeight(3);
IVs_Y_OverHighest.SetDefaultColor(Color.CYAN);
IVs_Y_OverHighest.HideBubble();
IVs_Y_OverHighest.HideTitle();

IVs_Y_OverHigh.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_OverHigh.SetLineWeight(3);
IVs_Y_OverHigh.SetDefaultColor(Color.Uptick);
IVs_Y_OverHigh.HideBubble();
IVs_Y_OverHigh.HideTitle();

IVs_Y_InRange.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_InRange.SetLineWeight(3);
IVs_Y_InRange.SetDefaultColor(Color.gray);
IVs_Y_InRange.HideBubble();
IVs_Y_InRange.HideTitle();

IVs_Y_UnderLow.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLow.SetLineWeight(3);
IVs_Y_UnderLow.SetDefaultColor(Color.pink);
IVs_Y_UnderLow.HideBubble();
IVs_Y_UnderLow.HideTitle();

IVs_Y_UnderLowest.SetPaintingStrategy(PaintingStrategy.SQUARES);
IVs_Y_UnderLowest.SetLineWeight(3);
IVs_Y_UnderLowest.SetDefaultColor(Color.magenta);
IVs_Y_UnderLowest.HideBubble();
IVs_Y_UnderLowest.HideTitle();

#---------------------------------


def spac1 = line2 - line1;
def spac2 = spac1/2;
def spac4 = spac2/2;

plot z1 = line1 - spac2;
plot z2 = line3 + spac2;
z1.SetDefaultColor(Color.black);
z2.SetDefaultColor(Color.black);


# symbol names right of lines
def bub1 = 2;
def xbub = (!isnan(close[bub1]) and isnan(close[bub1-1]));
addchartbubble(xbub, line1, sym1, color.white, yes);
addchartbubble(xbub, line2, sym2, color.white, yes);
addchartbubble(xbub, line3, sym3, color.white, yes);


# show 4 prices
def bub2 = 12;
def xbub2 = (!isnan(close[bub2]) and isnan(close[bub2-1]));
addchartbubble(xbub2, (line1 - spac1),
 SPY_prevDayHigh[bub2] + "\n" +
 spY_barhigh[bub2] + "\n" +
 SPY_Barlow[bub2] + "\n" +
 SPY_prevDayLow[bub2]
, color.white, yes);


# show price
def bub3 = 24;
def xbub3 = (!isnan(close[bub3]) and isnan(close[bub3-1]));
addchartbubble(xbub3, (line2 - (spac1+spac2)),
SpyCandle[bub3]
, color.white, yes);

#
I tried to be specific but apologies for any confusion, it's not so much that it doesn't work (or display lines), it's that it's not rendering the data correctly. For example, here is the chart for AAPL, May 17 2024. I expect the 3 lines at the bottom to appear like the top set, but they appear like the bottom set with the code I originally posted. And then as i change the ticker, the data in the bottom chart changes. However, since the bars are SPY, QQQ, and IWM, (respectively), it should remain consistent irrespective of what Ticker is selected.

EDIT: It's possible that it's not rendering correctly because it's after hours on the weekend. Perhaps it will work when market opens Monday?

1716104321583.png
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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