Thanks so much for the script, I will thoroughly check it out after work. I currently use a chopped up version of a Mobius script that allows me to get alerts but doesn't really paint permanently. I will post it presently.
This is the Mobius script I modified. It gives me very accurate alerts.
# Pivot_Array (
Please copy and paste this name to study name above)
# Mobius
# V01.09.13.2017
#hint: Plots the most recent 4 resistance pivots and support pivots. \n For scanning: Find the study in list of studies then select either BearScan or BullScan as the left side entry in the Scan Wizard and equal to as the center definition and close price as the right side entry.
#Modified to show alerts for 3 consecutive higher lows or 3 consecutive lower highs
# User Inputs
input n = 2; #hint n: periods used for pivot calculations.
input showHigh = no;
input ShowLow = no;
input showR1 = yes;
input showR2 = yes;
input showR3 = yes;
input showR4 = yes;
input showS1 = yes;
input showS2 = yes;
input showS3 = yes;
input showS4 = yes;
input StatsOn = no;
input ShowSignals = yes;
input labels = yes;
input showlabels = yes ;
input factor = 0.1 ;
# Internal Script Reference
script LinePlot {
input BarID = 0;
input Value = 0;
input BarOrigin = 0;
def ThisBar = HighestAll(BarOrigin);
def ValueLine = if BarOrigin == ThisBar
then Value
else Double.NaN;
plot P = if ThisBar - BarID <= BarOrigin
then HighestAll(ValueLine)
else Double.NaN;
}
# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def BBar = bar == HighestAll(bar);
# Parent High
def ParentHigh = HighestAll(h);
def ParentHBarOrigin = if h == ParentHigh
then bar
else ParentHBarOrigin[1];
def ParentHBarID = bar - HighestAll(ParentHBarOrigin);
# R1
def hh = fold i = 1 to n + 1
with p = 1
while p
do h > GetValue(h, -i);
def PivotH = if (bar > n and
h == Highest(h, n) and
hh)
then h
else Double.NaN;
def PHValue = if !IsNaN(PivotH)
then PivotH
else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH)
then bar
else PHBarOrigin[1];
def PHBarID = bar - PHBarOrigin;
# R2
def R2PHValue = if PHBarOrigin != PHBarOrigin[1]
then PHValue[1]
else R2PHValue[1];
def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1]
then PHBarOrigin[1]
else R2PHBarOrigin[1];
def R2PHBarID = bar - R2PHBarOrigin;
# R3
def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHValue[1]
else R3PHValue[1];
def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHBarOrigin[1]
else R3PHBarOrigin[1];
def R3PHBarID = bar - R3PHBarOrigin;
# R4
def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHValue[1]
else R4PHValue[1];
def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHBarOrigin[1]
else R4PHBarOrigin[1];
def R4PHBarID = bar - R4PHBarOrigin;
# Parent Low
def ParentLow = LowestAll(l);
def ParentLBarOrigin = if l == ParentLow
then bar
else ParentLBarOrigin[1];
def ParentLBarID = bar - HighestAll(ParentLBarOrigin);
# S1
def ll = fold j = 1 to n + 1
with q = 1
while q
do l < GetValue(l, -j);
def PivotL = if (bar > n and
l == Lowest(l, n) and
ll)
then l
else Double.NaN;
def PLValue = if !IsNaN(PivotL)
then PivotL
else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL)
then bar
else PLBarOrigin[1];
def PLBarID = bar - PLBarOrigin;
# S2
def S2PLValue = if PLBarOrigin != PLBarOrigin[1]
then PLValue[1]
else S2PLValue[1];
def S2PLBarOrigin = if PLBarOrigin != PLBarOrigin[1]
then PLBarOrigin[1]
else S2PLBarOrigin[1];
def S2PLBarID = bar - S2PLBarOrigin;
# S3
def S3PLValue = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLValue[1]
else S3PLValue[1];
def S3PLBarOrigin = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLBarOrigin[1]
else S3PLBarOrigin[1];
def S3PLBarID = bar - S3PLBarOrigin;
# S4
def S4PLValue = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLValue[1]
else S4PLValue[1];
def S4PLBarOrigin = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLBarOrigin[1]
else S4PLBarOrigin[1];
def S4PLBarID = bar - S4PLBarOrigin;
# Plots
def PR1 = LinePlot(BarID = ParentHBarID,
Value = ParentHigh,
BarOrigin = HighestAll(ParentHBarOrigin));
# PR1.SetDefaultColor(Color.GREEN);
# PR1.SetHiding(!ShowHigh);
#addChartBubble(ShowHigh and Bar == HighestAll(Bar), ParentHigh, "High", color.yellow, 1);
def R1 = LinePlot(BarID = PHBarID,
Value = PHValue,
BarOrigin = PHBarOrigin);
# R1.SetDefaultColor(Color.GREEN);
# R1.SetHiding(!ShowR1);
#addChartBubble(ShowR1 and Bar == HighestAll(PHBarOrigin), PHvalue, "R1", color.green, 1);
def R2 = LinePlot(BarID = R2PHBarID,
Value = R2PHValue,
BarOrigin = R2PHBarOrigin);
# R2.SetDefaultColor(Color.GREEN);
# R2.SetHiding(!ShowR2);
#addChartBubble(ShowR2 and Bar == HighestAll(R2PHBarOrigin), PHvalue, "R2", color.green, 1);
def R3 = LinePlot(BarID = R3PHBarID,
Value = R3PHValue,
BarOrigin = R3PHBarOrigin);
# R3.SetDefaultColor(Color.GREEN);
# R3.SetHiding(!ShowR3);
#addChartBubble(ShowR3 and Bar == HighestAll(R3PHBarOrigin), PHvalue, "R3", color.green, 1);
def R4 = LinePlot(BarID = R4PHBarID,
Value = R4PHValue,
BarOrigin = R4PHBarOrigin);
# R4.SetDefaultColor(Color.GREEN);
# R4.SetHiding(!ShowR4);
#addChartBubble(ShowR4 and Bar == HighestAll(R4PHBarOrigin), PHvalue, "R4", color.green, 1);
def PS1 = LinePlot(BarID = ParentLBarID,
Value = ParentLow,
BarOrigin = HighestAll(ParentLBarOrigin));
# PS1.SetDefaultColor(Color.RED);
# PS1.SetHiding(!ShowLow);
#AddChartBubble(ShowLow and Bar == HighestAll(ParentLBarOrigin), ParentLow, "Low", Color.Yellow, 0);
def S1 = LinePlot(BarID = PLBarID,
Value = PLValue,
BarOrigin = PLBarOrigin);
# S1.SetDefaultColor(Color.RED);
# S1.SetHiding(!ShowS1);
#addChartBubble(ShowS1 and Bar == HighestAll(PLBarOrigin), PLvalue, "S1", color.red, 0);
def S2 = LinePlot(BarID = S2PLBarID,
Value = S2PLValue,
BarOrigin = S2PLBarOrigin);
# S2.SetDefaultColor(Color.RED);
# S2.SetHiding(!ShowS2);
#addChartBubble(ShowS2 and Bar == HighestAll(S2PLBarOrigin), PLvalue, "S2", color.red, 0);
def S3 = LinePlot(BarID = S3PLBarID,
Value = S3PLValue,
BarOrigin = S3PLBarOrigin);
# S3.SetDefaultColor(Color.RED);
# S3.SetHiding(!ShowS3);
#addChartBubble(ShowS3 and Bar == HighestAll(S3PLBarOrigin), PLvalue, "S3", color.red, 0);
def S4 = LinePlot(BarID = S4PLBarID,
Value = S4PLValue,
BarOrigin = S4PLBarOrigin);
# S4.SetDefaultColor(Color.RED);
# S4.SetHiding(!ShowS4);
#addChartBubble(ShowS4 and Bar == HighestAll(S4PLBarOrigin), PLvalue, "S4", color.red, 0);
def Rising012Lows = if S3 < S2 and S2 < S1 and low > S1 then 1
else double.nan;
def Rising0123Lows = if S4< S3 and S3 < S2 and S2 < S1 and low > S1 then 1
else double.nan;
def Decreasing012Highs = if R3 > R2 and R2 > R1 and high < R1 then 1
else double.nan;
def Decreasing0123Highs = if R4 > R3 AND R3 > R2 and R2 > R1 and high < R1 then 1
else double.nan;
AddLabel(Labels,
if Rising012Lows then " 123 Higher Lows"
else "",
if Rising012Lows then (createcolor(143,239,191))#keylime
else color.dark_gray);
AddLabel(Labels,
if Decreasing012Highs then " 123 Lower Highs"
else "",
if Decreasing012Highs then color.pink
else color.dark_gray);
AddLabel(Labels,
if Rising0123Lows then " 1234 Higher Lows"
else "",
if Rising0123Lows then (createcolor(143,239,191))#keylime
else color.dark_gray);
AddLabel(Labels,
if Decreasing0123Highs then " 1234 Lower Highs"
else "",
if Decreasing0123Highs then color.pink
else color.dark_gray);
Above is version of Mobius script below:
# Pivot_Array (
Please copy and paste this name to study name above)
# Mobius
# V01.09.13.2017
#hint: Plots the most recent 4 resistance pivots and support pivots. \n For scanning: Find the study in list of studies then select either BearScan or BullScan as the left side entry in the Scan Wizard and equal to as the center definition and close price as the right side entry.
# V02 Added User Inputs to control plots. Added Statistics for pivot spreads with user inputs to display.
# User Inputs
input n = 3; #hint n: periods used for pivot calculations.
input showHigh = yes;
input ShowLow = yes;
input showR1 = yes;
input showR2 = yes;
input showR3 = yes;
input showR4 = yes;
input showS1 = yes;
input showS2 = yes;
input showS3 = yes;
input showS4 = yes;
input StatsOn = yes;
input ShowSignals = yes;
# Internal Script Reference
script LinePlot {
input BarID = 0;
input Value = 0;
input BarOrigin = 0;
def ThisBar = HighestAll(BarOrigin);
def ValueLine = if BarOrigin == ThisBar
then Value
else Double.NaN;
plot P = if ThisBar - BarID <= BarOrigin
then HighestAll(ValueLine)
else Double.NaN;
}
# Variables
def o = open;
def h = high;
def l = low;
def c = close;
def bar = BarNumber();
def BBar = bar == HighestAll(bar);
# Parent High
def ParentHigh = HighestAll(h);
def ParentHBarOrigin = if h == ParentHigh
then bar
else ParentHBarOrigin[1];
def ParentHBarID = bar - HighestAll(ParentHBarOrigin);
# R1
def hh = fold i = 1 to n + 1
with p = 1
while p
do h > GetValue(h, -i);
def PivotH = if (bar > n and
h == Highest(h, n) and
hh)
then h
else Double.NaN;
def PHValue = if !IsNaN(PivotH)
then PivotH
else PHValue[1];
def PHBarOrigin = if !IsNaN(PivotH)
then bar
else PHBarOrigin[1];
def PHBarID = bar - PHBarOrigin;
# R2
def R2PHValue = if PHBarOrigin != PHBarOrigin[1]
then PHValue[1]
else R2PHValue[1];
def R2PHBarOrigin = if PHBarOrigin != PHBarOrigin[1]
then PHBarOrigin[1]
else R2PHBarOrigin[1];
def R2PHBarID = bar - R2PHBarOrigin;
# R3
def R3PHValue = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHValue[1]
else R3PHValue[1];
def R3PHBarOrigin = if R2PHBarOrigin != R2PHBarOrigin[1]
then R2PHBarOrigin[1]
else R3PHBarOrigin[1];
def R3PHBarID = bar - R3PHBarOrigin;
# R4
def R4PHValue = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHValue[1]
else R4PHValue[1];
def R4PHBarOrigin = if R3PHBarOrigin != R3PHBarOrigin[1]
then R3PHBarOrigin[1]
else R4PHBarOrigin[1];
def R4PHBarID = bar - R4PHBarOrigin;
# Parent Low
def ParentLow = LowestAll(l);
def ParentLBarOrigin = if l == ParentLow
then bar
else ParentLBarOrigin[1];
def ParentLBarID = bar - HighestAll(ParentLBarOrigin);
# S1
def ll = fold j = 1 to n + 1
with q = 1
while q
do l < GetValue(l, -j);
def PivotL = if (bar > n and
l == Lowest(l, n) and
ll)
then l
else Double.NaN;
def PLValue = if !IsNaN(PivotL)
then PivotL
else PLValue[1];
def PLBarOrigin = if !IsNaN(PivotL)
then bar
else PLBarOrigin[1];
def PLBarID = bar - PLBarOrigin;
# S2
def S2PLValue = if PLBarOrigin != PLBarOrigin[1]
then PLValue[1]
else S2PLValue[1];
def S2PLBarOrigin = if PLBarOrigin != PLBarOrigin[1]
then PLBarOrigin[1]
else S2PLBarOrigin[1];
def S2PLBarID = bar - S2PLBarOrigin;
# S3
def S3PLValue = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLValue[1]
else S3PLValue[1];
def S3PLBarOrigin = if S2PLBarOrigin != S2PLBarOrigin[1]
then S2PLBarOrigin[1]
else S3PLBarOrigin[1];
def S3PLBarID = bar - S3PLBarOrigin;
# S4
def S4PLValue = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLValue[1]
else S4PLValue[1];
def S4PLBarOrigin = if S3PLBarOrigin != S3PLBarOrigin[1]
then S3PLBarOrigin[1]
else S4PLBarOrigin[1];
def S4PLBarID = bar - S4PLBarOrigin;
#Plots
plot PR1 = LinePlot(BarID = ParentHBarID,
Value = ParentHigh,
BarOrigin = HighestAll(ParentHBarOrigin));
PR1.SetDefaultColor(Color.GREEN);
PR1.SetHiding(!showHigh);
AddChartBubble(showHigh and bar == HighestAll(bar), ParentHigh, "High", Color.YELLOW, 1);
plot R1 = LinePlot(BarID = PHBarID,
Value = PHValue,
BarOrigin = PHBarOrigin);
R1.SetDefaultColor(Color.GREEN);
R1.SetHiding(!showR1);
AddChartBubble(showR1 and bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.GREEN, 1);
plot R2 = LinePlot(BarID = R2PHBarID,
Value = R2PHValue,
BarOrigin = R2PHBarOrigin);
R2.SetDefaultColor(Color.GREEN);
R2.SetHiding(!showR2);
AddChartBubble(showR2 and bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.GREEN, 1);
plot R3 = LinePlot(BarID = R3PHBarID,
Value = R3PHValue,
BarOrigin = R3PHBarOrigin);
R3.SetDefaultColor(Color.GREEN);
R3.SetHiding(!showR3);
AddChartBubble(showR3 and bar == HighestAll(R3PHBarOrigin), PHValue, "R3", Color.GREEN, 1);
plot R4 = LinePlot(BarID = R4PHBarID,
Value = R4PHValue,
BarOrigin = R4PHBarOrigin);
R4.SetDefaultColor(Color.GREEN);
R4.SetHiding(!showR4);
AddChartBubble(showR4 and bar == HighestAll(R4PHBarOrigin), PHValue, "R4", Color.GREEN, 1);
plot PS1 = LinePlot(BarID = ParentLBarID,
Value = ParentLow,
BarOrigin = HighestAll(ParentLBarOrigin));
PS1.SetDefaultColor(Color.RED);
PS1.SetHiding(!ShowLow);
AddChartBubble(ShowLow and bar == HighestAll(ParentLBarOrigin), ParentLow, "Low", Color.YELLOW, 0);
plot S1 = LinePlot(BarID = PLBarID,
Value = PLValue,
BarOrigin = PLBarOrigin);
S1.SetDefaultColor(Color.RED);
S1.SetHiding(!showS1);
AddChartBubble(showS1 and bar == HighestAll(PLBarOrigin), PLValue, "S1", Color.RED, 0);
plot S2 = LinePlot(BarID = S2PLBarID,
Value = S2PLValue,
BarOrigin = S2PLBarOrigin);
S2.SetDefaultColor(Color.RED);
S2.SetHiding(!showS2);
AddChartBubble(showS2 and bar == HighestAll(S2PLBarOrigin), PLValue, "S2", Color.RED, 0);
plot S3 = LinePlot(BarID = S3PLBarID,
Value = S3PLValue,
BarOrigin = S3PLBarOrigin);
S3.SetDefaultColor(Color.RED);
S3.SetHiding(!showS3);
AddChartBubble(showS3 and bar == HighestAll(S3PLBarOrigin), PLValue, "S3", Color.RED, 0);
plot S4 = LinePlot(BarID = S4PLBarID,
Value = S4PLValue,
BarOrigin = S4PLBarOrigin);
S4.SetDefaultColor(Color.RED);
S4.SetHiding(!showS4);
AddChartBubble(showS4 and bar == HighestAll(S4PLBarOrigin), PLValue, "S4", Color.RED, 0);
# Signals
def UpSignal;
def DnSignal;
if c crosses above R4
{
UpSignal = bar;
}
else if c crosses above R3
{
UpSignal = bar;
}
else if c crosses above R2
{
UpSignal = bar;
}
else if c crosses above R1
{
UpSignal = bar;
}
else
{
UpSignal = Double.NaN;
}
plot UpArrows = if bar == HighestAll(UpSignal)
then l
else Double.NaN;
UpArrows.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
UpArrows.SetDefaultColor(Color.CYAN);
UpArrows.HideBubble();
UpArrows.HideTitle();
UpArrows.SetHiding(!ShowSignals);
plot dnboy = if S1 < S2 then S1 else Double.NaN;
dnboy.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
dnboy.SetLineWeight(4);
dnboy.SetDefaultColor(Color.RED);
if c crosses below S1
{
DnSignal = bar;
}
else if c crosses below S2
{
DnSignal = bar;
}
else if c crosses below S3
{
DnSignal = bar;
}
else if c crosses below S4
{
DnSignal = bar;
}
else
{
DnSignal = DnSignal[1];
}
plot DnArrow = if bar == HighestAll(DnSignal)
then h
else Double.NaN;
DnArrow.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
DnArrow.SetDefaultColor(Color.YELLOW);
DnArrow.HideBubble();
DnArrow.HideTitle();
DnArrow.SetHiding(!ShowSignals);
Plot SPACING = if S1 > R1 then 1
else if R1 < S1 then 1 else 0;