Bonjour Noobyvan,
merci pour la réponse
c’était une de mes tentatives, mais c’est pas bon. Toujours le même résultat
Le code est celui qu’avait publié Nicolas il y a déjà un moment.
et je le trouve pertinent. je le republie en entier.
// --- PARAMÈTRES ---
// Fast Trail //
AP1 = 5 //"fast ATR period",integer) // ATR Period // 5 ATR Periode RAPIDE, pour générer des signaux ACHAT / VENTE
AF1 = 0.5 //"fast ATR multiplier",float) // ATR Factor // 0.5
// Slow Trail //
AP2 = 14 //"slow ATR perod",integer) // ATR Period // 10
AF2 = 3.1 // "slow ATR multiplier",float) // ATR Factor // 2
// --- end of settings
SC = customclose
SL1 = AF1*AverageTrueRange[AP1] // Stop Loss
once trail1=sc-sl1
if sc>trail1[1] and sc[1]>trail1[1] then
trail1 = max(trail1[1],sc-sl1)
else
if sc<trail1[1] and sc[1]<trail1[1] then
trail1=min(trail1[1],sc+sl1)
else
if sc>trail1[1] then
trail1=sc-sl1
else
trail1=sc+sl1
endif
endif
endif
SL2 = AF2*AverageTrueRange[AP2] // Stop Loss
if sc>trail2[1] and sc[1]>trail2[1] then
trail2 = max(trail2[1],sc-sl2)
else
if sc<trail2[1] and sc[1]<trail2[1] then
trail2=min(trail2[1],sc+sl2)
else
if sc>trail2[1] then
trail2=sc-sl2
else
trail2=sc+sl2
endif
endif
endif
ts1 = trail1
ts2 = trail2
if sc > trail2 then // ACHAT // ATR Ligne verte
rtrail=0
gtrail=180
else
rtrail=255 // VENTE // ATR Ligne rouge
gtrail=0
endif
//drawcandle(trail1,trail2,trail1,trail2) coloured(rtrail,gtrail,0,10)bordercolor(0,0,0,0)
Hst = Trail1-Trail2
Sig = average[9,1](Hst)
// Bar color for trade signal //
Green = Hst>0 and Hst>Sig
Red = Hst<0 and Hst<Sig
sBuy = green and not green[1]
sSell = red and not red[1]
indicator1 = sc < trail2 // VENTE
if indicator1 then
drawtriangle (barindex[1],ts2[1],barindex,indicator1,barindex[0],ts2[0]) coloured(255,0,0,25) bordercolor(0,100,0,0)
drawtriangle (barindex[1],ts2[1],barindex[1],close[1],barindex,close) coloured(255,0,0,25) bordercolor(0,100,0,0)
endif
if sBuy then
DRAWTEXT ("◯",barindex, ts2 - 0.004, dialog, bold, 23) coloured(0,0,255)
DRAWTEXT ("B",barindex, ts2 - 0.004, dialog, bold, 18) coloured(0,0,255)
endif
if sSell then
DRAWTEXT ("◯",barindex, ts2 + 0.004, dialog, bold, 23) coloured(255,69,0)
DRAWTEXT ("S",barindex, ts2 + 0.004, dialog, bold, 18) coloured(255,0,0)
endif
return
Merci pour une idée
Bonne journée