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