This strategy works on several markets but in this example I focused on gold.
The strategy is based on the Internal Bar Strength Indicator (IBS=(Close – Low) / (High – Low) * 100), and by using this indicator I’ve made a mean reversion strategy which basically gives you a high win rate thanks to a large stop loss distance. To find out if this is good or bad you need to do some further testing.
Anyhow, the main rule is as follow:
Apart from the main rule, I have also added some extra stuff to boost the performance of this backtest. You can optimise all of this in the top section.
Enjoy!
//////////////////////////////////////////////////////////////////
//// Sport Gold (E1 Contract) Spread 0.5
//////////////////////////////////////////////////////////////////
DEFPARAM CumulateOrders = False
DEFPARAM PreloadBars = 200
//////////////////////////////////////////////////////////////////
//// Opti
//////////////////////////////////////////////////////////////////
longtrigger = 9
shorttrigger = 91
maperiod = 100
maPeriod1 = 20 // Moving Average Period 100
maType1 = 2 // Moving Average function
stoplossmulti = 8
possize = 10
//////////////////////////////////////////////////////////////////
//// Indicators
//////////////////////////////////////////////////////////////////
IBS = (Close - Low) / (High - Low) * 100
ma = average[maperiod](close)
ma1 = average[maPeriod1, maType1](customClose)
slope1 = ma1 - ma1[1]
//////////////////////////////////////////////////////////////////
//// Entry conditions
//////////////////////////////////////////////////////////////////
b1 = not longonmarket // only open 1 position
b1 = b1 and close < Dhigh(1) // close below yesterday's high
b1 = b1 and IBS < longtrigger // Internal bar strength below trigger value
b1 = b1 and close > ma // close over moving average
b1 = b1 and slope1 > 0 // ma slope is positive
s1 = not shortonmarket // only open 1 position
s1 = s1 and close > Dlow(1) // close above yesterday's low
s1 = s1 and IBS > shorttrigger // Internal bar strength below trigger value
s1 = s1 and close < ma // close over moving average
s1 = s1 and slope1 < 0 // ma slope is negative
//////////////////////////////////////////////////////////////////
//// Exit conditions Short
//////////////////////////////////////////////////////////////////
el1 = close > Dhigh(1) // close above yesterday's high
es1 = close < Dlow(1) // close below yesterday's low
//////////////////////////////////////////////////////////////////
//// Execution
//////////////////////////////////////////////////////////////////
if b1 then
buy possize contract at market
endif
if s1 then
sellshort possize contract at market
endif
if el1 then
sell at market
endif
if es1 then
exitshort at market
endif
//////////////////////////////////////////////////////////////////
//// Stop loss
//////////////////////////////////////////////////////////////////
set stop ploss (averagetruerange[14] * stoplossmulti)*pointsize