DEFPARAM CumulateOrders = False
DEFPARAM FLATBEFORE = 144500
DEFPARAM FLATAFTER = 225500
timeframe(35 minutes,updateonclose)
noEntryBeforeTime = 144500
timeEnterBefore = time >= noEntryBeforeTime
noEntryAfterTime = 222000
timeEnterAfter = time < noEntryAfterTime
if timeEnterAfter then
A= 5
V =7
iMACD = MACD[11,26,9](close)
DonchianSupA = highest[A](high)
DonchianInfA = lowest[A](low)
DonchianSupV = highest[V](high)
DonchianInfV = lowest[V](low)
iRSI= RSI[4](close)
ca1 = iMACD > iMACD[1]
ca2 = iMACD >= -0.4
ca3 = close crosses over DonchianSupA[1]
ca4 = iRSI > 63
c1= ca1 AND ca2 AND ca3 and ca4
IF c1 THEN
buy 0.25 lot at market
SET STOP PLOSS 8.8
ENDIF
cv1 = iMACD < iMACD[1]
cv2 = iMACD <= -1
cv3 = close crosses under DonchianInfV[1]
cv4 = iRSI < 30
c2 = cv1 AND cv2 AND cv3 and cv4
if c2 then
SELLSHORT 0.25 LOT AT MARKET
SET STOP PLOSS 10
endif
timeframe(5 minutes)
trailingstart = 5
trailingstep = 3
IF NOT ONMARKET THEN
newSL=0
ENDIF
IF LONGONMARKET THEN
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
IF SHORTONMARKET THEN
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF