EMAperiod=8
STOperiod=13
once DssBuffer = 50
once MitBuffer = 30
smoothcoefficient = 2.6 / (1 + EMAperiod)
if barindex>STOperiod then
//price range definitions
HighRange = Highest[STOperiod](high)
LowRange = Lowest[STOperiod](low)
delta = Close - LowRange
rrange = HighRange-LowRange
if rrange = 0 then
rrange = 1*ticksize
endif
MIT = delta/rrange*100.0
MitBuffer = ROUND(smoothcoefficient * (MIT - MitBuffer[1]) + MitBuffer[1])
//DSS calculation
HighRange=0
LowRange=stoperiod*1000
for i = 0 to Stoperiod do
HighRange=Max(MitBuffer[i],HighRange)
LowRange=Min(MitBuffer[i],LowRange)
next
delta = MitBuffer - LowRange
DSS = delta/(HighRange - LowRange)*100.0
DssBuffer = smoothcoefficient * (DSS - DssBuffer[1]) + DssBuffer[1]
my20level=20
my80level=80
endif
IF dssbuffer>dssbuffer[1] and dssbuffer[1]<dssbuffer[2]AND dssbuffer<=my20level THEN
bullishSignal = 1
bearishSignal = 0
ELSIF dssbuffer<dssbuffer[1] and dssbuffer[1]>dssbuffer[2]AND dssbuffer>=my80level THEN
bullishSignal = 0
bearishSignal = -1
ELSE
bullishSignal = 0
bearishSignal = 0
ENDIF
RETURN bullishSignal, bearishSignal