//-------------------------------------------------------------------------
// Codice principale : LUNEDI
//-------------------------------------------------------------------------
// Definizione dei parametri del codice
DEFPARAM CumulateOrders = False // Posizioni cumulate disattivate
// Il sistema cancellerà tutti gli ordini in attesa e chiuderà tutte le posizioni a 0:00. Dopo l'orario "Flat Before" non saranno piazzati nuovi ordini o posizioni.
DEFPARAM FLATBEFORE = 070000
// Cancellare tutti gli ordini in attesa e chiudere tutte le posizioni all'orario "Flat After"
Otd = (Barindex - TradeIndex(1) > IntradayBarIndex)
// giorni tradabili specifici della settimana LUNEDI
daysForbiddenEntry = OpenDayOfWeek = 2 OR OpenDayOfWeek = 3 OR OpenDayOfWeek = 4 OR OpenDayOfWeek = 5 OR OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
indicator1 = SuperTrend[3,10]
c1 = (close[1] CROSSES OVER indicator1)
IF c1 AND not daysForbiddenEntry AND Otd AND trailingstart AND trailingstep AND Time < 200000 THEN
BUY 1 CONTRACT AT MARKET
ENDIF
SET STOP PLOSS 680
//************************************************************************
//trailing stop function
trailingstart =250//trailing will start @trailinstart points profit
trailingstep = 100//trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//************************************************************************