As requested in the forum, here is a new version of the Cynthia Kase Dev Stop indicator.
Originally developed bu Cynthia Kase (in her book “Trading With the Odds”). This version is calculating the DevStops exactly as described in the book.
Engineering a Better Stop: The Kase DevStops
What all of this boils down to is that we need to take variance and skew into consideration when we are establishing a system for setting stops. Three steps that we can take in order to both better define and to minimize the threshold of uncertainty in setting stops are:
//PRC_KaseDevStop v3 | indicator
//29.06.2018
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//translated from MT5 code version
//--- settings
inpDesPeriod = 20 // Dev-stop period
inpSlowPeriod = 21 // Dev-stop slow period
inpFastPeriod = 10 // Dev-stop fast period
inpStdDev1 = 0.0 // Deviation 1
inpStdDev2 = 1.0 // Deviation 2
inpStdDev3 = 2.2 // Deviation 3
inpStdDev4 = 3.6 // Deviation 4
//--- end of settings
pricc=customclose
once price=close*100
average1 = average[inpFastPeriod](pricc)
average2 = average[inpSlowPeriod](pricc)
if average1>average2 then
trend=1
r=0
g=191
b=255
else
trend=-1
r=255
g=128
b=0
endif
if trend<>trend[1] then
if trend=1 then
price=high
else
price=low
endif
endif
if trend>0 then
price=max(price,high)
endif
if trend<0 then
price=min(price,low)
endif
mmax=max(max(high,high[1]),pricc[2])
mmin=min(min(low,low[1]),pricc[2])
rrange=mmax-mmin
avg=rrange
for n=1 to inpDesPeriod-1 do
avg=(avg+rrange[n])
next
avg=avg/n
dev = square(rrange-avg)
for n=1 to inpDesPeriod-1 do
dev=dev+(rrange[n]-avg)*(rrange[n]-avg)
next
dev=sqrt(dev/n)
val = price+(-1)*trend*(avg+(inpStdDev1*dev))
val1 = price+(-1)*trend*(avg+(inpStdDev2*dev))
val2 = price+(-1)*trend*(avg+(inpStdDev3*dev))
val3 = price+(-1)*trend*(avg+(inpStdDev4*dev))
return val coloured(r,g,b) style(dottedline,1) ,val1 coloured(r,g,b) style(dottedline,1) ,val2 coloured(r,g,b) style(dottedline,1),val3 coloured(r,g,b) style(line,3)