Trading system con Harsi

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #239166 quote
    xPepx71@
    Participant
    New

    Ciao. Vorrei provare un trading system basato sull’indicatore Harsi, che è già stato codificato (lo riporto sotto) e come indicatore funziona. Tuttavia se lo infilo in un trading system automatico non parte neppure il backtest, segnalando che la funzione da  5 valori invece che  6 . (boh ….) Magari qualche anima pia (Roberto Gozzi) che mi aiuta …

    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    // HARSI  by JS le 02.10.2023 modifié  02.10.2023
    defparam calculateonlastbars = 150
    //variables:
    rsip=7
    smoothing=1
    halength=14
    rsihelp= RSI[rsip]((high+close+low+open)/4)//-50
    rsihelp2= RSI[halength]((high+close+low+open)/4)//-50
    closersi2= rsi[halength](close)//-50
    if barindex>0 then
    openrsi2=rsi[halength](close[1])//-50
    else
    openrsi2=rsi[halength](close)//-50
    endif
    rsihighraw2= rsi[halength](high)//-50
    rslowraw2= rsi[halength](low)//-50
    rsihigh2= max(rsihighraw2,rslowraw2)
    rsilow2=min(rsihighraw2,rslowraw2)
    haclose= (closersi2+openrsi2+rsihigh2+rsilow2)/4
    if barindex > halength+2 then
    haopen = ((haopen[1]*smoothing) +haclose[1])/(smoothing+1)
    else
    haopen = (closersi2 +openrsi2)/2
    endif
    hahigh= max(rsihigh2, max(haopen,haclose))
    halow = min(rsilow2 , min( haopen, haclose))
    if haclose > haopen then
    r=0
    g=153
    b=153
    else
    r=238
    g=73
    b=73
    endif
    DRAWCANDLE(haopen, hahigh, halow, haclose) COLOURED(r,g,b) BORDERCOLOR(R,G,B)
    if barindex > rsip then
    rsismoothed = (rsismoothed[1]+ rsihelp)/2
    else
    rsismoothed = rsihelp
    endif
    return rsismoothed as “RSI-Smoothed”, 20 as “20”, 30 as “30”, 70 as “70”, 80 as “80”
    #239191 quote
    Iván González
    Moderator
    Master

    Ciao. Lascia che ti faccia un esempio. Ora devi solo modificare le condizioni di input e output per quelle che desideri.

    // HARSI  by JS le 02.10.2023 modifié  02.10.2023
    //variabili:
    rsip = 7
    smoothing = 1
    halength = 14
    
    rsihelp = RSI[rsip]((high+close+low+open)/4)
    closersi2 = rsi[halength](close)
    
    if barindex > 0 then
    openrsi2 = rsi[halength](close[1])
    else
    openrsi2 = rsi[halength](close)
    endif
    
    rsihighraw2 = rsi[halength](high)
    rslowraw2 = rsi[halength](low)
    rsihigh2 = max(rsihighraw2, rslowraw2)
    rsilow2 = min(rsihighraw2, rslowraw2)
    
    haclose = (closersi2 + openrsi2 + rsihigh2 + rsilow2) / 4
    
    if barindex > halength + 2 then
    haopen = ((haopen[1] * smoothing) + haclose[1]) / (smoothing + 1)
    else
    haopen = (closersi2 + openrsi2) / 2
    endif
    
    hahigh = max(rsihigh2, max(haopen, haclose))
    halow = min(rsilow2, min(haopen, haclose))
    
    if barindex > rsip then
    rsismoothed = (rsismoothed[1] + rsihelp) / 2
    else
    rsismoothed = rsihelp
    endif
    
    //----- Strategia di trading -----//
    
    // Condizioni di entrata/uscita lunghe
    yourConditionsOpenLong=rsismoothed crosses over 30
    yourConditionsCloseLong=rsismoothed crosses over 70
    
    if not longonmarket and yourConditionsOpenLong then
    BUY 1 CONTRACT AT MARKET
    endif
    
    if longonmarket and yourConditionsCloseLong then
    SELL AT MARKET
    endif
    
    // Condizioni di entrata/uscita corte
    yourConditionsOpenShort=rsismoothed crosses under 70
    yourConditionsCloseShort=rsismoothed crosses under 30
    if not shortonmarket and yourConditionsOpenShort then
    SELLSHORT 1 CONTRACT AT MARKET
    endif
    
    if shortonmarket and yourConditionsCloseShort then
    EXITSHORT AT MARKET
    endif
    #239214 quote
    xPepx71@
    Participant
    New

    Innanzitutto grazie per l’aiuto. Gentilissimo. Nel tuo codice hai tenuto   rsi e hai eliminato la parte sulle candele. che è quella per me più importante. Puoi fare qualcosa ? Ancora grazie

    Sotto ho messo un esempio

    Esempio

    #239215 quote
    xPepx71@
    Participant
    New

    Non riesco a far visualizzare l’immagine , ma penso che hai capito cosa intendo

    #239322 quote
    Iván González
    Moderator
    Master

    Ciao. Questo codice deve essere eseguito nel modulo di backtesting. Le candele non possono essere rappresentate in questo modulo.

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

Trading system con Harsi


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
xPepx71@ @peppe71 Participant
Summary

This topic contains 4 replies,
has 2 voices, and was last updated by Iván González
1 year, 3 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 10/17/2024
Status: Active
Attachments: No files
Logo Logo
Loading...