Hello all, hope that you’re well.
I use the simplified creation ProOrder builder on PRT that I get with my IG Index account. I have a coded strategy that I’m happy with, BUT, only when the system doesn’t close your positions early if there’s a signal to take a position in the opposite direction.
I’ve deactivated position netting on IG, but all this does is force open of multiple positions, which I have combated using:
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
My question to the forum is simply, how do I prevent the strategy from closing my trade and taking the opposite direction if/when a new signal comes along? This strategy needs to give positions time to play out.
Here’s the code as it stands:
// Definition of code parameters
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 = 100000
timeEnterBefore = time >= noEntryBeforeTime
// Prevents the system from placing new orders to enter the market or increase position size after the specified time
noEntryAfterTime = 200000
timeEnterAfter = time < noEntryAfterTime
// Conditions to enter long positions
indicator1 = ExponentialAverage[200](close)
c1 = (close > indicator1)
indicator2 = MACDline[12,26,9](close)
indicator3 = ExponentialAverage[9](MACDline[12,26,9](close))
c2 = (indicator2 CROSSES OVER indicator3)
indicator4 = MACDline[12,26,9](close)
indicator5 = MACD[12,26,9](close)
c3 = (indicator4 < indicator5)
IF (c1 AND c2 AND c3) AND timeEnterBefore AND timeEnterAfter THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to enter short positions
indicator6 = ExponentialAverage[200](close)
c4 = (close < indicator6)
indicator7 = MACDline[12,26,9](close)
indicator8 = ExponentialAverage[9](MACDline[12,26,9](close))
c5 = (indicator7 CROSSES UNDER indicator8)
indicator9 = MACDline[12,26,9](close)
indicator10 = MACD[12,26,9](close)
c6 = (indicator9 > indicator10)
IF (c4 AND c5 AND c6) AND timeEnterBefore AND timeEnterAfter THEN
SELLSHORT 1 PERPOINT AT MARKET
ENDIF
// Stops and targets
SET STOP pLOSS 30
SET TARGET pPROFIT 45
(I use it on GBP/USD on the 5 min time frame)
I appreciate any help, thanks guys.
Matt