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.
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.
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..
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
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
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.