//-------Heikin Ashi-----------------
once haopen=open
haclose=(open+close+high+low)/4
if barindex> 0 then
haopen=(haopen+haclose[1])/2
endif
halow=min(low,min(haclose,haopen))
hahigh=max(high,max(haclose,haopen))
if haclose > haopen then
r=0
g=250
else
r=250
g=0
endif
//----------------------------------
ema = average[50,1](haclose)
//----------------------------------
vol = volume
avgvol = average[50](vol)
//----------------------------------
atr = averagetruerange[50]
//------Bands-----------------------
kDnout = ema - 3.5*atr
KUpout = ema + 3.5*atr
KDnIn = ema - 2.5*atr
KUpIn = ema + 2.5*atr
//-----Long condition---------------//
n = barssince(haclose crosses under KDnOut)
longcondition = haclose crosses over KDnIn and n <= 5 and vol > avgvol
//-----Short condition--------------//
m = barssince(haclose crosses over KUpOut)
shortconidition = haclose crosses under KUpIn and m <=5 and vol > avgvol
if longcondition then
drawarrowup(barindex,halow-0.25*atr)coloured("green")
elsif shortconidition then
drawarrowdown(barindex,hahigh+0.25*atr)coloured("red")
endif
DRAWCANDLE(haopen, hahigh, halow, haclose)coloured(r,g,0,70)
return ema coloured("green")style(dottedline,2),kDnout coloured("red"),KDnIn coloured("purple"),kUpout coloured("red"),KUpIn coloured("purple")