Entrata su livello percentile ed uscita ad n giorni

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #245636 quote
    othello
    Participant
    Senior

    Buonasera.

    Sono passati diversi anni dalla scrittura dell’ultimo codice PRT e sono un po’ arrugginito. Mi scuso, sin da subito, se la domanda risulta banale.

    Partendo dall’indicatore percentile, vorrei realizzare un sistema che entra in apertura di barra successiva a quella in cui si è verificata la rottura di un certo livello dell’indicatore. Ad esempio, il sistema potrebbe entrare Long se il valore del percentile è superiore ad 80 uscendo dopo un certo numero fisso di barre (per esempio 5).
    E, potrebbe entrare Short se il valore del percentile è inferiore a 20; anche in questo caso, uscendo dopo un certo numero fisso di barre.

    Spero sia sufficientemente chiaro.

    Grazie.

    #245665 quote
    Iván González
    Moderator
    Master

    Buongiorno. Non so a quale indicatore percentile si riferisca.
    Ho programmato un indicatore che calcola il percentile e, in base a este, si calcolano le entrate.
    Se si riferisce a un altro indicatore, basta sostituirlo nel mio codice e funzionerà comunque.

    //Percentile
    p=200
    rnkCount = 0
    count = 0
    FOR i = 1 to p-1
    count = count + 1
    IF close[i] < close THEN
    rnkCount = rnkCount + 1
    endif
    NEXT
     
    PercentileRank = (rnkCount/count)*100
    
    if not onmarket and PercentileRank crosses over 80 then
    buy 1 contract at market
    elsif not onmarket and PercentileRank crosses under 20 then
    sellshort 1 contract at market
    endif
    
    if onmarket then
    bars=bars+1
    else
    bars=0
    endif
    
    if longonmarket and bars=5 then
    sell at market
    elsif shortonmarket and bars=5 then
    exitshort at market
    endif
    
    graph PercentileRank coloured("darkblue")
    graph 20 coloured("red")
    graph 80 coloured("green")
    robertogozzi thanked this post
    #245731 quote
    othello
    Participant
    Senior

    Perfetto!
    Ora voglio lavorarci un po’, anche per riprendere la mano (come scrivevo sopra, c’è un po’ di ruggine …).
    Grazie, Ivan, per il tuo tempo e la cortese disponibilità.

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

Entrata su livello percentile ed uscita ad n giorni


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
othello @othello Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by othello
10 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 04/06/2025
Status: Active
Attachments: No files
Logo Logo
Loading...