DEFPARAM CumulateOrders = false // Posizioni cumulate disattivate
DEFPARAM PRELOADBARS = 2000
//DEFPARAM FLATBEFORE = 070000
DEFPARAM FLATAFTER = 220000
orainizio = 070000 // HHMMSS
orafine = 220000 //HHMMSS
ObiettivoDay = 10 //obiettivo cumulativo daily in punti x chiudere la strategia
Maxlossday = 200 // eventuale max loss cumulativo daily x chiudere la strategia - mettere 10000 per disattivare
CNTR = 1 //numero di contratti per posizione
//fascia oraria x inserimento operazioni
if time>orainizio and time <orafine then
fasciaoraria=1
else
fasciaoraria=0
endif
//azzeramento variabili daily
if time => orainizio and time <orainizio+200 then
gainday=0
countoperDay=0
endif
//indicatori
mm1=average[20](close)
mm2=average[100](close)
If mm1>mm2 then
direction = 1
endif
If mm1<mm2 then
direction = -1
endif
/////////////////
//Condizioni per entrare su posizioni long
EL1 = (direction crosses over 0.5) and fasciaoraria=1 and StrategyONL
UL1 = direction=-1
IF NOT longonmarket and EL1 = 1 THEN
BUY CNTR CONTRACT AT MARKET
mementryL=close
CountOperDay=CountOperDay+1
ENDIF
IF longonmarket and UL1 = 1 THEN
SELL AT MARKET
memexitL=close
gainparz=memexitL-mementryL
gainday=gainday+gainparz
ENDIF
StrategyONS = fasciaoraria=1 and gainday<ObiettivoDay and gainday>-Maxlossday
/////////////////
//Condizioni per entrare su posizioni short
ES1 = (direction crosses under -0.5) and fasciaoraria=1 and StrategyONS
US1 = direction=1
IF NOT shortonmarket and ES1 = 1 THEN
SELLSHORT CNTR CONTRACT AT MARKET
mementryS=close
CountOperDay=CountOperDay+1
ENDIF
IF shortonmarket and US1 = 1 THEN
EXITSHORT AT MARKET
memexitS=close
gainparz=mementryS-memexitS
gainday=gainday+gainparz
ENDIF
StrategyONL = fasciaoraria=1 and gainday<ObiettivoDay and gainday>-Maxlossday
//visualizzazione indicatori
graph gainday coloured (0,0,200) as "Guadagno_Giorno"
graph CountOperDay coloured (0,0,10) as "Operazioni_Daily"
graph StrategyONS
graph StrategyONL