CHIUDERE POSIZIONI APERTE DOPO X ORE

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

    Buonasera a tutti:

    Vorrei chiedervi se è possibile, e quale il relativo comando, trasferire alla macchina il comando: “chiudi la posizione dopo X ore dall’apertura” o “se dopo x ore la posizione non è ancora chiusa, allora chiudila”

    In questo caso lavoro su Daily, quindi non posso riferirmi alla barre, che rappresentano ovviamente una giornata.

    ps: esistono manuali o video che spieghino ai novizi come si programma con PROBILDER?

    Vi ringrazio anticipatamente.
    Giacomo.

    #55289 quote
    robertogozzi
    Moderator
    Master

    Col daily non è possibile interrompere un trade a certe ore, perché le strategie vengono eseguite solo alla chiusura di ogni barra e non c’è un comando in proposito.

    Bretty86 and Nicolas thanked this post
    #65760 quote
    beppe8949
    Participant
    Average
    Ciao Roberto! Su un timeframe minore come si fa invece? E altra domanda, come si fa invece a far chiudere qualsiasi posizione aperta a una certa ora? Esempio ho una posizione long sul dax alle 21 e vorrei che alle 22 si chiudesse automaticamente..
    #65762 quote
    beppe8949
    Participant
    Average
    Ok ho risolto, ho trovato un tuo post! Grazie, dovrebbe essere:
    IF OpenDayOfWeek = 5 AND time = 200000 AND OnMarket THEN
       SELL      AT MARKET  //chiudere i   LONG,  se aperti
       EXITSHORT AT MARKET  //chiudere gli SHORT, se aperti
    ENDIF
    robertogozzi thanked this post
    #65769 quote
    beppe8949
    Participant
    Average
    Roberto perdonami, ho provato ad inserire nel codice il comando per chiudere qualsiasi posizione alle 22, però non mi pare funzioni.. Di seguito il codice completo
    DEFPARAM CUMULATEORDERS = TRUE
    DEFPARAM PRELOADBARS = 10000
    
    /////////////////////////////////////////////////////////////////////////////////////
    
    CicloContinuo=0//PERIODOCONTINUO//1=24h/24h  0=orari stabiliti
    
    noEntryBeforeTime=080000//STARTTIME//ora inizio EGLin 6 cifre
    
    noEntryAfterTime=220000//FINISHTIME//ora fine EGL in 6 cifre
    
    Long=1//RIALZO//direzione rialzo 1=si  0=no
    
    Short=0//RIBASSO//direzione ribasso 1=si 0=no
    
    TargetStop=1//STOPTARGET//1=targetprice e stoploss 0=opera solo con segnali indicatore
    
    PointTarget=25//TARGETPRICE//limite punti di profitto
    
    PointStop=10//STOPLOSS//limite punti di perdita
    
    PointMaxLoss=123456//MAXLOSS//limite massimo punti di perdita (con stoploss=0)
    
    size=1//NUMCONTRATTI//numero di contratti/valore del pip (punto)
    
    Frame=2//EGLFRAME//settaggi indicatore
    
    PointSogliaTrailing=123456//STARTTRAILSTOP//valore che attiva il trailingstop
    
    PointTrailingStop=123456//POINTTRAILSTOP//valore del trailingstop
    
    //////////////////////////////////////////////////////////////////////////////////////
    
    timeEnterBefore = time >= noEntryBeforeTime
    timeEnterAfter = time <= noEntryAfterTime
    daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
    indicator1 = CALL EGLTREND[Frame]
    c1 = (indicator1 = 2)
    c2 = (indicator1 = 1)
    IF time >= noEntryAfterTime AND OnMarket THEN
    SELL AT MARKET
    EXITSHORT AT MARKET
    ENDIF
    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
    
    #65780 quote
    robertogozzi
    Moderator
    Master
    Credo l’unico problema delle ore 22 sia il DAX, che chiude alle 22:00, per cui quando viene eseguita la strategia, alle 22, il DAX è già chiuso e quindi la chiude alla prima candela successiva, alle 08:00 dell’indomani mattina. Se la provi su una coppia di valute vedrai che alle 22:00 se capita chiude ogni operazione aperta.
    #65849 quote
    beppe8949
    Participant
    Average
    Ah ok perfetto!
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

CHIUDERE POSIZIONI APERTE DOPO X ORE


ProOrder: Trading Automatico & Backtesting

New Reply
Author
author-avatar
Bretty86 @bretty86 Participant
Summary

This topic contains 6 replies,
has 3 voices, and was last updated by beppe8949
7 years, 10 months ago.

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