Condizione RSI non rispettata

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #171532 quote
    Wolf Trades
    Participant
    Average

    Salve a tutti, ho implementato questo sistema HA. Eseguendo il backtest mi sono reso conto che vengono aperte operazioni long anche quando l’RSI non si trova sotto il valore 3o e operazioni short anche quando l’RSI non si trova sopra il valore 70. Non riesco a capire il motivo visto che sono condizioni scritte nel mio sistema.

    Allego il codice per chi potrà aiutarmi.

    Inoltre volevo sapere se i take profit e gli stoploss scritti così sono corretti.

    DEFPARAM PreLoadBars = 300
    DEFPARAM CumulateOrders = False
    DEFPARAM FLATBEFORE = 070100 // Il TS non apre trade prima di questo orario
    //DEFPARAM FLATAFTER = 180000  // Il TS non apre trade dopo questo orario e chiude le posizioni ancora aperte
    
    
    // HA - definizione Heikin-Ashi
    once xOpen = open
    xClose = (open+close+high+low)/4
    if barindex > 0 then
    xOpen = (xOpen[1]+xClose[1])/2
    endif
    xLow = min(low,min(xClose,xOpen))
    xHigh = max(high,max(xClose,xOpen))
    xRange = abs(xHigh - xLow)
    xBody = abs(XClose - xOpen)
    
    //Indicatori
    EMA20 = ExponentialAverage[20](xClose)
    EMA100 = ExponentialAverage[100](xClose)
    EMA200 = ExponentialAverage[200](xClose)
    MyRSI = RSI[14](xclose)
    
    
    //Trend Rilazista candele
    a1 = xClose[1] > xClose[2]
    a2 = xClose[2] > xClose[3]
    a3 = xClose[3] > xClose[4]
    a4 = xClose[4] > xClose[5]
    a5 = xClose[5] > xClose[6]
    a6 = xClose[6] > xClose[7]
    
    //Trend Rilazista EMA
    //d1 = EMA20 > EMA100
    //d2 = EMA100 > EMA200
    //TrendEMAUP = d1 and d2
    
    //Trend Ribassista candele
    b1 = xClose[1] < xClose[2]
    b2 = xClose[2] < xClose[3]
    b3 = xClose[3] < xClose[4]
    b4 = xClose[4] < xClose[5]
    b5 = xClose[5] < xClose[6]
    b6 = xClose[6] < xClose[7]
    
    //Trend Ribassista EMA
    //d3 = EMA20 < EMA100
    //d4 = EMA100 < EMA200
    //TrendEMADOWN = d3 and d4
    
    TrendUP = a1 and a2 and a3 and a4 // aggiungere o diminuire le condizioni "a" in base alla forza del trend che cerchiamo
    TrendDOWN = b1 and b2 and b3 and b4 // aggiungere o diminuire le condizioni "b" in base alla forza del trend che cerchiamo
    
    // Condizioni corpo candela
    Ratio1 = 0.25 // il 25%
    c1 = abs(xBody > xRange*Ratio1) // il corpo della candela che crea il segnale è maggiore del n% del range
    
    // Chiusura Posizioni dopo le ore hhmmss
    TempoScaduto = CurrentTime > 200000
    
    // Aggiungo "n" Point/Pips al mio stopLoss
    Npips = 2 * pipsize
    
    //Condizione BUY
    c2 = xRange < xRange[1]  // il range della candela che crea il segnale è minore di quello della candela precedente
    c3 = xClose > xOpen // Candela Rialzista
    c31= xClose[1] < xOpen[1] //la candela precedente è ribassista
    c33 = MyRSI[1] < 30 or MyRSI[2] < 30
    MyStop1 = abs((xClose - Lowest[2](xLow))- Npips) // il minimo tra 2 minimi fa - Npips
    MyProfit1 = TradePrice + (abs (MyStop1*2))
    
    //Condizione SELL
    c4 = xRange < xRange[1]  // il range della candela che crea il segnale è minore di quello della candela precedente
    c5 = xClose < xOpen // Candela Ribassista
    c51 = xClose[1] > xOpen[1] // la candela precedente è rialzista
    c55 = MyRSI[1] > 70 or MyRSI[2] > 70
    MyStop2 = abs((xClose + Highest[2](xHigh))+ Npips)  // il massimo tra due massimi fa + Npips
    MyProfit2 = TradePrice - (abs (MyStop2*2))
    
    
    // Condizioni per entrare su posizioni long
    IF NOT LongOnMarket AND c1 and c2 and c3 and  c31 and C33 THEN
    BUY 1 CONTRACTS AT MARKET
    SET STOP LOSS  MyStop1  //se inserisco MySTop1 devo togliere la "p" prima di LOSS
    SET TARGET pPROFIT MyProfit1   //se inserisco MyProfit1 devo togliare la "p" prima di PROFIT
    ENDIF
    
    // Condizioni per uscire da posizioni long
    If LongOnMarket AND TempoScaduto THEN
    SELL AT MARKET
    ENDIF
    
    // Condizioni per entrare su posizioni short
    IF NOT ShortOnMarket AND c1 and c4 and c5 and c51 and c55 THEN
    SELLSHORT 1 CONTRACTS AT MARKET
    SET STOP LOSS  MyStop2 //se inserisco MySTop2 devo togliere la "p" prima di LOSS
    SET TARGET pPROFIT MyProfit2  //se inserisco MyProfit2 devo togliare la "p" prima di PROFIT
    ENDIF
    
    // Condizioni per uscire da posizioni short
    IF ShortOnMarket AND TempoScaduto THEN
    EXITSHORT AT MARKET
    ENDIF
    
    #171545 quote
    robertogozzi
    Moderator
    Master

    Credo sia perché tu fai il confronto con il normale RSI che lavora sulle candele giapponesi.

    Prova con questo RSI per Heikin-Ashi:

    N = 14
    // HA - definizione Heikin-Ashi
    once xOpen = open
    xClose = (open+close+high+low)/4
    if barindex > 0 then
        xOpen = (xOpen[1]+xClose[1])/2
    endif
    MyRSI = RSI[N](xclose)
    RETURN MyRSI AS "Rsi HA",70 AS "Ob",30 AS "Os"
    Wolf Trades thanked this post
    #171546 quote
    robertogozzi
    Moderator
    Master

    In effetti se lavora solo sulla chiusura si può anche scrivere:

    N = 14
    // HA - definizione Heikin-Ashi
    xClose = (open+close+high+low)/4
    MyRSI  = RSI[N](xclose)
    RETURN MyRSI AS "Rsi HA",70 AS "Ob",30 AS "Os"
    Wolf Trades thanked this post
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Condizione RSI non rispettata


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Wolf Trades @lupo32 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by robertogozzi
4 years, 9 months ago.

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