BB stops stochastic

Category: Indicators By: Nicolas Created: March 27, 2019, 11:39 AM
March 27, 2019, 11:39 AM
Indicators
4 Comments

The BB stops stochastic indicator defines trend trigger depending of the cross of the stochastic over the upper or lower bands of a Bollinger Bands applied to it.

Various typical settings of these indicators can be applied: periods of MA, standard deviation periods, etc.

If you are looking for the “famous” BBands Stop indicator but applied to the price, you can find it here: BBands stop

//PRC_ BBstops Stochastic| indicator
//27.03.2019
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
//converted from MT4 version 

// --- settings 
StoPeriod        = 32 // Stochastic period
StoSlowing       = 9  // Stochastic slowing period
MaPeriod         = 20 // Bollinger bands period
MaMethod         = 0  // Moving average method
DevPeriod        = 20 // Deviations period
Deviation        = 1  // Deviation
Risk             = 1  // Risk
// --- end of settings 

PriceC = customclose // Sotchastic price applied

sto = stochastic[StoPeriod,StoSlowing](PriceC)
dev = std[DevPeriod](sto)
ma = average[MaPeriod,MaMethod](sto)

amax  = ma+dev*Deviation
amin  = ma-dev*Deviation
bmax  = amax+0.5*(Risk-1)*(amax-amin)
bmin  = amin-0.5*(Risk-1)*(amax-amin)

if sto>amax[1] then
 trend=1
elsif sto<amin[1] then
 trend=-1
endif

if trend=-1 and amax>amax[1] then
 amax=amax[1]
endif
if trend = 1 and amin<amin[1] then
 amin=amin[1]
endif
if trend=-1 and bmax>bmax[1] then
 bmax=bmax[1]
endif
if trend=1 and bmin<bmin[1] then
 bmin=bmin[1]
endif

if sto crosses over amax then
 upr=30
 upg=144
 upb=255
 upalpha=255
 dnr=168
 dng=168
 dnb=168
 dnalpha=100
 if(dot<=0) then
  drawtext("•",barindex[1],bmin[1],Dialog,Standard,20) coloured(upr,upg,upb)
  dot=1
 endif
elsif sto crosses under amin then
 upr=168
 upg=168
 upb=168
 upalpha=100
 dnr=244
 dng=164
 dnb=96
 dnalpha=255
 if(dot>=0) then
  drawtext("•",barindex[1],bmax[1],Dialog,Standard,20) coloured(dnr,dng,dnb)
  dot=-1
 endif
endif


return sto coloured(168,168,168) STYLE(dottedline,2) as "stochastic",bmax coloured(dnr,dng,dnb,dnalpha) style(line,2),bmin coloured(upr,upg,upb,upalpha) style(line,2)

 

Download
Filename: PRC_-BBstops-Stochastic.itf
Downloads: 501
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...