//————————————————————————-
// Main code : EMA cross over DOW £1
//————————————————————————-
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the “FLATBEFORE” time.
DEFPARAM FLATBEFORE = 143500
// Cancel all pending orders and close all positions at the “FLATAFTER” time
DEFPARAM FLATAFTER = 220000
//// Prevents the system from placing new orders to enter the market or increase position size after the specified time
//noEntryAfterTime = 160000
//timeEnterAfter = time < noEntryAfterTime
// Prevents the system from placing new orders on specified days of the week
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
////stops trades within x bars after exit
//ONCE BarCount = 0
//ONCE TradeON = 1 //1=trading allowed 0=trading disbaled
//IF OnMarket AND Not OnMarket[1] THEN
//TradeON = 0 //disable trading
//BarCount = 0 //reset counter
//ENDIF
//IF Not OnMarket THEN //Increase counter when not on market
//BarCount = BarCount + 1
//ENDIF
//IF BarCount > 3 THEN
//TradeON = 1
//ENDIF
//Initial balance
myBalance5mDOW = CALL “Balance 5m DOW”
If Time = 143000 then
upper=highest[6](high)
lower=lowest[6](low)
endif
//Conditions to enter long positions
indicator1 = ExponentialAverage[shortT](close)
indicator2 = ExponentialAverage[longT](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF close >upper AND c1 AND myBalance5mDOW <minibalance AND not daysForbiddenEntry THEN
BUY 0.5 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = ExponentialAverage[shortT](close)
indicator4 = ExponentialAverage[longT](close)
c2 = (indicator3 CROSSES UNDER indicator4)
IF open <upper -5 OR C2 THEN
SELL AT MARKET
ENDIF
//Conditions to enter SHORT positions
indicator1 = ExponentialAverage[shortT](close)
indicator2 = ExponentialAverage[longT](close)
c3 = (indicator1 CROSSES UNDER indicator2)
IF c3 AND close <lower AND not daysForbiddenEntry THEN
SELLSHORT 0.5 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
indicator3 = ExponentialAverage[shortT](close)
indicator4 = ExponentialAverage[longT](close)
c4 = (indicator3 CROSSES OVER indicator4)
IF open >lower +5 OR C4 THEN
EXITSHORT AT MARKET
ENDIF
SET STOP pLOSS (stoploss)
SET TARGET pPROFIT (TP)