DEFPARAM PreLoadBars = 0
DEFPARAM CumulateOrders = FALSE
//------------
timeframe(daily, updateonclose)
myAdx = Adx[5]
AdxMaxOk = (myAdx[1] < 45)
AdxMinOk = (myAdx[1] > 25)
timeframe(default)
myRange = DHigh(1)-DLow(1)
myBody = ABS(DOpen(1)-DClose(1))
if myRange=0 then
myRange=1
endif
RangeOk = myBody/myRange < 0.4
//------------
//Calcolo Livelli
LivelloH = Highest[48](High)
LivelloL = Lowest[48](Low)
//Condizioni generali di ingresso
CondizioniOk = Month <> 8 AND Time >= 010000 AND Time < 210000 AND AdxMaxOk AND AdxMinOk AND RangeOk
//Ingresso a mercato
IF CondizioniOk and Not LongOnMarket THEN
BUY 5 LOT AT LivelloH STOP
DaysLong = Days
ENDIF
IF CondizioniOk and Not ShortOnMarket THEN
SELLSHORT 5 LOT AT LivelloL STOP
DaysShort = Days
ENDIF
//Condizioni di uscita
UscitaLong = (((DayOfWeek=5) OR ( Days>=(DaysLong+5) AND POSITIONPERF > 0) OR ( Days>=(DaysLong+5) AND POSITIONPERF < 0) ) AND Time >= 210000 )
UscitaShort = (((DayOfWeek=5) OR ( Days>=(DaysShort+5) AND POSITIONPERF > 0) OR ( Days>=(DaysShort+5) AND POSITIONPERF < 0) ) AND Time >= 210000 )
//Uscita dal mercato
IF LongOnMarket AND UscitaLong THEN
SELL AT MARKET
ENDIF
IF ShortOnMarket AND UscitaShort THEN
EXITSHORT AT MARKET
ENDIF
//SL & TP
SET STOP pLOSS 50
SET TARGET pPROFIT 150