//Fomr Inertia 12/01/2018
// Définition des paramètres du code
DEFPARAM CumulateOrders = FALSE
//Trade to be closed after 5 bars
x = 5
IF BarIndex - TradeIndex = x Then
Sell at Market
endif
indicator1 = Volume
c1 = (indicator1 >= 10000)
indicator2 = MACD[12,24,9](close)
c2 = (indicator2 > 0)
indicator3 = MACDline[12,24,9](close)
c3 = (indicator3 < 0)
indicator4 = Williams[14](close)
c4 = (indicator4 >= -20)
IF c1 AND c2 AND c3 AND c4 THEN
BUY positionsize CONTRACT AT MARKET
ENDIF
//MM...
once startpositionsize=1
once positionsize=startpositionsize
once flatoverweekends=1
once startequity=0
once Reinvest=1
if reinvest then
//------------ Fixed fraction money management ----------
once multiplier=1
once delta=500 // < == THROTTLE
once fraction=delta*pipvalue
once newlevel=delta*pipvalue
once oldlevel=delta*pipvalue
if strategyprofit+startequity>newlevel then
multiplier=multiplier+1
oldlevel=newlevel
newlevel=strategyprofit+startequity+multiplier*fraction
positionsize=multiplier*startpositionsize
elsif strategyprofit+startequity<oldlevel and multiplier>=2 then
newlevel=strategyprofit+startequity
oldlevel=strategyprofit+startequity-multiplier*fraction
multiplier=multiplier-1
positionsize=multiplier*startpositionsize
endif
Endif
if flatoverweekends then
//--------------- daylight-saving corrections ------------------
if currentmonth=3 and day>=15 then
dlc=10000
elsif currentmonth=11 and day<8 then
dlc=10000
else
dlc=0
endif
fridaynight=(currentdayofweek=5 and time>=(223000-dlc))
else
fridaynight=0
endif
if fridaynight then
if longonmarket then
sell at market
elsif shortonmarket then
exitshort at market
endif
endif
//trailing stop
trailingstop = 40
if not onmarket then
MAXPRICE = 0
priceexit = 0
endif
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then
priceexit = MAXPRICE-trailingstop*pointsize
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
SELL AT priceexit STOP
endif
SET STOP ploss 100//20
SET TARGET pPROFIT 150