Ordini Cumulativi

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #65134 quote
    beppe8949
    Participant
    Average

    Ciao Roberto! Penso di aver risolto con il discorso trailing stop, però sto avendo un problema che non riesco in nessun modo a risolvere. Allora, ho modificato il mio indicatore, è basato sui principali pattern di inversione, se io faccio un test su ogni singolo pattern sul dax a 30 mninuti, mi da dei risultati davvero eclatanti, fino al 96% di trades vincenti, il problema ora è un altro, che quando mi apre una posizione ad esempio short, e il mio indicatore da un altro segnale short, lui non apre un’altra posizione sempre short e io vorrei invece che facesse proprio così. Ho provato a mettere “DEFPARAM CUMULATEORDERS = TRUE” e ho provato con “DEFPARAM CUMULATEORDERS = FALSE” ma niente da fare, mi tiene una posizione per giorni e poi la chiude.. E’ un peccato perchè LONG su 53 posizioni, 48 vanno in profit e SHORT su 45 ne vanno in profit 42.. Mentre l’indicatore da segnali almeno 10 volte tanto in 2 anni.. Riusciresti ad aiutarmi in questo? Grazie mille!

    #65138 quote
    robertogozzi
    Moderator
    Master

    Se posti il codice completo posso esaminarlo.

    #65141 quote
    beppe8949
    Participant
    Average
    DEFPARAM CUMULATEORDERS = TRUE
    DEFPARAM PRELOADBARS = 10000
    
    /////////////////////////////////////////////////////////////////////////////////////
    
    CicloContinuo=PERIODOCONTINUO // 1=24h/24h  0=orari stabiliti
    
    noEntryBeforeTime=STARTTIME //  ora inizio EGLin 6 cifre
    
    noEntryAfterTime=FINISHTIME //  ora fine EGL in 6 cifre
    
    Long=RIALZO // direzione rialzo 1=si  0=no
    
    Short=RIBASSO // direzione ribasso 1=si 0=no
    
    TargetStop=STOPTARGET // 1=targetprice e stoploss 0=opera solo con segnali indicatore
    
    PointTarget=TARGETPRICE   // limite punti di profitto
    
    PointStop=STOPLOSS   // limite punti di perdita
    
    PointMaxLoss=MAXLOSS   // limite massimo punti di perdita (con stoploss=0)
    
    size=NUMCONTRATTI   //  numero di contratti/valore del pip (punto)
    
    PointSogliaTrailing=STARTTRAILSTOP  // valore che attiva il trailingstop
    
    PointTrailingStop=POINTTRAILSTOP  //  valore del trailingstop
    
    //////////////////////////////////////////////////////////////////////////////////////
    
    timeEnterBefore = time >= noEntryBeforeTime
    timeEnterAfter = time <= noEntryAfterTime
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    indicator1 = CALL EGL
    c1 = (indicator1=2)
    c2 = (indicator1=1)
    IF TargetStop=0 AND (CicloContinuo=1 OR (CicloContinuo=0 AND timeEnterBefore AND timeEnterAfter AND NOT daysForbiddenEntry)) THEN
    IF c1 AND ShortOnMarket AND Long=0 THEN
    EXITSHORT AT MARKET
    ENDIF
    IF c1  AND NOT LongOnMarket AND Long=1 THEN
    BUY size CONTRACTS AT MARKET
    SET STOP pLOSS PointMaxLoss
    ENDIF
    IF c2 AND LongOnMarket AND Short=0 THEN
    SELL AT MARKET
    ENDIF
    IF c2  AND NOT ShortOnMarket AND Short=1 THEN
    SELLSHORT size CONTRACTS AT MARKET
    SET STOP pLOSS PointMaxLoss
    ENDIF
    ENDIF
    
    IF TargetStop=0 AND (CicloContinuo=0 AND (NOT timeEnterBefore OR NOT timeEnterAfter OR daysForbiddenEntry)) THEN
    IF c1 AND ShortOnMarket THEN
    EXITSHORT AT MARKET
    ENDIF
    IF c2 AND LongOnMarket THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    
    IF TargetStop=1 AND (CicloContinuo=1 OR (CicloContinuo=0 AND timeEnterBefore AND timeEnterAfter AND NOT daysForbiddenEntry)) THEN
    IF c1  AND NOT LongOnMarket AND Long=1 THEN
    BUY size CONTRACTS AT MARKET
    SET STOP pLOSS PointStop
    SET TARGET pPROFIT PointTarget
    AttivaTrailingLong=0
    ENDIF
    IF c2  AND NOT ShortOnMarket AND Short=1 THEN
    SELLSHORT size CONTRACTS AT MARKET
    SET STOP pLOSS PointStop
    SET TARGET pPROFIT PointTarget
    AttivaTrailingShort=0
    ENDIF
    ENDIF
    
    IF TargetStop=1 AND PointTrailingStop>0 AND ONMARKET THEN
    if LongOnMarket and High>=POSITIONPRICE+PointSogliaTrailing*POINTSIZE AND AttivaTrailingLong=0 then
    AttivaTrailingLong=1
    if (High-Close)<PointTrailingStop*POINTSIZE then
    newSL=High-PointTrailingStop*POINTSIZE
    SELL AT newSL STOP
    else
    SELL AT MARKET
    endif
    SET STOP pTRAILING PointTrailingStop
    endif
    if ShortOnMarket and Low<=POSITIONPRICE-PointSogliaTrailing*POINTSIZE AND AttivaTrailingShort=0 then
    AttivaTrailingShort=1
    if (Close-Low)<PointTrailingStop*POINTSIZE then
    newSL=Low+PointTrailingStop*POINTSIZE
    EXITSHORT AT newSL STOP
    else
    EXITSHORT AT MARKET
    endif
    SET STOP pTRAILING PointTrailingStop
    endif
    
    if LongOnMarket AND AttivaTrailingLong=1 then
    if (High-Close)<PointTrailingStop*POINTSIZE then
    newSL=max(High-PointTrailingStop*POINTSIZE,newSL)
    SELL AT newSL STOP
    else
    SELL AT MARKET
    endif
    endif
    if ShortOnMarket and AttivaTrailingShort=1 then
    if (Close-Low)<PointTrailingStop*POINTSIZE then
    newSL=min(Low+PointTrailingStop*POINTSIZE,newSL)
    EXITSHORT AT newSL STOP
    else
    EXITSHORT AT MARKET
    endif
    endif
    ENDIF
    
    #65154 quote
    robertogozzi
    Moderator
    Master

    Ho creato un altro thread perché è un argomento diverso dal trailing stop.

    #65155 quote
    robertogozzi
    Moderator
    Master

    Purtroppo mancano le variabili, non posso provarlo.

    #65157 quote
    beppe8949
    Participant
    Average

    Ok grazie, l’indicatore l’ho modificato, te lo inoltro in allegato, anzi ti inoltro anche il trading system!
    Grazie!

    #65175 quote
    robertogozzi
    Moderator
    Master

    Non ti apre più posizioni perché così gli hai detto nel codice (DEFPARAM CUMULATEORDERS = TRUE diventa ininfluente), infatti le righe 71-72 sono

    IF c2  AND NOT ShortOnMarket AND Short=1 THEN
       SELLSHORT size CONTRACTS AT MARKET

    dove gli dici di andare SHORT quando la condizione c2 è verificata E NON è già short.

    Per cui NON aprirà mai un’altra posizione short!!!

    Prova a scriverla così

    IF c2 AND Short=1 THEN
       SELLSHORT size CONTRACTS AT MARKET

    ripeti il procedimento anche per i LONG.

    #65184 quote
    beppe8949
    Participant
    Average

    Ok grazie, provo tra poco e ti faccio sapere! 🙂

    #65185 quote
    beppe8949
    Participant
    Average

    Niente da fare Roberto.. Ho provato a modificare e addirittura a togliere tutta la parte del trailing stop riducendo il codice solo a tp e sl ma mi apre solamente 95 posizioni in 2 anni quando l’indicatore da centinaia di segnali in più..

    #65188 quote
    robertogozzi
    Moderator
    Master

    Comunque avevo notato che a me le posizioni duravano una sola candela, non più giorni, sul DAX a 30 minuti.

    #65189 quote
    beppe8949
    Participant
    Average

    No no a me vanno avanti anche settimane.. E’ proprio questo che non voglio caspita.. Con quel codice che ti ho mandato e seguendo l’indicatore.. sia long che short.. Come posso fare?

    #65190 quote
    robertogozzi
    Moderator
    Master

    A me funziona benissimo, vedo che molti segnali si verificano prima dell’ora iniziale oppure DOPO, per cui non entra, ma questo non dipende dal codice, solo dagli orari scelti.

    Non saprei davvero darti indicazioni, non so quali impostazioni di trading hai. Tu l’hai provato sul DAX a 30 minuti?

    #65192 quote
    robertogozzi
    Moderator
    Master

    Prova ad inserire le seguenti istruzioni per il debugging.

    GRAPH c1
    GRAPH c2
    GRAPH Long
    Graph Short

    Puoi al massimo vedere 5 variabili contemporaneamente.

    Ti allego una foto delle mie impostazioni del TS.

    #65194 quote
    beppe8949
    Participant
    Average

    Ok, grazie! Dove devo inserire GRAPH c1 GRAPH c2 GRAPH Long GRAPH Short ?
    Nell’indicatore oppure nel trading system? In che sezione?
    Comunque si DAX 30 minuti!

    #65195 quote
    robertogozzi
    Moderator
    Master

    Subito dopo la riga 37, dove c’è l’asssegnazione del valore a C2.

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

Ordini Cumulativi


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
beppe8949 @beppe8949 Participant
Summary

This topic contains 15 replies,
has 2 voices, and was last updated by beppe8949
7 years, 11 months ago.

Topic Details
Forum: ProOrder: Trading Automatico & Backtesting
Language: Italian
Started: 03/12/2018
Status: Active
Attachments: 5 files
Logo Logo
Loading...