Professional Documents
Culture Documents
Nifty BN Members 3 in 1
Nifty BN Members 3 in 1
Nifty BN Members 3 in 1
daily_cpr = input (title=" Daily CPR ", type= input.integer , defval=7, minval=0)
one_day = 1000 * 60 * 60 * 24
new_day = daily_cpr > 0 and timenow - time < one_day * daily_cpr and new_bar("D")
// ZigZag options:
bool show_real_pivots = input(defval=true, title="Show real zigzag pivots:",
type=input.bool)
bool show_zigzag_lines = input(defval=true, title="Show zigzag lines:",
type=input.bool)
// Label options:
bool show_pivot_price = input(defval=true, title="Show price labels on zigzag:",
type=input.bool)
bool show_triangle_rates = input(defval=true, title="Show rate labels on
triangles:", type=input.bool)
bool show_angles = input(defval=false, title="Show Angle Degree
information(EXPERIMENTAL):", type=input.bool)
bool show_patterns = input(defval=true, title="Show Patterns:", type=input.bool)
bool show_harmonic = input(defval=true, title="Show Harmonic Triangle Pattern:",
type=input.bool)
bool show_tap = input(defval=true, title="Show 2/3/4 Tap Patterns:",
type=input.bool)
bool show_abcd = input(defval=true, title="Show AB=CD Pattern:", type=input.bool)
bool show_bat = input(defval=true, title="Show Bat Pattern:", type=input.bool)
bool show_butterfly = input(defval=true, title="Show Butterfly Pattern:",
type=input.bool)
bool show_gartley = input(defval=true, title="Show Gartley Pattern:",
type=input.bool)
bool show_crab = input(defval=true, title="Show Crab Pattern:", type=input.bool)
bool show_shark = input(defval=true, title="Show Shark Pattern:", type=input.bool)
bool show_5o = input(defval=true, title="Show 5o Pattern:", type=input.bool)
bool show_wolfe = input(defval=true, title="Show wolfe Pattern:", type=input.bool)
bool show_contria = input(defval=true, title="Show Contracting Triangle Pattern:",
type=input.bool)
bool show_exptria = input(defval=true, title="Show Expanding Triangle Pattern:",
type=input.bool)
bool show_hns = input(defval=true, title="Show Head and Shoulders Pattern:",
type=input.bool)
// Forecast options:
bool show_projections = input(defval=true, title="Show projections forecast of
zigzag:", type=input.bool)
bool show_projections_square = input(defval=true, title="Show projections forecast
Bounds:", type=input.bool)
bool show_projections_square_rates = input(defval=false, title="Show projections
target rates:", type=input.bool)
// ||-------------------------------------------------------------------------||
// ||
// ||-------------------------------------------------------------------------||
// |{
f_zz(_percent)=>
if na(_is_direction_up)
_is_direction_up := true
if _is_direction_up
_ltrack := na
_ltime := time
if na(_htrack)
if high > high[1]
_htrack := high
_htime := time
else
_htrack := high[1]
_htime := time[1]
else
if high > _htrack
_htrack := high
_htime := time
if not _is_direction_up
_htrack := na
_htime := na
if na(_ltrack)
if low < low[1]
_ltrack := low
_ltime := time
else
_ltrack := low[1]
_ltime := time[1]
else
if low < _ltrack
_ltrack := low
_ltime := time
// || |}---------------------------------------------------------------------<•
// |{
[price_a, is_up, reverse, _rl_time] = f_zz(percent)
alt_time = show_real_pivots and showAutoBS ? _rl_time : time
// | Get Pivots:
var int time_a = na
var int time_b = na, var float price_b = na
var int time_c = na, var float price_c = na
var int time_d = na, var float price_d = na
var int time_e = na, var float price_e = na
var int time_f = na, var float price_f = na
var int time_g = na, var float price_g = na
if is_new_zig
time_a := alt_time
time_b := time_a[1], price_b := price_a[1]
time_c := time_b[1], price_c := price_b[1]
time_d := time_c[1], price_d := price_c[1]
time_e := time_d[1], price_e := price_d[1]
time_f := time_e[1], price_f := price_e[1]
time_g := time_f[1], price_g := price_f[1]
// || |}---------------------------------------------------------------------<•
// |{
f_draw_zigzag_lines()=>
var line _li = na
_li_color = price_a > price_b ? color.lime : color.red
if is_new_zig
_li := line.new(
time_a, price_a,
time_b, price_b,
xloc.bar_time, extend=extend.none, color=_li_color, width=2
)
if show_zigzag_lines and showAutoBS
f_draw_zigzag_lines()
// || |}---------------------------------------------------------------------<•
// || |}---------------------------------------------------------------------<•
// ||-------------------------------------------------------------------------||
// || Pivot Labels:
// ||-------------------------------------------------------------------------||
// |{
f_draw_zigzag_labels(_text)=>
var label _la = na
color _la_color = price_a > price_b ? color.red : color.lime
string _la_style = price_a > price_b ? label.style_labeldown :
label.style_labelup
string _la_text = na
if show_pivot_price and showAutoBS
_la_text := price_a > price_b ? tostring(price_a, "#.#####") + _text :
_text + tostring(price_a, "#.#####")
else
_la_text := _text
if is_new_zig
_la := label.new(
x=time_a, y=price_a,
text=_la_text,
xloc=xloc.bar_time, yloc=yloc.price,
style=_la_style,
color=_la_color, textcolor=color.black, size=size.normal
)
// if show_zigzag_labels
// f_plot_zigzag_labels("")
// || |}---------------------------------------------------------------------<•
// ||-------------------------------------------------------------------------||
// || Function to process data, return range, avg, +/- dev, max to be ploted:
// ||-------------------------------------------------------------------------||
// |{
f_mode_process_stats(_weight, _data)=>
float _avg_range = _data, float _max_range = 0.0
if bar_index < 1
// on 1st bar, make it equal to _data
_avg_range := _data
else
if change(_data) != 0
_weight_data = _weight * _data
_weight_previous = (1 - _weight) * nz(_avg_range[1], _data[1])
_avg_range := _weight_data + _weight_previous
else
_avg_range := _avg_range[1]
// |{
f_cast_projections()=>
var line line_midline = na
var line line_price_dev = na
var line line_time_dev = na
var label _la0618 = na
var label _la1618 = na
// || Style abreviation:
xtend = extend.right
st_dash = line.style_dashed
st_arrow = line.style_arrow_both
line_midline := line.new(
time_a, price_a,
target_avg_time, target_avg_price,
xloc.bar_time, extend=xtend, color=color.orange, style=st_dash,
width=1
)
line_price_dev := line.new(
target_avg_time, target_price_lower_dev,
target_avg_time, target_price_upper_dev,
xloc.bar_time, color=#0066ff, style=st_arrow, width=1
)
line_time_dev := line.new(
target_time_lower_dev, target_avg_price,
target_time_upper_dev, target_avg_price,
xloc.bar_time, color=#0066ff, style=st_arrow, width=1
)
// |{
// || Pattern Functions:
isHarmonicTriangle(_cba, _margin_of_error)=>
bool _return = false
// return true if its rate is near a harmonic rate:
// 0.146, 0.236, 0.382, 0.618, 1, 1.618, 2.618, 4.236, 6.854, 11.089,
17.942, 29.03
for _i = 1 to 12
if f_is_inrange(_cba, (-pow(1.618, -5+_i) - _margin_of_error), (-pow(1.618,
-5+_i) + _margin_of_error))
_return := true
_return
is2Tap(_cba, _margin_of_error)=>
_is_cba = f_is_inrange(_cba, -1.000 - _margin_of_error, -1.000 +
_margin_of_error)
_is_cba
// |}
// |{-------------------------------------------------------------------------||
// || Parameters:
// || _percent_of_error (float) : Margin of error in percentage.
f_Detect_Patterns(_percent_of_error)=>
// Placeholder for pattern label
string _pattern_label_placeholder = ""
// adjust margin of error into multiplier
float _margin_of_error = _percent_of_error / 100
// Placeholders for pivot rates:
var float price_gfe = na, var float time_gfe = na
var float price_gfc = na, var float time_gfc = na
var float price_gfa = na, var float time_gfa = na
var float price_gdc = na, var float time_gdc = na
var float price_gda = na, var float time_gda = na
var float price_gba = na, var float time_gba = na
// ||-------------------------------------------------------------------------||
// || Pattern check block:
// ||-------------------------------------------------------------------------||
// |{-------------------------------------------------------------------------||
if show_patterns and showAutoBS
bool _isvalid_gfa = price_fed >= -1 and price_feb >= -1 and price_cba <= -1
and price_eda <= -1
bool _isvalid_gda = price_fed <= -1 and price_gfe >= -1 and price_cba <= -1
and price_dcb >= -1
bool _isvalid_gba = price_feb <= -1 and price_gfe >= -1 and price_cba <= -1
and price_dcb <= -1
bool _isvalid_eba = price_cba <= -1 and price_dcb <= -1
bool _isvalid_eda = price_cba <= -1 and price_dcb >= -1
bool _isvalid_fcb = price_fed >= -1 and price_edc <= -1
bool _isvalid_feb = price_edc >= -1 and price_dcb <= -1
_pattern_list = "\n"
// Check if its a harmonic triangle:
if show_harmonic
if isHarmonicTriangle(price_gfa, _margin_of_error) and _isvalid_gfa
_pattern_list := _pattern_list + "• Harmonic Triangle(GFA) •\n"
if isHarmonicTriangle(price_gda, _margin_of_error) and _isvalid_gda
_pattern_list := _pattern_list + "• Harmonic Triangle(GDA) •\n"
if isHarmonicTriangle(price_gba, _margin_of_error) and _isvalid_gba
_pattern_list := _pattern_list + "• Harmonic Triangle(GBA) •\n"
if isHarmonicTriangle(price_eba, _margin_of_error) and _isvalid_eba
_pattern_list := _pattern_list + "• Harmonic Triangle(EBA) •\n"
if isHarmonicTriangle(price_eda, _margin_of_error) and _isvalid_eda
_pattern_list := _pattern_list + "• Harmonic Triangle(EDA) •\n"
if isHarmonicTriangle(price_cba, _margin_of_error)
_pattern_list := _pattern_list + "• Harmonic Triangle(CBA) •\n"
// Check if its Double Tap
if show_tap
if is2Tap(price_cba, _margin_of_error)
_pattern_list := _pattern_list + "• Double Tap(CBA) •\n"
if is2Tap(price_eba, _margin_of_error) and _isvalid_eba
_pattern_list := _pattern_list + "• Double Tap(EBA) •\n"
if is2Tap(price_eda, _margin_of_error) and _isvalid_eda
_pattern_list := _pattern_list + "• Double Tap(EDA) •\n"
// Check if its Triple Tap
if show_tap
if is3Tap(price_edc, price_cba, _margin_of_error)
_pattern_list := _pattern_list + "• Triple Tap(EDC, CBA) •\n"
// Check if its Quadruple Tap
if show_tap
if is4Tap(price_gfe, price_edc, price_cba, _margin_of_error)
_pattern_list := _pattern_list + "• Quadruple Tap(GFE, EDC, CBA)
•\n"
f_draw_zigzag_labels(_pattern_list)
else
// Only shows price label:
if show_pivot_price and showAutoBS
f_draw_zigzag_labels("")
// || |}---------------------------------------------------------------------<•
//Shanky Rainbow
//
tema(src, len) =>
ema1 = ema(src, len)
ema2 = ema(ema1, len)
ema3 = ema(ema2, len)
(3 * ema1) - (3 * ema2) + ema3
kidiv = input(defval=1,maxval=4, title="Kijun MOD Divider")
//----
//EDSMA
get2PoleSSF(src, length) =>
PI = 2 * asin(1)
arg = sqrt(2) * PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(arg)
c2 = b1
c3 = -pow(a1, 2)
c1 = 1 - c2 - c3
ssf = 0.0
ssf := c1 * src + c2 * nz(ssf[1]) + c3 * nz(ssf[2])
arg = PI / length
a1 = exp(-arg)
b1 = 2 * a1 * cos(1.738 * arg)
c1 = pow(a1, 2)
coef2 = b1 + c1
coef3 = -(c1 + b1 * c1)
coef4 = pow(c1, 2)
coef1 = 1 - coef2 - coef3 - coef4
ssf = 0.0
ssf := coef1 * src + coef2 * nz(ssf[1]) + coef3 * nz(ssf[2]) + coef4 *
nz(ssf[3])
edsma = 0.0
edsma := alpha * src + (1 - alpha) * nz(edsma[1])
result := edsma
result
///SSL 1 and SX
emaHigh = ma(maType, high, len)
emaLow = ma(maType, low, len)
///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)
//SZ VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow
//SX VALUES
Hlv2 = int(na)
Hlv2 := close > maHigh ? 1 : close < maLow ? -1 : Hlv2[1]
sslDown2 = Hlv2 < 0 ? maHigh : maLow
//EXIT VALUES
Hlv3 = int(na)
Hlv3 := close > ExitHigh ? 1 : close < ExitLow ? -1 : Hlv3[1]
sslExit = Hlv3 < 0 ? ExitHigh : ExitLow
base_cross_Long = crossover(close, sslExit)
base_cross_Short = crossover(sslExit, close)
codiff = base_cross_Long ? 1 : base_cross_Short ? -1 : na
//COLORS
show_color_bar = input(title="Color Bars", type=input.bool, defval=true)
color_bar = close > upperk ? #00E113 : close < lowerk ? #E16024 : color.gray
color_SZ = close > sslDown ? #00E113 : close < sslDown ? #E16024 : na
//PLOTS
plotarrow(showRainbow ? codiff : na, colorup=#00E113, colordown=#E16024,title="Exit
Arrows", transp=20, maxheight=20, offset=0)
p1 = plot(showRainbow and show_Baseline ? BBMC : na, color=color_bar,
linewidth=4,transp=0, title='MA Baseline')
DownPlot = plot(showRainbow and show_SZ ? sslDown : na, title="SZ", linewidth=3,
color=color_SZ, transp=10)
barcolor(showRainbow and show_color_bar ? color_bar : na)
up_channel = plot(showRainbow and show_Baseline ? upperk : na, color=color_bar,
title="Baseline Upper Channel")
low_channel = plot(showRainbow and show_Baseline ? lowerk : na, color=color_bar,
title="Basiline Lower Channel")
fill(up_channel, low_channel, color=color_bar, transp=90)
//ALERTS
alertcondition(crossover(close, sslDown), title='SSL Cross Alert', message='SZ has
crossed.')
alertcondition(crossover(close, sslDown2), title='SX Cross Alert', message='SX has
crossed.')
alertcondition(sell_atr, title='Sell Continuation', message='Sell Continuation.')
alertcondition(buy_atr, title='Buy Continuation', message='Buy Continuation.')
alertcondition(crossover(close, sslExit), title='Exit Sell', message='Exit Sell
Alert.')
alertcondition(crossover(sslExit, close), title='Exit Buy', message='Exit Buy
Alert.')
alertcondition(crossover(close, upperk ), title='Baseline Buy Entry', message='Base
Buy Alert.')
alertcondition(crossover(lowerk, close ), title='Baseline Sell Entry',
message='Base Sell Alert.')