//XAUDUSD(EUR1 Contract) - IG MARKET
// TIME FRAME 1H
// PROBACKTEST TICK by TICK - 100.000 bars
// SPREAD 0.5 PIP
DEFPARAM CumulateOrders = FALSE
DEFPARAM Preloadbars = 200
tradingtime = (currenttime >= 030000 and currenttime <= 180000)
CP1 = 4
CP2 = 4
shorttrend = supertrend[4,10]
longtrend = supertrend[7,24]
// INDICATORS
///FRACTAL INDICATOR
if close[cp1] >= highest[2*cp1+1](close) then
LH = 1
else
LH=0
endif
if close[cp2] <= lowest[2*cp2+1](close) then
LL= -1
else
LL=0
endif
if LH=1 then
HIL = close[cp1]
endif
if LL = -1 then
LOL=close[cp2]
endif
// ENTRY CONDITIONS
C1 = not longonmarket
C1 = C1 and (close crosses over LOL)
C1 = C1 and tradingtime
C1 = C1 and close > longtrend
// ENTRY CONDITIONS
S1 = not shortonmarket
S1 = S1 and (close crosses under HIL)
S1 = S1 and tradingtime
S1 = S1 and close < shorttrend
//ENTRY LONG
IF C1 THEN
BUY 10 CONTRACT AT MARKET
ENDIF
// ENTRY SHORT
IF S1 THEN
SELLSHORT 10 CONTRACT AT MARKET
ENDIF
// Exit Long
If longonmarket and close > HIL then
sell at market
endif
// Exit Short
If shortonmarket and close < LOL then
exitshort at market
endif
//trailing stop
trailingstop = 4
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
// stoploss
Set stop ploss 80