La version du code de cet indicateur de signaux, ci-dessous, place les textes correspondants aux TP1, TP2 et TP3 uniquement si le prix les atteint.
// --- settings
defparam drawonlastbaronly = false
sarclose = SAR[0.9,0.9,0.9]
sarslow=SAR[0.04,0.04,0.4]
sarfast=SAR[0.06,0.06,0.6]
//colors
if close>sarfast then //bullish
r=0
g=255
else //bearish
r=255
g=0
endif
//highs and lows
if close<sarfast then
ll=min(ll,low)
else
hh=max(hh,high)
endif
if close>sarfast and close[1]<sarfast[1] then //new bullish signal
fibo0=ll
ll=sarslow //reset ll
if close>sarslow then
type=1
startbar=barindex[0]
irange1=high-fibo0
entry = fibo0+(irange1/2)
itarget = entry+pointsize
itarget2 = entry+pointsize+2
itarget3 = entry+pointsize+3
itarget4 = entry+pointsize+4
itarget5 = entry+pointsize+5
itarget6 = entry+pointsize+6
itarget7 = entry+pointsize+10
itarget8 = entry+pointsize+15
itarget9 = entry+pointsize+20
itarget10 = entry+pointsize+30
itarget11 = entry+pointsize+35
itarget12 = entry+pointsize+40
itarget13 = entry+pointsize+45
itarget14 = entry+pointsize+50
istop = fibo0-2*pointsize
drawarrowup(barindex, low) coloured(255,255,255)
drawtext("BE",barindex,itarget2,dialog,standard,10) coloured(250,250,250)
//drawtext("TP1",barindex,itarget5,dialog,standard,10) coloured(250,250,250)
//drawtext("TP2",barindex,itarget7,dialog,standard,10) coloured(250,250,250)
//drawtext("TP3",barindex,itarget8,dialog,standard,10) coloured(250,250,250)
endif
endif
if close<sarfast and close[1]>sarfast[1] then //new bearish signal
fibo0=hh
hh=0 //reset hh
if close<sarslow then
type=-1
startbar=barindex[0]
irange2=fibo0-low
entry = fibo0-(irange2/2)
itarget = entry-pointsize
itarget2 = entry-pointsize-2
itarget3 = entry-pointsize-3
itarget4 = entry-pointsize-4
itarget5 = entry-pointsize-5
itarget6 = entry-pointsize-6
itarget7 = entry-pointsize-7
itarget8 = entry-pointsize-8
itarget9 = entry-pointsize-9
itarget10 = entry-pointsize-10
itarget11 = entry-pointsize-11
itarget12 = entry-pointsize-12
itarget13 = entry-pointsize-13
itarget14 = entry-pointsize-14
istop = fibo0+2*pointsize
drawarrowdown(barindex, high ) coloured(255,255,255)
drawtext("BE",barindex,itarget2,dialog,standard,10) coloured(250,250,250)
//drawtext("TP1",barindex,itarget5,dialog,standard,10) coloured(250,250,250)
//drawtext("TP2",barindex,itarget7,dialog,standard,10) coloured(250,250,250)
//drawtext("TP3",barindex,itarget8,dialog,standard,10) coloured(250,250,250)
endif
endif
//check takeprofit
if type=1 then //buy signal
if high crosses over itarget5 then
drawtext("TP1",barindex,itarget5,dialog,standard,10) coloured(250,250,250)
elsif high crosses over itarget7 then
drawtext("TP2",barindex,itarget7,dialog,standard,10) coloured(250,250,250)
elsif high crosses over itarget8 then
drawtext("TP3",barindex,itarget8,dialog,standard,10) coloured(250,250,250)
endif
elsif type=-1 then //sell signal
if low crosses under itarget5 then
drawtext("TP1",barindex,itarget5,dialog,standard,10) coloured(250,250,250)
elsif low crosses under itarget7 then
drawtext("TP2",barindex,itarget7,dialog,standard,10) coloured(250,250,250)
elsif low crosses under itarget8 then
drawtext("TP3",barindex,itarget8,dialog,standard,10) coloured(250,250,250)
endif
endif
return sarfast as"SARFAST" coloured(r,g,0) style(line,1),sarslow as"SARLOW" coloured(0,195,255) style(line,1),sarclose as"SARCLOSE" coloured(255, 0, 255) style(line,1)