Buongiorno
vorrei implementare una strategia ovvero alla identificazione di una divergenza sul CCI col supetrend:
Identificazione divergenza rialzista -> entrata long quando il supertrend diventa verde e stop quando il supetrend diventa rosso.
Identificazione divergenza ribassista -> entrata short quando il supertrend diventa rosso e stop quando il supetrend diventa verde.
Se possibile inserire anche un tempo limite per l’entrata es. dopo 10 barre dalla segnalazione della divergenza se non è partita l’entrata, annullare l’operazione.
Riporto di seguito il codice che ho fatto per individuazione della divergenza col CCI.
Period = 20
OverSold = -150
OverBought = 150
MinBarRange = 5
Rge = averagetruerange[10](close)
MyCCI = cci[Period](typicalprice)
ONCE ShiftText = 3
CCIMax = MyCCI < MyCCI[1] and MyCCI[1] > MyCCI[2] and MyCCI[1] > OverBought
CCIMin = MyCCI > MyCCI[1] and MyCCI[1] < MyCCI[2] and MyCCI[1] < OverSold
if CCIMax then
CCIMax1 = MyCCI[1]
High1 = High[1]
for I = MinBarRange to 80
if CCIMax[I] then
CCIMax2 = MyCCI[I + 1]
High2 = High[I + 1]
If High1 > High2 and RSIMax1 < RSIMax2 then
DRAWARROWDOWN(barindex, High + Rge / ShiftText)coloured(255,192,203,255)
DRAWTEXT("dd", barindex, High + Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
endif
break
endif
next
endif
if CCIMin then
CCIMin1 = MyCCI[1]
Low1 = Low[1]
for I = MinBarRange to 80
if CCIMin[I] then
CCIMin2 = MyCCI[I + 1]
Low2 = Low[I + 1]
If Low1 < Low2 and RSIMin1 > RSIMin2 then
DRAWARROWUP(barindex, lOW - Rge / ShiftText)coloured(0,0,255,255)
DRAWTEXT("dd", barindex, lOW - Rge / ShiftText / 0.3,SansSerif,Italic,10)coloured(0,0,255,255)
endif
break
endif
next
endif
return
Posta il codice funzionante, altrimenti è impossibile creare qualcosa.