MatParticipant
New
2 Hour breakout strategy on price action. Goes long on 2 hour breakout with 50 Day EMA filter. Exits on either hitting Stop loss or Profit target or if price goes below 2 hour low of previous period. Opposite strategy for short trades. This is my first time to post so feedback from other members will be great to have. Below is the code.
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Prevents the system from creating new orders to enter the market or increase position size before the specified time
noEntryBeforeTime = 090000
timeEnterBefore = time >= noEntryBeforeTime
// 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
// Conditions to enter long positions
c1 = (close CROSSES OVER high[1])
indicator1 = ExponentialAverage[50](close)
c2 = (close > indicator1)
IF (c1 AND c2) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
BUY 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit long positions
c3 = (close < low[1])
IF c3 THEN
SELL AT MARKET
ENDIF
// Conditions to enter short positions
c4 = (close CROSSES UNDER low[1])
indicator2 = ExponentialAverage[50](close)
c5 = (close < indicator2)
IF (c4 AND c5) AND timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
// Conditions to exit short positions
c6 = (close > high[1])
IF c6 THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 25
SET TARGET pPROFIT 25
EricParticipant
Master
Hi Mat
Further to Eric’s comment, you need to have the Tick Mode box ticked when backtesting to give results nearest to what you will get in Live Trades.
For full details read Eric’s Ref, but see below how to tick the tick by tick box! 🙂
Cheers
GraHal
PS If you make the change below you get attached equity curve, so your code / values has potential.
SET STOP pLOSS 40
SET TARGET pPROFIT 120