texte des take profit sur bougies avec DRAWTEXT

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #210470 quote
    AMDAMD
    Participant
    New

    Bonjour, J’ai un soucis sur un code que j’ai trouvé ici et modifié. Je voudrais faire apparaitre sur la bougie mes TP quand celle-ci rentre des les paramètres prédéfinie et non sur la bougie barindex. MERCI !

    // --- 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
    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
    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
    
    
    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)
    Capture-decran-2023-02-25-a-15.06.06.png Capture-decran-2023-02-25-a-15.06.06.png
    #210579 quote
    NicolasNicolas
    Keymaster
    Legend

    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)
    #210583 quote
    AMDAMD
    Participant
    New

    Bonjour Nicolas,

    Merci 1000 fois, bonne semaine 😉

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

texte des take profit sur bougies avec DRAWTEXT


ProBuilder : Indicateurs & Outils Personnalisés

New Reply
Author
author-avatar
AMD @amd Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by AMDAMD
3 years, 6 months ago.

Topic Details
Forum: ProBuilder : Indicateurs & Outils Personnalisés
Language: French
Started: 02/25/2023
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...