DEFPARAM CalculateOnLastBars = 2000
ProximityThreshold=limite
Offset = 2 * pipsize
ema8hi = ExponentialAverage[8](high) // upper bound of EMA(8)
ema8lo = ExponentialAverage[8](low) // lower bound of EMA(8)
sma200 = Average[200](close) // SMA(200)
sma200h = sma200 + ProximityThreshold * (ema8hi - ema8lo)// upper bound of virtual channel
sma200l = sma200 - ProximityThreshold * (ema8hi - ema8lo) // lower bound of virtual channel
c1=low[2]>ema8hi[2] and low[1]>ema8hi[1]
c2=high[2]<ema8lo[2] and high[1]<ema8lo[1]
c3=ema8lo>sma200h
c4=ema8hi<sma200l
if (ema8lo crosses over sma200h)then
startbar = barindex
startprice=ema8lo
endif
if barindex-startbar<=10 and startprice<>signalprice then
if c1 and c3 then
drawtext("●",barindex,low-offset,Dialog,Bold,20) coloured(55,55,255)
DRAWARROWUP(barindex, LOW - offset)coloured(255,61,249)
//indicator=1
signalprice=startprice
endif
endif
//if (ema8lo < sma200h) and (ema8hi > sma200h) then
//backgroundcolor(255,255,0)
//endif
if (ema8hi crosses under sma200l)then
startbar1 = barindex
startprice=ema8lo
endif
if barindex-startbar1<=10 and startprice<>signalprice then
//if (ema8hi > sma200l) and (ema8lo < sma200l)then
//backgroundcolor(255,255,0)
//endif
if c2 and c4 then
drawtext("●",barindex,high+ offset,Dialog,Bold,20) coloured(255,55,55)
DRAWARROWDOWN(barindex, high + offset )coloured(255,255,255)
//indicator=-1
signalprice=startprice
endif
endif
return //sma200h as"sma200h",sma200l as "sma200l"