Colore candele in base al trend

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #250652 quote
    Trading97
    Participant
    New

    Buonasera, è possibile colorare le candele del grafico in base ad un trend come potrebbe essere un semplice incrocio di due medie mobili? Candele per es. sempre verdi fintanto che la mm a 20 periodi sta sopra la mm a 50 e rosse viceversa? Che comandi devo usare? Grazie.

    #250653 quote
    JS
    Participant
    Senior

    Ciao,

    Prova questi…

    FastAvg=Average[20,0](Close)
    SlowAvg=Average[50,0](Close)
    
    If FastAvg>=SlowAvg then
    DrawCandle(Open,High,Low,Close) Coloured("Green")
    Else
    DrawCandle(Open,High,Low,Close) Coloured("Red")
    EndIf
    
    Return FastAvg as "FastAvg" Coloured("Red"), SlowAvg as "SlowAvg" Coloured("Green")
    Iván González thanked this post
    #250655 quote
    Trading97
    Participant
    New

    Grazie.

    JS thanked this post
    #250658 quote
    Trading97
    Participant
    New

    Scusami un’ultima cosa, volessi farlo con due coppie di mm (quindi 4) anzichè due soltanto, come verrebbe implementato il codice? Esempio: colorare le candele del grafico verdi fintanto che (per es.) la mm a 5 e la mm a 10 periodi sono tutte e due sopra le mm a 30 e 35  e rosse viceversa?  Grazie infinite.

    #250659 quote
    JS
    Participant
    Senior

    No problema… 🙂

    SuperFastAvg=Average[5,0](Close)
    FastAvg=Average[10,0](Close)
    SlowAvg=Average[30,0](Close)
    SuperSlowAvg=Average[35,0](Close)
    
    
    If SuperFastAvg>=SuperSlowAvg and SuperFastAvg>=SlowAvg and FastAvg>=SuperSlowAvg and FastAvg>=SlowAvg  then
    DrawCandle(Open,High,Low,Close) Coloured("Green")
    Else
    DrawCandle(Open,High,Low,Close) Coloured("Red")
    EndIf
    
    Return SuperFastAvg as "SuperFastAvg" Coloured("Red"),FastAvg as "FastAvg" Coloured("Red"),SuperSlowAvg as "SuperSlowAvg" Coloured("Green"), SlowAvg as "SlowAvg" Coloured("Green")
    
    robertogozzi and Iván González thanked this post
    #250663 quote
    Trading97
    Participant
    New

    Ottimo, ma esiste anche la possibilità poi non disturbo veramente più, che si possa avere un codice dove le candele restano in trend (cioè per es. sempre colorate di verde) anche quando solo 1 condizione su x condizioni resta in piedi. Mi spiego meglio: trend che resta al rialzo (quindi candele verdi) quando la candela chiude sopra anche solo una delle per es. 4 mm prese in considerazione. Esplicito ulteriormente: Il trend deve rimanere rialzista fintanto che la chiusura della candela resta sopra anche ad una sola delle mm (a 5 o a 10 o a 30 o a 35 periodi),  basta che resti anche sopra una mm soltanto delle 4 che la candela deve restare verde, per diventare rossa serve che la chiusura sia inferiore a tutte e 4 le mm.

    #250664 quote
    JS
    Participant
    Senior

    Esatto, puoi programmare tutte le combinazioni usando le “istruzioni condizionali”…

    SuperFastAvg=Average[5,0](Close)
    FastAvg=Average[10,0](Close)
    SlowAvg=Average[30,0](Close)
    SuperSlowAvg=Average[35,0](Close)
    
    
    If Close>=SuperFastAvg or Close>=FastAvg or Close>=SlowAvg or Close>=SuperSlowAvg then
    DrawCandle(Open,High,Low,Close) Coloured("Green")
    ElsIf Close<SuperFastAvg and Close<FastAvg and Close<SlowAvg and Close<SuperSlowAvg then
    DrawCandle(Open,High,Low,Close) Coloured("Red")
    EndIf
    
    Return SuperFastAvg as "SuperFastAvg" Coloured("Red"),FastAvg as "FastAvg" Coloured("Red"),SuperSlowAvg as "SuperSlowAvg" Coloured("Green"), SlowAvg as "SlowAvg" Coloured("Green")
    Iván González thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Colore candele in base al trend


ProBuilder: Indicatori & Strumenti Personalizzati

New Reply
Author
author-avatar
Trading97 @trading97 Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by JS
4 months, 3 weeks ago.

Topic Details
Forum: ProBuilder: Indicatori & Strumenti Personalizzati
Language: Italian
Started: 09/10/2025
Status: Active
Attachments: 3 files
Logo Logo
Loading...