This looks for 4 patterns,
. Nirvana - cyan , 3 bars, middle bar is smaller
. HolyGrail - magenta , 3 bars, middle bar is bigger
. Inside bar - yellow , 2 bars , right bar is smaller
. Outside bar - white , 2 bars , right bar is bigger
each pattern is drawn in a different color.
a colored label is shown for each pattern that is turned on.
the last bar in a pattern has a different color, i left it that way from the original.
the high and low of the last bar in a pattern, are the levels that are compared to price.
up arrow , when price is above a high.
down arrow , when price is below a low.
setting this to yes, will plot only the arrows that change direction. when an arrow is different that the last one.
input show_only_first_changed_arrows = yes;
the arrows for the 4 patterns are drawn at different distances from the candles, so if all 4 are drawn, they are visible and stacked, not covered up.
there are 3 variables that affect how the arrows are placed.
def arrow_size = 1;
def arrow_sp_fac = 0.1;
def sizex = 0.8;
can show horizontal lines from the high and low.
can turn any of the 4 patterns on or off.
settings
nirvana - zoomed in , first changed arrows
nirvana - zoom out, multiple triggers
all 4 signals - all arrows
each signal arrow has a different price factor, so they appear stacked, not on top of each other.
. Nirvana - cyan , 3 bars, middle bar is smaller
. HolyGrail - magenta , 3 bars, middle bar is bigger
. Inside bar - yellow , 2 bars , right bar is smaller
. Outside bar - white , 2 bars , right bar is bigger
each pattern is drawn in a different color.
a colored label is shown for each pattern that is turned on.
the last bar in a pattern has a different color, i left it that way from the original.
the high and low of the last bar in a pattern, are the levels that are compared to price.
up arrow , when price is above a high.
down arrow , when price is below a low.
setting this to yes, will plot only the arrows that change direction. when an arrow is different that the last one.
input show_only_first_changed_arrows = yes;
the arrows for the 4 patterns are drawn at different distances from the candles, so if all 4 are drawn, they are visible and stacked, not covered up.
there are 3 variables that affect how the arrows are placed.
def arrow_size = 1;
def arrow_sp_fac = 0.1;
def sizex = 0.8;
can show horizontal lines from the high and low.
can turn any of the 4 patterns on or off.
Ruby:
#Nirvana Holy Grail Inside Bar Outside Bar For ThinkOrSwim
#@halcyonguy 2/2022
# hilite_bars_higherlower_02
def na = double.nan;
def bn = barnumber();
input show_Nirvana = yes;
input show_HolyGrail = yes;
input show_Inside_bar = yes;
input show_Outside_bar = yes;
# Nirvana - color.CYAN
# HolyGrail - color.magenta
# Inside bar - color.yellow
# Outside bar - color.WHITE
input show_only_first_changed_arrows = yes;
input show_bar_level_lines = yes;
def arrow_size = 1;
def arrow_sp_fac = 0.1;
def sizex = 0.8;
# ----------------------------------------------
##NIRVANA - Color.cyan
#def nirvana = low[1] > low[2] and low < low[1] and high[1] < high[2] and high > high[1];
def nirvana = if !show_Nirvana then 0 else
high[2] > high[1] and high[1] < high[0]
and
low[2] < low[1] and low[1] > low[0];
# keep hi/lo of last signal bar
def nirvana_hi = if bn == 1 or nirvana[-1] then na else if nirvana then high else nirvana_hi[1];
def nirvana_lo = if bn == 1 or nirvana[-1] then na else if nirvana then low else nirvana_lo[1];
plot z1 = if (!show_NIRVANA or !show_bar_level_lines) then na else nirvana_hi;
z1.SetDefaultColor(Color.cyan);
#z1.hidebubble();
plot z2 = if (!show_NIRVANA or !show_bar_level_lines) then na else nirvana_lo;
z2.SetDefaultColor(Color.cyan);
#z2.hidebubble();
def narrows = if bn == 1 then 0
else if nirvana then 0
else if close > nirvana_hi then 1
else if close < nirvana_lo then -1
else narrows[1];
def nuparrow_en = if (show_only_first_changed_arrows and (close > nirvana_hi and narrows[1] <> 1)) then 1
else if (!show_only_first_changed_arrows and close > nirvana_hi) then 1
else 0;
def ndwnarrow_en = if (show_only_first_changed_arrows and (close < nirvana_lo and narrows[1] <> -1)) then 1
else if (!show_only_first_changed_arrows and close < nirvana_lo) then 1
else 0;
# row 1 of arrows
plot nirup = if (show_NIRVANA and nuparrow_en) then (low - (arrow_sp_fac * (arrow_size * sizex) * 0)) else na;
nirup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
nirup.SetDefaultColor(Color.cyan);
nirup.SetLineWeight(arrow_size);
nirup.hidebubble();
plot nirdwn = if (show_NIRVANA and ndwnarrow_en) then (high + (arrow_sp_fac * (arrow_size * sizex) * 0)) else na;
nirdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
nirdwn.SetDefaultColor(Color.cyan);
nirdwn.SetLineWeight(arrow_size);
nirdwn.hidebubble();
addchartbubble(0, low*0.997,
bn + "\n" +
nirvana + " n\n" +
nirvana_hi + " hi\n" +
nirvana_lo + " lo\n" +
narrows + " arr\n" +
nuparrow_en + " up\n" +
ndwnarrow_en + " dwn"
, color.yellow, no);
# ----------------------------------------------
# HolyGrail - magenta
#plot holyGrail = low[1] < low[2] and high[1] > high[2] and low > low[1] and high < high[1];
def holyGrail = if !show_holygrail then 0 else
high[2] < high[1] and high[1] > high[0]
and
low[2] > low[1] and low[1] < low[0];
# keep hi/lo of last signal bar
def holygrail_hi = if bn == 1 or holygrail[-1] then na else if holygrail then high else holygrail_hi[1];
def holygrail_lo = if bn == 1 or holygrail[-1] then na else if holygrail then low else holygrail_lo[1];
plot z3 = if (!show_holygrail or !show_bar_level_lines) then na else holygrail_hi;
z3.SetDefaultColor(Color.magenta);
#z3.hidebubble();
plot z4 = if (!show_holygrail or !show_bar_level_lines) then na else holygrail_lo;
z4.SetDefaultColor(Color.magenta);
#z4.hidebubble();
def harrows = if bn == 1 then 0
else if holygrail then 0
else if close > holygrail_hi then 1
else if close < holygrail_lo then -1
else harrows[1];
def huparrow_en = if (show_only_first_changed_arrows and (close > holygrail_hi and harrows[1] <> 1)) then 1
else if (!show_only_first_changed_arrows and close > holygrail_hi) then 1
else 0;
def hdwnarrow_en = if (show_only_first_changed_arrows and (close < holygrail_lo and harrows[1] <> -1)) then 1
else if (!show_only_first_changed_arrows and close < holygrail_lo) then 1
else 0;
# row 2 of arrows
plot holup = if (show_holygrail and huparrow_en) then (low - (arrow_sp_fac * (arrow_size * sizex) * 1)) else na;
holup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
holup.SetDefaultColor(Color.magenta);
holup.SetLineWeight(arrow_size);
holup.hidebubble();
plot holdwn = if (show_holygrail and hdwnarrow_en) then (high + (arrow_sp_fac* (arrow_size * sizex) * 1)) else na;
holdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
holdwn.SetDefaultColor(Color.magenta);
holdwn.SetLineWeight(arrow_size);
holdwn.hidebubble();
# ----------------------------------------------
# Inside_bar - yellow
#plot inBar = low > low[1] and high < high[1];
def inBar2 = if !show_inside_bar then 0 else
low[1] < low[0] and high[1] > high[0];
# insidebar is same as 2nd half of HolyGrail
# if bar is a HolyGrail , then disable insidebar
def inside_bar = if HolyGrail then 0 else inbar2;
# keep hi/lo of last signal bar
def inside_bar_hi = if bn == 1 or inside_bar[-1] then na else if inside_bar then high else inside_bar_hi[1];
def inside_bar_lo = if bn == 1 or inside_bar[-1] then na else if inside_bar then low else inside_bar_lo[1];
plot z5 = if (!show_inside_bar or !show_bar_level_lines) then na else inside_bar_hi;
z5.SetDefaultColor(Color.yellow);
#z5.hidebubble();
plot z6 = if (!show_inside_bar or !show_bar_level_lines) then na else inside_bar_lo;
z6.SetDefaultColor(Color.yellow);
#z6.hidebubble();
def iarrows = if bn == 1 then 0
else if inside_bar then 0
else if close > inside_bar_hi then 1
else if close < inside_bar_lo then -1
else iarrows[1];
def iuparrow_en = if (show_only_first_changed_arrows and (close > inside_bar_hi and iarrows[1] <> 1)) then 1
else if (!show_only_first_changed_arrows and close > inside_bar_hi) then 1
else 0;
def idwnarrow_en = if (show_only_first_changed_arrows and (close < inside_bar_lo and iarrows[1] <> -1)) then 1
else if (!show_only_first_changed_arrows and close < inside_bar_lo) then 1
else 0;
# row 3 of arrows
plot insup = if (show_inside_bar and iuparrow_en) then (low - (arrow_sp_fac * (arrow_size * sizex) * 2)) else na;
insup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
insup.SetDefaultColor(Color.yellow);
insup.SetLineWeight(arrow_size);
insup.hidebubble();
plot insdwn = if (show_inside_bar and idwnarrow_en) then (high + (arrow_sp_fac * (arrow_size * sizex) * 2)) else na;
insdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
insdwn.SetDefaultColor(Color.yellow);
insdwn.SetLineWeight(arrow_size);
insdwn.hidebubble();
# ----------------------------------------------
# Outside_Bar - white
#plot outBar2 = low < low[1] and high > high[1];
def outBar2 = if !show_outside_bar then 0 else
low[1] > low[0] and high[1] < high[0];
# outsidebar is same as 2nd half of nirvana
# if bar is a nirvana , then disable outsidebar
def outside_bar = if nirvana then 0 else outbar2;
# keep hi/lo of last signal bar
def outside_bar_hi = if bn == 1 or outside_bar[-1] then na else if outside_bar then high else outside_bar_hi[1];
def outside_bar_lo = if bn == 1 or outside_bar[-1] then na else if outside_bar then low else outside_bar_lo[1];
plot z7 = if (!show_outside_bar or !show_bar_level_lines) then na else outside_bar_hi;
z7.SetDefaultColor(Color.white);
#z7.hidebubble();
plot z8 = if (!show_outside_bar or !show_bar_level_lines) then na else outside_bar_lo;
z8.SetDefaultColor(Color.white);
#z8.hidebubble();
def oarrows = if bn == 1 then 0
else if outside_bar then 0
else if close > outside_bar_hi then 1
else if close < outside_bar_lo then -1
else oarrows[1];
def ouparrow_en = if (show_only_first_changed_arrows and (close > outside_bar_hi and oarrows[1] <> 1)) then 1
else if (!show_only_first_changed_arrows and close > outside_bar_hi) then 1
else 0;
def odwnarrow_en = if (show_only_first_changed_arrows and (close < outside_bar_lo and oarrows[1] <> -1)) then 1
else if (!show_only_first_changed_arrows and close < outside_bar_lo) then 1
else 0;
# row 4 of arrows
plot outsup = if (show_outside_bar and ouparrow_en) then (low - (arrow_sp_fac * (arrow_size * sizex) * 3)) else na;
outsup.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
outsup.SetDefaultColor(Color.white);
outsup.SetLineWeight(arrow_size);
outsup.hidebubble();
plot outsdwn = if (show_outside_bar and odwnarrow_en) then (high + (arrow_sp_fac * (arrow_size * sizex) * 3)) else na;
outsdwn.SetPaintingStrategy(PaintingStrategy.ARROW_down);
outsdwn.SetDefaultColor(Color.white);
outsdwn.SetLineWeight(arrow_size);
outsdwn.hidebubble();
# ----------------------------------------------
addlabel(show_NIRVANA, "Nirvana", Color.CYAN);
addlabel(show_HolyGrail, "HolyGrail", color.magenta);
addlabel(show_Inside_bar, "Inside bar", Color.yellow);
addlabel(show_Outside_bar, "Outside bar", Color.WHITE);
AssignPriceColor(
if Nirvana then Color.CYAN
else if HolyGrail then color.magenta
else if inside_bar then Color.yellow
else if outside_Bar then Color.WHITE
else Color.CURRENT);
#
settings
nirvana - zoomed in , first changed arrows
nirvana - zoom out, multiple triggers
all 4 signals - all arrows
each signal arrow has a different price factor, so they appear stacked, not on top of each other.
Last edited by a moderator: