ND
ND
// Get values
ema1 = ta.ema(emaSource1, emaLength1)
ema2 = ta.ema(emaSource2, emaLength2)
//Test
Long = Buy == 1 ? 1 : 0
Short = Buy != 1 ? 1 : 0
// Alerts
alertcondition(Longtrigger, title='Long Alert', message='Long Alert')
alertcondition(Shorttrigger, title='Short Alert', message='Short Alert')
//Barcolor
barcolor(Long == 1 ? color.green : color.red, title='Bar Color')
// Cloud
displacement_A = 26
displacement_B = 26
conversion_len = 9
base_line_len = 26
senkou_B_len = 51
f(x) =>
total_volume = math.sum(volume, x)
volume_weighted_high = math.sum(high * volume, x) / total_volume
volume_weighted_low = math.sum(low * volume, x) / total_volume
(volume_weighted_high + volume_weighted_low) / 2
conversion_line = f(conversion_len)
base_line = f(base_line_len)
senkou_A = (conversion_line + base_line) / 2
senkou_B = f(senkou_B_len)
gansqr(x) =>
math.round(x * x * 100) / 100
two_dec(x) =>
math.round(x * 100) / 100
//Get previous day/week bar and avoiding realtime calculation by taking the
previous to current bar
popen_d = request.security(syminfo.tickerid, 'D', open[1], barmerge.gaps_off,
barmerge.lookahead_on)
phigh_d = request.security(syminfo.tickerid, 'D', high[1], barmerge.gaps_off,
barmerge.lookahead_on)
plow_d = request.security(syminfo.tickerid, 'D', low[1], barmerge.gaps_off,
barmerge.lookahead_on)
pclose_d = request.security(syminfo.tickerid, 'D', close[1], barmerge.gaps_off,
barmerge.lookahead_on)
PP_d = 0.0
R1_d = 0.0
R2_d = 0.0
R3_d = 0.0
S1_d = 0.0
S2_d = 0.0
S3_d = 0.0
PP_d := two_dec(PP_d)
R1_d := two_dec(R1_d)
S1_d := two_dec(S1_d)
R2_d := two_dec(R2_d)
S2_d := two_dec(S2_d)
R3_d := two_dec(R3_d)
S3_d := two_dec(S3_d)
PP_w = 0.0
R1_w = 0.0
R2_w = 0.0
R3_w = 0.0
S1_w = 0.0
S2_w = 0.0
S3_w = 0.0
PP_w := two_dec(PP_w)
R1_w := two_dec(R1_w)
S1_w := two_dec(S1_w)
R2_w := two_dec(R2_w)
S2_w := two_dec(S2_w)
R3_w := two_dec(R3_w)
S3_w := two_dec(S3_w)
//PP_m = 0.0
//R1_m = 0.0, R2_m = 0.0, R3_m = 0.0
//S1_m = 0.0, S2_m = 0.0, S3_m = 0.0
//PP_m := two_dec(PP_m)
//R1_m := two_dec(R1_m)
//S1_m := two_dec(S1_m)
//R2_m := two_dec(R2_m)
//S2_m := two_dec(S2_m)
//R3_m := two_dec(R3_m)
//S3_m := two_dec(S3_m)
///////////////////////////////////////////
// GANN Levels
//////////////////////////////////////////
G540N_d = 0.0
G360N_d = 0.0
G270N_d = 0.0
G180N_d = 0.0
G135N_d = 0.0
G90N_d = 0.0
G45N_d = 0.0
G45P_d = 0.0
G90P_d = 0.0
G135P_d = 0.0
G180P_d = 0.0
G270P_d = 0.0
G360P_d = 0.0
G540P_d = 0.0
Gkey_d = 0.0
Gkey_d := math.sqrt(pclose_d)
G540N_d := gansqr(Gkey_d - 3)
G360N_d := gansqr(Gkey_d - 1)
G270N_d := gansqr(Gkey_d - 0.75)
G180N_d := gansqr(Gkey_d - 0.5)
G135N_d := gansqr(Gkey_d - 0.375)
G90N_d := gansqr(Gkey_d - 0.25)
G45N_d := gansqr(Gkey_d - 0.125)
G45P_d := gansqr(Gkey_d + 0.125)
G90P_d := gansqr(Gkey_d + 0.25)
G135P_d := gansqr(Gkey_d + 0.375)
G180P_d := gansqr(Gkey_d + 0.5)
G270P_d := gansqr(Gkey_d + 0.75)
G360P_d := gansqr(Gkey_d + 1)
G540P_d := gansqr(Gkey_d + 3)
////////////////////////
// PLOT GANN LEVELS //
Gkey_w := math.sqrt(pclose_w)
G720N_w := gansqr(Gkey_w - 4)
G540N_w := gansqr(Gkey_w - 3)
G360N_w := gansqr(Gkey_w - 2)
G270N_w := gansqr(Gkey_w - 1.5)
G180N_w := gansqr(Gkey_w - 1)
G90N_w := gansqr(Gkey_w - 0.5)
G45N_w := gansqr(Gkey_w - 0.25)
G45P_w := gansqr(Gkey_w + 0.25)
G90P_w := gansqr(Gkey_w + 0.5)
G180P_w := gansqr(Gkey_w + 1)
G270P_w := gansqr(Gkey_w + 1.5)
G360P_w := gansqr(Gkey_w + 2)
G540P_w := gansqr(Gkey_w + 3)
G720P_w := gansqr(Gkey_w + 4)
////////////////////////
// PLOT GANN LEVELS //
//////////////////
// Monthly Gann
//Gkey_m := sqrt(pclose_m)
//G720N_m:= gansqr(Gkey_m-4)
//G540N_m:= gansqr(Gkey_m-3)
//G360N_m:= gansqr(Gkey_m-2)
//G270N_m:= gansqr(Gkey_m-1.5)
//G180N_m:= gansqr(Gkey_m-1)
//G90N_m:= gansqr(Gkey_m-0.5)
//G45N_m:= gansqr(Gkey_m-0.25)
//G45P_m:= gansqr(Gkey_m+0.25)
//G90P_m:= gansqr(Gkey_m+0.5)
//G180P_m:= gansqr(Gkey_m+1)
//G270P_m:= gansqr(Gkey_m+1.5)
//G360P_m:= gansqr(Gkey_m+2)
//G540P_m:= gansqr(Gkey_m+3)
//G720P_m:= gansqr(Gkey_m+4)
////////////////////////
// PLOT GANN LEVELS //
// MA4 Plot
plot(ta.sma(close, maPeriods4), '66', color.new(color.white, 0), linewidth=1)
// MA5 Plot
plot(ta.sma(close, maPeriods5), '180', color.new(color.green, 0), linewidth=1)
// MA9 Plot
plot(ta.sma(close, maPeriods9), '77', color.new(color.white, 0), linewidth=1,
style=plot.style_circles)
// MA10 Plot
plot(ta.sma(close, maPeriods10), '231', color.new(color.green, 0), linewidth=1,
style=plot.style_circles)
//////////////////////////////////////////////////////////////////////////
// Settings for 5min chart, BTCUSDC. For Other coin, change the parameters
//////////////////////////////////////////////////////////////////////////
// Color variables
upColor = color.white
midColor = #90bff9
downColor = color.blue
// Source
src = input(defval=close, title="Source")
// Sampling Period
// Settings for 5min chart, BTCUSDC. For Other coin, change the paremeters
per = input.int(defval=100, minval=1, title="Sampling Period")
// Range Multiplier
mult = input.float(defval=3.0, minval=0.1, title="Range Multiplier")
// Range Filter
rngfilt(x, r) =>
rngfilt = x
rngfilt := x > nz(rngfilt[1]) ? x - r < nz(rngfilt[1]) ? nz(rngfilt[1]) : x - r
:
x + r > nz(rngfilt[1]) ? nz(rngfilt[1]) : x + r
rngfilt
filt = rngfilt(src, smrng)
// Filter Direction
upward = 0.0
upward := filt > filt[1] ? nz(upward[1]) + 1 : filt < filt[1] ? 0 : nz(upward[1])
downward = 0.0
downward := filt < filt[1] ? nz(downward[1]) + 1 : filt > filt[1] ? 0 :
nz(downward[1])
// Target Bands
hband = filt + smrng
lband = filt - smrng
// Colors
filtcolor = upward > 0 ? upColor : downward > 0 ? downColor : midColor
barcolor = src > filt and src > src[1] and upward > 0 ? upColor :
src > filt and src < src[1] and upward > 0 ? upColor :
src < filt and src < src[1] and downward > 0 ? downColor :
src < filt and src > src[1] and downward > 0 ? downColor : midColor
// Target
hbandplot = plot(hband, color=color.new(upColor, 70), title="High Target")
lbandplot = plot(lband, color=color.new(downColor, 70), title="Low Target")
// Fills
fill(hbandplot, filtplot, color=color.new(upColor, 90), title="High Target Range")
fill(lbandplot, filtplot, color=color.new(downColor, 90), title="Low Target Range")
// Bar Color
barcolor(barcolor)
// Break Outs
longCond = bool(na)
shortCond = bool(na)
longCond := src > filt and src > src[1] and upward > 0 or
src > filt and src < src[1] and upward > 0
shortCond := src < filt and src < src[1] and downward > 0 or
src < filt and src > src[1] and downward > 0
CondIni = 0
CondIni := longCond ? 1 : shortCond ? -1 : CondIni[1]
longCondition = longCond and CondIni[1] == -1
shortCondition = shortCond and CondIni[1] == 1
//Alerts
plotshape(longCondition, title="Buy Signal", text="Buy", textcolor=color.white,
style=shape.labelup, size=size.small, location=location.belowbar,
color=color.new(#aaaaaa, 20))
plotshape(shortCondition, title="Sell Signal", text="Sell", textcolor=color.white,
style=shape.labeldown, size=size.small, location=location.abovebar,
color=color.new(downColor, 20))
// Settings for 5min BTCUSDT. For other timeframes and assets, adjust the
parameters within the settings menu.
//
___________________________________________________________________________________
________________________