Professional Documents
Culture Documents
0 at
https://mozilla.org/MPL/2.0/
// � dineeshk
//@version=4
study("HVSD-SSL", overlay=true)
//
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
///EXIT
ExitHigh = ma(SSL3Type, high, len3)
ExitLow = ma(SSL3Type, low, len3)
//SSL1 VALUES
Hlv = int(na)
Hlv := close > emaHigh ? 1 : close < emaLow ? -1 : Hlv[1]
sslDown = Hlv < 0 ? emaHigh : emaLow
//SSL2 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 ? #00c3ff : close < lowerk ? #ff0062 : color.gray
color_ssl1 = close > sslDown ? #00c3ff : close < sslDown ? #ff0062 : na
//PLOTS
plotarrow(codiff, colorup=#00c3ff, colordown=#ff0062,title="Exit Arrows",
transp=20, maxheight=20, offset=0)
p1 = plot(show_Baseline ? BBMC : na, color=color_bar, linewidth=4,transp=0,
title='MA Baseline')
DownPlot = plot( show_SSL1 ? sslDown : na, title="SSL1", linewidth=3,
color=color_ssl1, transp=10)
barcolor(show_color_bar ? color_bar : na)
up_channel = plot(show_Baseline ? upperk : na, color=color_bar, title="Baseline
Upper Channel")
low_channel = plot(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='SSL1
has crossed.')
alertcondition(crossover(close, sslDown2), title='SSL2 Cross Alert', message='SSL2
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.')
//
***********************************************************************************
*******************Dinesh
// === INPUTS
useDaily = input(true, title="Use Daily Data to Calculate HV (default), otherwise
chart TF")
LookBack = input(21, minval=1, type=input.integer)
annual = input(252, minval=1, type=input.integer)
DaystoExpire_ = input(defval=0, minval=0, type=input.integer, title="Calender Days
to Expiry (0=Auto, default)")
src1 = input(close, title="Settlement Source (close=default)")
sLength_ = input(1, minval=1, type=input.integer, title="Settlement Volume Weighted
Average Length (1=Use end of day)")
//
stddev1 = input(true, title="Display 1x Standard Deviation Levels")
stddev2 = input(false, title="Display 2x Standard Deviation Levels")
stddev3 = input(false, title="Display 3x Standard Deviation Levels")
pivotNow = input(false, title="Display Only Todays Deviation Levels")
sHiLo = input(false, title="Show Previous Day's High Low Levels")
sHiLoNow = input(false, title="Show Current Day's Running High Low Levels")
//
// === /INPUTs
dodgerblue = #1E90FF
//
// Test for new Daily Session or start of new month for Daily.
sLength = timeframe.isintraday ? sLength_ : 1
nstart = security(syminfo.tickerid, "D", bar_index, barmerge.gaps_off,
barmerge.lookahead_on)
start = security(syminfo.tickerid, "D", time, barmerge.gaps_off,
barmerge.lookahead_on)
first = security(syminfo.tickerid, "D", valuewhen(barstate.islast, time, 0),
barmerge.gaps_off, barmerge.lookahead_on)
change_1 = change(start)
newDay = nohist ? false :
timeframe.isintraday ? change_1 : dayofmonth(time) < dayofmonth(time[1])
//--- debug
//plotchar(n,title="n",location=location.bottom,color=na)
//plotchar(nstart,title="nstart",location=location.bottom,color=na)
//plotchar(nohist,title="noHist",location=location.bottom,color=na)
//plotchar(dayofmonth(start),title="startDay",location=location.bottom,color=na)
//plotchar(hour(start),title="startMins",location=location.bottom,color=na)
//plotchar(dayofmonth(first),title="firstDay",location=location.bottom,color=na)
//plotchar(hour(first),title="firstMins",location=location.bottom,color=na)
//plotchar(newDay,title="newDay",location=location.bottom,color=na)
//--- /debug
LookBack : DaystoExpire_
stdhv := newDay ? settlement * hv * sqrt(DaystoExpire / annual) : nz(stdhv[1])
//