Hi guys, I keep trying to add clouds at each support and Resistance , I succeeded, but so far I can't get the clouds to hide along with the lines, I'll leave the code to see if someone helps me see what happens, For now I have only done it on the Resistance , thanks in advanced
#StudyName: BLT_HarndogLazyFractalPivots
#Version/Date: v2 01-13-2016 TOS.mx Link:
http://tos.mx/2CTLqx #Type: [Study | Strategy]
#Description: Instead of redrafting fractal pivots to frame market behavior
# this adaption of Mobius' FractalPivotsArrayV3 was modified by
# by BLT/ZZZ/LB using a Harndog test script idea to generate
# lazy fractal pivot lines.
#Requested By: Harndog in chat starting around 02/12/17
#History: TOS.mx Link:
# Notes: The idea is based on Mobius Fractal Pivot Array
http://tos.mx/Yf06LY
# Annotation:
# V02: Added ExtLine.Hide: because script was generating expansion problems
# Changed Plot Support Line (line 450) to
# plot SupportLine = if bar == ParentHbarOrigin
# then ParentHigh
# else if bar == ParentLbarOrigin
# then ParentLow
# else double.nan;
# Suggestion from Brian_ss
# Trading Notes: Play with the script properties to adjust fractal pivots,
# aggregations
# 18:58 blt_: harndog, if you still are looking for hiding pivots in your version of "lazy pivots", maybe this will help. It hides pivots when a close crosses the pivot. You can set how many crosses before a line is hidden. The bubble was also set to hide if the pivot line is hidden. The current/higher option was changed to allow for more
# Fractal Pivot Array 11 deep
# Mobius
# V03.01.2017
# V02: Added some information on Basic Wave Structure and labels to hold wave data started
# V03: Added User Input for secondary aggregations. Add a label to show what chart aggregation pivots are being plotted. Add a cloud to show first zone of support / resistance. Altered Support line plot to extend at a consistent slope. Reset UI's for WaveLabel and ShowWaves to no.
# User Inputs
input length = 300;
input averageType = AverageType.WILDERS;
input n = 10;
input WaveLabel = no;
input ShowWaves = no;
input ShowSupportResistanceCloud = no;
input select_aggperiod = {default "Current", "Higher"};
input higheragg = AggregationPeriod.THREE_MIN;
input sethiding_crosses_required = 1;
input ShowSRLevelsCloud = yes;
def closecloud = yes;
def sh = sethiding_crosses_required;
def ATR = MovingAverage(AverageType.SIMPLE, TrueRange(high, close, low), length);
def Num_Dev_Dn = ATR ;
def Num_Dev_up = - ATR ;
# 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;
def h;
def l;
def c;
switch (select_aggperiod) {
case Current:
o = open;
h = high;
l = low;
c = if IsNaN(close) then c[1] else close;
case Higher:
o = open(period = higheragg);
h = high(period = higheragg);
l = low(period = higheragg);
c = if IsNaN(close(period = higheragg)) then c[1] else close(period = higheragg);
}
def bar = BarNumber();
def BBar = bar == HighestAll(bar);
def nan = Double.NaN;
# 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;
def xh = if h == hh then c else nan;
#plot hh_ = if PivotH >= HighestAll(xh) then HighestAll(if IsNaN(close[-1]) then hh else nan) else nan;
#hh_.SetDefaultColor(Color.RED);
# 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;
# R5
def R5PHValue = if R4PHBarOrigin != R4PHBarOrigin[1] then R4PHValue[1] else R5PHValue[1];
def R5PHBarOrigin = if R4PHBarOrigin != R4PHBarOrigin[1] then R4PHBarOrigin[1] else R5PHBarOrigin[1];
def R5PHBarID = bar - R5PHBarOrigin;
# R6
def R6PHValue = if R5PHBarOrigin != R5PHBarOrigin[1] then R5PHValue[1] else R6PHValue[1];
def R6PHBarOrigin = if R5PHBarOrigin != R5PHBarOrigin[1] then R5PHBarOrigin[1] else R6PHBarOrigin[1];
def R6PHBarID = bar - R6PHBarOrigin;
# R5
def R7PHValue = if R6PHBarOrigin != R6PHBarOrigin[1] then R6PHValue[1] else R7PHValue[1];
def R7PHBarOrigin = if R6PHBarOrigin != R6PHBarOrigin[1] then R6PHBarOrigin[1] else R7PHBarOrigin[1];
def R7PHBarID = bar - R7PHBarOrigin;
# R8
def R8PHValue = if R7PHBarOrigin != R7PHBarOrigin[1] then R7PHValue[1] else R8PHValue[1];
def R8PHBarOrigin = if R7PHBarOrigin != R7PHBarOrigin[1] then R7PHBarOrigin[1] else R8PHBarOrigin[1];
def R8PHBarID = bar - R8PHBarOrigin;
# R9
def R9PHValue = if R8PHBarOrigin != R8PHBarOrigin[1] then R8PHValue[1] else R9PHValue[1];
def R9PHBarOrigin = if R8PHBarOrigin != R8PHBarOrigin[1] then R8PHBarOrigin[1] else R9PHBarOrigin[1];
def R9PHBarID = bar - R9PHBarOrigin;
# R10
def R10PHValue = if R9PHBarOrigin != R9PHBarOrigin[1] then R9PHValue[1] else R10PHValue[1];
def R10PHBarOrigin = if R9PHBarOrigin != R9PHBarOrigin[1] then R9PHBarOrigin[1] else R10PHBarOrigin[1];
def R10PHBarID = bar - R10PHBarOrigin;
# Parent Low
def ParentLow = LowestAll(l);
def ParentLBarOrigin = if l == ParentLow then bar else ParentLBarOrigin[1];
def ParentLBarID = bar - 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;
# S5
def S5PLValue = if S4PLBarOrigin != S4PLBarOrigin[1] then S4PLValue[1] else S5PLValue[1];
def S5PLBarOrigin = if S4PLBarOrigin != S4PLBarOrigin[1] then S4PLBarOrigin[1] else S5PLBarOrigin[1];
def S5PLBarID = bar - S5PLBarOrigin;
# S6
def S6PLValue = if S5PLBarOrigin != S5PLBarOrigin[1] then S5PLValue[1] else S6PLValue[1];
def S6PLBarOrigin = if S5PLBarOrigin != S5PLBarOrigin[1] then S5PLBarOrigin[1] else S6PLBarOrigin[1];
def S6PLBarID = bar - S6PLBarOrigin;
# S7
def S7PLValue = if S6PLBarOrigin != S6PLBarOrigin[1] then S6PLValue[1] else S7PLValue[1];
def S7PLBarOrigin = if S6PLBarOrigin != S6PLBarOrigin[1] then S6PLBarOrigin[1] else S7PLBarOrigin[1];
def S7PLBarID = bar - S7PLBarOrigin;
# S8
def S8PLValue = if S7PLBarOrigin != S7PLBarOrigin[1] then S7PLValue[1] else S8PLValue[1];
def S8PLBarOrigin = if S7PLBarOrigin != S7PLBarOrigin[1] then S7PLBarOrigin[1] else S8PLBarOrigin[1];
def S8PLBarID = bar - S8PLBarOrigin;
# S9
def S9PLValue = if S8PLBarOrigin != S8PLBarOrigin[1] then S8PLValue[1] else S9PLValue[1];
def S9PLBarOrigin = if S8PLBarOrigin != S8PLBarOrigin[1] then S8PLBarOrigin[1] else S9PLBarOrigin[1];
def S9PLBarID = bar - S9PLBarOrigin;
# S10
def S10PLValue = if S9PLBarOrigin != S9PLBarOrigin[1] then S9PLValue[1] else S10PLValue[1];
def S10PLBarOrigin = if S9PLBarOrigin != S9PLBarOrigin[1] then S9PLBarOrigin[1] else S10PLBarOrigin[1];
def S10PLBarID = bar - S10PLBarOrigin;
# Plots
plot PR1 = LinePlot(BarID = ParentHBarID, Value = ParentHigh, BarOrigin = HighestAll(ParentHBarOrigin));
PR1.SetDefaultColor(Color.RED);
AddChartBubble(bar == HighestAll(ParentHBarOrigin), ParentHigh, "B", Color.YELLOW, 1);
plot R1 = LinePlot(BarID = PHBarID, Value = PHValue, BarOrigin = PHBarOrigin);
R1.SetDefaultColor(Color.RED);
def r1v = if bar == HighestAll(PHBarOrigin) then h else r1v[1];
def crossr1 = if bar < HighestAll(PHBarOrigin) then 0 else if bar > HighestAll(PHBarOrigin) and c crosses HighestAll(r1v) then crossr1[1] + 1 else crossr1[1];
R1.SetHiding(crossr1 >= sh);
AddChartBubble(HighestAll(crossr1) < sh and bar == HighestAll(PHBarOrigin), PHValue, "R1", Color.RED, 1);
plot R1_ = LinePlot(BarID = PHBarID, Value = R1 + Num_Dev_up, BarOrigin = PHBarOrigin);
R1_.SetDefaultColor(Color.RED);
R1_.SetHiding(crossr1 >= sh);
AddCloud(if ShowSRLevelsCloud then R1_ else Double.NaN , R1, Color.LIGHT_RED , Color.LIGHT_RED);
plot R2 = LinePlot(BarID = R2PHBarID, Value = R2PHValue, BarOrigin = R2PHBarOrigin);
R2.SetDefaultColor(Color.RED);
def r2v = if bar == HighestAll(R2PHBarOrigin) then h else r2v[1];
def crossr2 = if bar < HighestAll(R2PHBarOrigin) then 0 else if bar > HighestAll(R2PHBarOrigin) and c crosses HighestAll(r2v) then crossr2[1] + 1 else crossr2[1];
R2.SetHiding(crossr2 >= sh);
AddChartBubble(HighestAll(crossr2) < sh and bar == HighestAll(R2PHBarOrigin), PHValue, "R2", Color.RED, 1);
plot R2_ = LinePlot(BarID = R2PHBarID, Value = R2 + Num_Dev_up, BarOrigin = R2PHBarOrigin);
R2_.SetDefaultColor(Color.RED);
R2_.SetHiding(crossr2 >= sh);
AddCloud(if ShowSRLevelsCloud then R2_ else Double.NaN , R2, Color.LIGHT_RED , Color.LIGHT_RED);
plot R3 = LinePlot(BarID = R3PHBarID, Value = R3PHValue, BarOrigin = R3PHBarOrigin);
R3.SetDefaultColor(Color.RED);
def r3v = if bar == HighestAll(R3PHBarOrigin) then h else r3v[1];
def crossr3 = if bar < HighestAll(R3PHBarOrigin) then 0 else if bar > HighestAll(R3PHBarOrigin) and c crosses HighestAll(r3v) then crossr3[1] + 1 else crossr3[1];
R3.SetHiding(crossr3 >= sh);
AddChartBubble(HighestAll(crossr3) < sh and bar == HighestAll(R3PHBarOrigin), PHValue, "R3", Color.RED, 1);
plot R3_ = LinePlot(BarID = R3PHBarID, Value = R3 + Num_Dev_up, BarOrigin = R3PHBarOrigin);
R3_.SetLineWeight(1);
R3_.SetDefaultColor(Color.RED);
R3_.SetHiding(crossr3 >= sh);
AddCloud(if ShowSRLevelsCloud then R3_ else Double.NaN , R3, Color.LIGHT_RED , Color.LIGHT_RED);
plot R4 = LinePlot(BarID = R4PHBarID, Value = R4PHValue, BarOrigin = R4PHBarOrigin);
R4.SetDefaultColor(Color.RED);
def r4v = if bar == HighestAll(R4PHBarOrigin) then h else r4v[1];
def crossr4 = if bar < HighestAll(R4PHBarOrigin) then 0 else if bar > HighestAll(R4PHBarOrigin) and c crosses HighestAll(r4v) then crossr4[1] + 1 else crossr4[1];
R4.SetHiding(crossr4 >= sh);
AddChartBubble(HighestAll(crossr4) < sh and bar == HighestAll(R4PHBarOrigin), PHValue, "R4", Color.RED, 1);
plot R4_ = LinePlot(BarID = R4PHBarID, Value = R4 + Num_Dev_up, BarOrigin = R4PHBarOrigin);
R4_.SetLineWeight(1);
R4_.SetDefaultColor(Color.LIGHT_RED);
R4_.SetHiding(crossr4 >= sh);
AddCloud(if ShowSRLevelsCloud then R4_ else Double.NaN , R4, Color.LIGHT_RED , Color.LIGHT_RED);
plot R5 = LinePlot(BarID = R5PHBarID, Value = R5PHValue, BarOrigin = R5PHBarOrigin);
R5.SetDefaultColor(Color.RED);
def r5v = if bar == HighestAll(R5PHBarOrigin) then h else r5v[1];
def crossr5 = if bar < HighestAll(R5PHBarOrigin) then 0 else if bar > HighestAll(R5PHBarOrigin) and c crosses HighestAll(r5v) then crossr5[1] + 1 else crossr5[1];
R5.SetHiding(crossr5 >= sh);
AddChartBubble(HighestAll(crossr5) < sh and bar == HighestAll(R5PHBarOrigin), PHValue, "R5", Color.RED, 1);
plot R5_ = LinePlot(BarID = R5PHBarID, Value = R5 + Num_Dev_up, BarOrigin = R5PHBarOrigin);
R5_.SetDefaultColor(Color.RED);
R5_.SetHiding(crossr5 >= sh);
AddCloud(if ShowSRLevelsCloud then R5_ else Double.NaN , R5, Color.LIGHT_RED , Color.LIGHT_RED);
plot R6 = LinePlot(BarID = R6PHBarID, Value = R6PHValue, BarOrigin = R6PHBarOrigin);
R6.SetDefaultColor(Color.RED);
def r6v = if bar == HighestAll(R6PHBarOrigin) then h else r6v[1];
def crossr6 = if bar < HighestAll(R6PHBarOrigin) then 0 else if bar > HighestAll(R6PHBarOrigin) and c crosses HighestAll(r6v) then crossr6[1] + 1 else crossr6[1];
R6.SetHiding(crossr6 >= sh);
AddChartBubble(HighestAll(crossr6) < sh and bar == HighestAll(R6PHBarOrigin), PHValue, "R6", Color.RED, 1);
plot R6_ = LinePlot(BarID = R6PHBarID, Value = R6+Num_Dev_up, BarOrigin = R6PHBarOrigin);
R6_.SetDefaultColor(Color.RED);
R6_.SetHiding(crossr6 >= sh);
AddCloud(if ShowSRLevelsCloud then R6_ else Double.NaN , R6, Color.LIGHT_RED , Color.LIGHT_RED);
plot R7 = LinePlot(BarID = R7PHBarID, Value = R7PHValue, BarOrigin = R7PHBarOrigin);
R7.SetDefaultColor(Color.RED);
def r7v = if bar == HighestAll(R7PHBarOrigin) then h else r7v[1];
def crossr7 = if bar < HighestAll(R7PHBarOrigin) then 0 else if bar > HighestAll(R7PHBarOrigin) and c crosses HighestAll(r7v) then crossr7[1] + 1 else crossr7[1];
R7.SetHiding(crossr7 >= sh);
AddChartBubble(HighestAll(crossr7) < sh and bar == HighestAll(R7PHBarOrigin), PHValue, "R7", Color.RED, 1);
plot R7_ = LinePlot(BarID = R7PHBarID, Value = R7 + Num_Dev_up, BarOrigin = R7PHBarOrigin);
R7_.SetDefaultColor(Color.RED);
R7_.SetHiding(crossr7 >= sh);
AddCloud(if ShowSRLevelsCloud then R7_ else Double.NaN , R7, Color.LIGHT_RED , Color.LIGHT_RED);
plot R8 = LinePlot(BarID = R8PHBarID, Value = R8PHValue, BarOrigin = R8PHBarOrigin);
R8.SetDefaultColor(Color.RED);
def r8v = if bar == HighestAll(R8PHBarOrigin) then h else r8v[1];
def crossr8 = if bar < HighestAll(R8PHBarOrigin) then 0 else if bar > HighestAll(R8PHBarOrigin) and c crosses HighestAll(r8v) then crossr8[1] + 1 else crossr8[1];
R8.SetHiding(crossr8 >= sh);
AddChartBubble(HighestAll(crossr8) < sh and bar == HighestAll(R8PHBarOrigin), PHValue, "R8", Color.RED, 1);
plot R8_ = LinePlot(BarID = R8PHBarID, Value = R8 + Num_Dev_up, BarOrigin = R8PHBarOrigin);
R8_.SetDefaultColor(Color.RED);
R8_.SetHiding(crossr8 >= sh);
AddCloud(if ShowSRLevelsCloud then R8_ else Double.NaN , R8, Color.LIGHT_RED , Color.LIGHT_RED);
plot R9 = LinePlot(BarID = R9PHBarID, Value = R9PHValue, BarOrigin = R9PHBarOrigin);
R9.SetDefaultColor(Color.RED);
def r9v = if bar == HighestAll(R9PHBarOrigin) then h else r9v[1];
def crossr9 = if bar < HighestAll(R9PHBarOrigin) then 0 else if bar > HighestAll(R9PHBarOrigin) and c crosses HighestAll(r9v) then crossr9[1] + 1 else crossr9[1];
R9.SetHiding(crossr9 >= sh);
AddChartBubble(HighestAll(crossr9) < sh and bar == HighestAll(R9PHBarOrigin), PHValue, "R9", Color.RED, 1);
plot R9_ = LinePlot(BarID = R9PHBarID, Value = R9 + Num_Dev_up, BarOrigin = R9PHBarOrigin);
R9_.SetDefaultColor(Color.RED);
R9_.SetHiding(crossr9 >= sh);
AddCloud(if ShowSRLevelsCloud then R9_ else Double.NaN , R9, Color.LIGHT_RED , Color.LIGHT_RED);
plot R10 = LinePlot(BarID = R10PHBarID, Value = R10PHValue, BarOrigin = R10PHBarOrigin);
R10.SetDefaultColor(Color.RED);
def r10v = if bar == HighestAll(R10PHBarOrigin) then h else r10v[1];
def crossr10 = if bar < HighestAll(R10PHBarOrigin) then 0 else if bar > HighestAll(R10PHBarOrigin) and c crosses HighestAll(r10v) then crossr10[1] + 1 else crossr10[1];
R10.SetHiding(crossr10 >= sh);
AddChartBubble(HighestAll(crossr10) < sh and bar == HighestAll(R10PHBarOrigin), PHValue, "R10", Color.RED, 1);
plot R10_ = LinePlot(BarID = R10PHBarID, Value = R10 + Num_Dev_up, BarOrigin = R10PHBarOrigin);
R10_.SetDefaultColor(Color.RED);
R10_.SetHiding(crossr10 >= sh);
AddCloud(if ShowSRLevelsCloud then R10_ else Double.NaN , R10, Color.LIGHT_RED , Color.LIGHT_RED);
plot PS1 = LinePlot(BarID = ParentLBarID, Value = ParentLow, BarOrigin = HighestAll(ParentLBarOrigin));
PS1.SetDefaultColor(Color.GREEN);
AddChartBubble(bar == HighestAll(ParentLBarOrigin), ParentLow, "A", Color.YELLOW, 0);
plot S1 = LinePlot(BarID = PLBarID, Value = PLValue, BarOrigin = PLBarOrigin);
S1.SetDefaultColor(Color.GREEN);
def s1v = if bar == HighestAll(PLBarOrigin) then l else s1v[1];
def crosss1 = if bar < HighestAll(PLBarOrigin) then 0 else if bar > HighestAll(PLBarOrigin) and c crosses HighestAll(s1v) then crosss1[1] + 1 else crosss1[1];
S1.SetHiding(crosss1 >= sh);
AddChartBubble(HighestAll(crosss1) < sh and bar == HighestAll(PLBarOrigin), PLValue, "S1", Color.GREEN, 0);
plot S2 = LinePlot(BarID = S2PLBarID,
Value = S2PLValue,
BarOrigin = S2PLBarOrigin);
S2.SetDefaultColor(Color.GREEN);
def s2v = if bar == HighestAll(S2PLBarOrigin) then l else s2v[1];
def crosss2 = if bar < HighestAll(S2PLBarOrigin) then 0 else if bar > HighestAll(S2PLBarOrigin) and c crosses HighestAll(s2v) then crosss2[1] + 1 else crosss2[1];
S2.SetHiding(crosss2 >= sh);
AddChartBubble(HighestAll(crosss2) < sh and bar == HighestAll(S2PLBarOrigin), PLValue, "S2", Color.GREEN, 0);
plot S3 = LinePlot(BarID = S3PLBarID, Value = S3PLValue, BarOrigin = S3PLBarOrigin);
S3.SetDefaultColor(Color.GREEN);
def s3v = if bar == HighestAll(S3PLBarOrigin) then l else s3v[1];
def crosss3 = if bar < HighestAll(S3PLBarOrigin) then 0 else if bar > HighestAll(S3PLBarOrigin) and c crosses HighestAll(s3v) then crosss3[1] + 1 else crosss3[1];
S3.SetHiding(crosss3 >= sh);
AddChartBubble(HighestAll(crosss3) < sh and bar == HighestAll(S3PLBarOrigin), PLValue, "S3", Color.GREEN, 0);
plot S4 = LinePlot(BarID = S4PLBarID, Value = S4PLValue, BarOrigin = S4PLBarOrigin);
S4.SetDefaultColor(Color.GREEN);
def s4v = if bar == HighestAll(S4PLBarOrigin) then l else s4v[1];
def crosss4 = if bar < HighestAll(S4PLBarOrigin) then 0 else if bar > HighestAll(S4PLBarOrigin) and c crosses HighestAll(s4v) then crosss4[1] + 1 else crosss4[1];
S4.SetHiding(crosss4 >= sh);
AddChartBubble(HighestAll(crosss4) < sh and bar == HighestAll(S4PLBarOrigin), PLValue, "S4", Color.GREEN, 0);
plot S5 = LinePlot(BarID = S5PLBarID,
Value = S5PLValue,
BarOrigin = S5PLBarOrigin);
S5.SetDefaultColor(Color.GREEN);
def s5v = if bar == HighestAll(S5PLBarOrigin) then l else s5v[1];
def crosss5 = if bar < HighestAll(S5PLBarOrigin) then 0 else if bar > HighestAll(S5PLBarOrigin) and c crosses HighestAll(s5v) then crosss5[1] + 1 else crosss5[1];
S5.SetHiding(crosss5 >= sh);
AddChartBubble(HighestAll(crosss5) < sh and bar == HighestAll(S5PLBarOrigin), PLValue, "S5", Color.GREEN, 0);
plot S6 = LinePlot(BarID = S6PLBarID, Value = S6PLValue, BarOrigin = S6PLBarOrigin);
S6.SetDefaultColor(Color.GREEN);
def s6v = if bar == HighestAll(S6PLBarOrigin) then l else s6v[1];
def crosss6 = if bar < HighestAll(S6PLBarOrigin) then 0 else if bar > HighestAll(S6PLBarOrigin) and c crosses HighestAll(s6v) then crosss6[1] + 1 else crosss6[1];
S6.SetHiding(crosss6 >= sh);
AddChartBubble(HighestAll(crosss6) < sh and bar == HighestAll(S6PLBarOrigin), PLValue, "S6", Color.GREEN, 0);
plot S7 = LinePlot(BarID = S7PLBarID, Value = S7PLValue, BarOrigin = S7PLBarOrigin);
S7.SetDefaultColor(Color.GREEN);
def s7v = if bar == HighestAll(S7PLBarOrigin) then l else s7v[1];
def crosss7 = if bar < HighestAll(S7PLBarOrigin) then 0 else if bar > HighestAll(S7PLBarOrigin) and c crosses HighestAll(s7v) then crosss7[1] + 1 else crosss7[1];
S7.SetHiding(crosss7 >= sh);
AddChartBubble(HighestAll(crosss7) < sh and bar == HighestAll(S7PLBarOrigin), PLValue, "S7", Color.GREEN, 0);
plot S8 = LinePlot(BarID = S8PLBarID, Value = S8PLValue, BarOrigin = S8PLBarOrigin);
S8.SetDefaultColor(Color.GREEN);
def s8v = if bar == HighestAll(S8PLBarOrigin) then l else s8v[1];
def crosss8 = if bar < HighestAll(S8PLBarOrigin) then 0 else if bar > HighestAll(S8PLBarOrigin) and c crosses HighestAll(s8v) then crosss8[1] + 1 else crosss8[1];
S8.SetHiding(crosss8 >= sh);
AddChartBubble(HighestAll(crosss8) < sh and bar == HighestAll(S8PLBarOrigin), PLValue, "S8", Color.GREEN, 0);
plot S9 = LinePlot(BarID = S9PLBarID, Value = S9PLValue, BarOrigin = S9PLBarOrigin);
def s9v = if bar == HighestAll(S9PLBarOrigin) then l else s9v[1];
def crosss9 = if bar < HighestAll(S9PLBarOrigin) then 0 else if bar > HighestAll(S9PLBarOrigin) and c crosses HighestAll(s9v) then crosss9[1] + 1 else crosss9[1];
S9.SetHiding(crosss9 >= sh);
AddChartBubble(HighestAll(crosss9) < sh and bar == HighestAll(S9PLBarOrigin), PLValue, "S9", Color.GREEN, 0);
S9.SetDefaultColor(Color.GREEN);
plot S10 = LinePlot(BarID = S10PLBarID, Value = S10PLValue, BarOrigin = S10PLBarOrigin);
S10.SetDefaultColor(Color.GREEN);
def s10v = if bar == HighestAll(S10PLBarOrigin) then l else s10v[1];
def crosss10 = if bar < HighestAll(S10PLBarOrigin) then 0 else if bar > HighestAll(S10PLBarOrigin) and c crosses HighestAll(s10v) then crosss10[1] + 1 else crosss10[1];
S10.SetHiding(crosss10 >= sh);
AddChartBubble(HighestAll(crosss10) < sh and bar == HighestAll(S10PLBarOrigin), PLValue, "S10", Color.GREEN, 0);
# End Code Fractal Array 11 Deep
# Trend Line
def PH_low = if bar == ParentHBarOrigin then l else PH_low[1];
def firstParentBar = Min(HighestAll(ParentLBarOrigin), HighestAll(ParentHBarOrigin));
def lastParentBar = Max(HighestAll(ParentLBarOrigin), HighestAll(ParentHBarOrigin));
def firstParent = if bar == firstParentBar and l == PH_low then PH_low else if bar == firstParentBar and l == ParentLow then ParentLow else firstParent[1];
def lastParent = if bar == lastParentBar and l == PH_low then PH_low else if bar == lastParentBar and l == ParentLow then ParentLow else lastParent[1];
def slope = (lastParent - firstParent) / (lastParentBar - firstParentBar);
plot SupportLine = if bar == ParentHBarOrigin then ParentHigh else if bar == ParentLBarOrigin then ParentLow else Double.NaN;
SupportLine.EnableApproximation();
SupportLine.SetDefaultColor(Color.GRAY);
SupportLine.SetLineWeight(2);
SupportLine.SetStyle(Curve.LONG_DASH);
plot ExtLine = if bar >= lastParentBar then (bar - lastParentBar) * slope + lastParent else Double.NaN;
ExtLine.EnableApproximation();
ExtLine.SetDefaultColor(Color.GRAY);
ExtLine.SetLineWeight(2);
ExtLine.SetStyle(Curve.LONG_DASH);
ExtLine.Hide();
AddChartBubble(WaveLabel and bar == HighestAll(bar), HighestAll(high),
"Basic Elliott Wave Rules:" + "\n" +
"Wave (2) cannot retrace past the start of Wave (1)" + "\n" +
"Wave (3) cannot be the shortest wave in a 5 wave sequence." + "\n" +
"Wave (4) cannot retrace into Wave (1)" + "\n", Color.WHITE, 1);
plot waves = if !IsNaN(PivotH) then PivotH else if !IsNaN(PivotL) then PivotL else Double.NaN;
waves.SetStyle(Curve.FIRM);
waves.EnableApproximation();
waves.SetDefaultColor(Color.CYAN);
waves.SetLineWeight(2);
waves.SetHiding(!ShowWaves);
# Wave Pattern
def ParentMaxBar = Max(ParentHBarOrigin, ParentLBarOrigin);
def ParentMinBar = Min(ParentLBarOrigin, ParentLBarOrigin);
def deltaPos = if ParentHBarOrigin == ParentMaxBar then 1 else 0;
# Clouds
AddCloud(if ShowSupportResistanceCloud then R1 else Double.NaN, S1, Color.DARK_GRAY, Color.DARK_GRAY);