Bonjour,
J’aimerais transformer un indicateur de franchissement support/résistance en screener. Le code que je vais mettre est juste une partie que je souhaite ajouter à un plus gros screener.
J’ai dans un premier temps écrit le code pour qu’il fonctionne en indicateur puis essayer de le mettre sous forme de screener mais il ne fonctionne pas du tout et me donne de fausse alerte et souvent aucune alerte. Je ne comprend pas d’où vient l’erreur alors que j’ai simplement recopier le code de l’indicateur de base.
DEFPARAM CALCULATEONLASTBARS=1000
p=1
//////////////////////////////Average candle size//////////////////////////////
x = 96
XGreen = 0
GreenSUM = 0
For i = 0 To x-1 Do
GreenSUM = GreenSUM + Range[i]
XGreen = XGreen + 1
A = GreenSUM / XGreen
next
///////////////////////////////////////////////
length1=70
lenght2=50
/////////////////Resistance ///////////////////////////
if close>=highest[length1](close) then
$TOPD[lastset($TOPA)+1]=Date
$TOPH[lastset($TOPA)+1]=24-Hour
t1 = 0
top1 = close
else
top1 = top1
t1 = t1+1
if t1>lenght2 and t1<lenght2+2 then
$TOPy[t+1] = top1
$TOPx[t+1] = barindex
$TopA[t+1]= A
t=t+1
endif
ENDIF
/////////////////Support ///////////////////////////
if close<=lowest[length1](close) then
$BOTD[lastset($BOTA)+1]=Date
$BOTH[lastset($BOTA)+1]=24-Hour
b1 = 0
bot1 = close
else
bot1 = bot1
b1 = b1+1
if b1>lenght2 and b1<lenght2+2 then
$boty[r+1] = bot1
$botx[r+1] = barindex
$BotA[r+1]= A
r=r+1
endif
endif
for i=r downto max(0,r-30) do
if (low[p] < $BOTy[i] and high[p] > $BOTy[i]) or (low[p] < ($boty[i]+($BotA[i]*0.1)) and high[p] > ($BOTy[i]-($BotA[i]*0.2))) or (high[p] > $TOPy[i] and low[p] < $TOPy[i]) or (high[p] > ($TOPy[i]-($TopA[i]*0.05)) and low[p] < ($TOPy[i]+$TOPA[i]*0.2))then
DRAWARROWup(barindex[1],high[1]) COLOURED("grey")
ENDIF
next
//////////////Resistances lenght in day (3 days) ////////////////
for d = 0 to lastset($topy) do
if (date-$TOPD[d]) >=3 and (HOUR+$TOPH[d])>24 THEN
$TOPY[d]=0
endif
next
//////////////Supports lenght in day (3 days) ////////////////
for o = 0 to lastset($boty) do
if (date-$BOTD[o]) >=3 and (HOUR+$BOTH[o])>24 THEN
$BOTY[o]=0
endif
next
return
Voici ensuite la forme screener que j’ai essayé de créer.
p=1
//////////////////////////////Average candle size//////////////////////////////
x = 96
XGreen = 0
GreenSUM = 0
For i = 0 To x-1 Do
GreenSUM = GreenSUM + Range[i]
XGreen = XGreen + 1
A = GreenSUM / XGreen
next
///////////////////////////////////////////////
length1=70
lenght2=50
/////////////////Resistance ///////////////////////////
if close>=highest[length1](close) then
$TOPD[lastset($TOPA)+1]=Date
$TOPH[lastset($TOPA)+1]=24-Hour
t1 = 0
top1 = close
else
top1 = top1
t1 = t1+1
if t1>lenght2 and t1<lenght2+2 then
$TOPy[t+1] = top1
$TOPx[t+1] = barindex
$TopA[t+1]= A
t=t+1
endif
ENDIF
/////////////////Support ///////////////////////////
if close<=lowest[length1](close) then
$BOTD[lastset($BOTA)+1]=Date
$BOTH[lastset($BOTA)+1]=24-Hour
b1 = 0
bot1 = close
else
bot1 = bot1
b1 = b1+1
if b1>lenght2 and b1<lenght2+2 then
$boty[r+1] = bot1
$botx[r+1] = barindex
$BotA[r+1]= A
r=r+1
endif
endif
for i=r downto max(0,r-30) do
if (low[p] < $BOTy[i] and high[p] > $BOTy[i]) or (low[p] < ($boty[i]+($BotA[i]*0.1)) and high[p] > ($BOTy[i]-($BotA[i]*0.2))) or (high[p] > $TOPy[i] and low[p] < $TOPy[i]) or (high[p] > ($TOPy[i]-($TopA[i]*0.05)) and low[p] < ($TOPy[i]+$TOPA[i]*0.2))then
Signal = close[1]
endif
next
//////////////Resistances lenght in day (3 days) ////////////////
for d = 0 to lastset($topy) do
if (date-$TOPD[d]) >=3 and (HOUR+$TOPH[d])>24 THEN
$TOPY[d]=0
endif
next
//////////////Supports lenght in day (3 days) ////////////////
for o = 0 to lastset($boty) do
if (date-$BOTD[o]) >=3 and (HOUR+$BOTH[o])>24 THEN
$BOTY[o]=0
endif
next
SCREENER [Signal](Signal as "close")
Cette partie du screener est vraiment la pièce final de mon screener global.
Merci de votre aide
Holà ! Essayez de modifier le signal variable pour démarrer la boucle :
signal=0
for i=r downto max(0,r-30) do
if (low[p] < $BOTy[i] and high[p] > $BOTy[i]) or (low[p] < ($boty[i]+($BotA[i]*0.1)) and high[p] > ($BOTy[i]-($BotA[i]*0.2))) or (high[p] > $TOPy[i] and low[p] < $TOPy[i]) or (high[p] > ($TOPy[i]-($TopA[i]*0.05)) and low[p] < ($TOPy[i]+$TOPA[i]*0.2))then
Signal = 1
endif
next
Salut Ivan, merci pour ta réponse
Le screener ne marche toujours pas, j’ai l’impression que mon tableau ne marche pas dans le screener et donc aucun support ou résistance ne reste enregistré.
J’ai essayé de “print” les valeurs du tableau mais seulement le dernier top et bot marche, les autres ne sont pas définis. Je ne comprend pas pourquoi ca ne marche pas, peut être car il y a pas un maximum de candle prise en compte ? Si quelqu’un à une idée du fonctionnement du array sur un proscreener.
Merci de votre aide