// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
defparam flatbefore = 080000
defparam flatafter = 170000
// --- settings
SlowLength = 7 // Slow length
SlowPipDisplace = 0 // Slow pip displace
FastLength = 3 // Fast length
FastPipDisplace = 0 // Fast pip displace
MinDailyProfit=20 //Max daily loss allowed (in points)
// --- end of settings
thigh1 = Highest[SlowLength](high)+ SlowPipDisplace*pointsize
tlow1 = Lowest[SlowLength](low)- SlowPipDisplace*pointsize
thigh2 = Highest[FastLength](high)+ FastPipDisplace*pointsize
tlow2 = Lowest[FastLength](low)- FastPipDisplace*pointsize
if barindex>2 then
if Close>line1[1] then
line1 = tlow1
else
line1 = thigh1
endif
if Close>line2[1] then
line2 = tlow2
else
line2 = thigh2
endif
endif
if (Close[0]<line1[0] and Close[0]<line2[0]) then
trend = 1
endif
if (Close[0]>line1[0] and Close[0]>line2[0]) then
trend = -1
endif
if (line1[0]>line2[0] or trend[0] = 1) then
trena = 1
endif
if (line1[0]<line2[0] or trend[0] = -1) then
trena = -1
endif
//----
// first time we launch the code, the trading is allowed
once TradeAllowed=1
if intradaybarindex=0 then
count=0
MyProfit=STRATEGYPROFIT
TradeAllowed=1
endif
// test if the strategyprofit of the day is currently above the daily profit allowed
If StrategyProfit>=MyProfit+(MinDailyProfit*POINTVALUE) then
TradeAllowed=0
endif
if TradeAllowed and trena<>trena[1] and trend=-1 and not onmarket and count<150 then
buy 1 contract at market
endif
if longonmarket and trend=1 then
sell at market
endif
if longonmarket and tradeindex<>lastindex then
count=count+1
lastindex=tradeindex
endif
SET STOP PLOSS 5
SET TARGET PPROFIT 5