Finally the last strategy, Strategy #3 of group 3, along with the 3 indicators:
//-------------------------------------------------------------------------
// Klinger-Rvi-Lsma DAX 5 min
//-------------------------------------------------------------------------
DEFPARAM CumulateOrders = False
DEFPARAM FlatBefore = 090000 //no trades before 09:00:00
DEFPARAM FlatAfter = 213000 //no trades after 21:30:00
ONCE nLots = 1 //number of LOTs traded
ONCE TP = 23 //23 pips Take Profit
ONCE SL = 16 //16 pips Stop Loss
RviVal, RviSignal = CALL "RVI by John Ehlers"[7] //7
KlingerVal, KlingerTrigger = CALL "Klinger oscillator"[25,44,55,1] //25,44,55,1 (ema)
LeastSquareEMA = CALL "ELSMA - Least Square EMA"[11,4] //11,4
//***************************************************************************************
IF LongOnMarket THEN
IF close < LeastSquareEMA THEN
SELL AT MARKET //Exit LONGs when MACD reverses southwards
ENDIF
ENDIF
IF ShortOnMarket THEN
IF close > LeastSquareEMA THEN
EXITSHORT AT MARKET //Exit SHORTs when MACD reverses northwards
ENDIF
ENDIF
//***************************************************************************************
trailingstart = 10 //10 trailing will start @trailinstart points profit
trailingstep = 13 //13 trailing step to move the "stoploss"
//reset the stoploss value
IF NOT ONMARKET THEN
newSL=0
ENDIF
//manage long positions
IF LONGONMARKET THEN
//first move (breakeven)
IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
newSL = tradeprice(1)+trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
newSL = newSL+trailingstep*pipsize
ENDIF
ENDIF
//manage short positions
IF SHORTONMARKET THEN
//first move (breakeven)
IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
newSL = tradeprice(1)-trailingstep*pipsize
ENDIF
//next moves
IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
newSL = newSL-trailingstep*pipsize
ENDIF
ENDIF
//stop order to exit the positions
IF newSL>0 THEN
SELL AT newSL STOP
EXITSHORT AT newSL STOP
ENDIF
//***************************************************************************************
// LONG trades
//***************************************************************************************
a1 = close > open //BULLish bar
a2 = KlingerTrigger CROSSES OVER KlingerVal //Klinger trigger is going north
a3 = RviSignal CROSSES OVER RviVal //RVI long signal occurred
IF a1 AND a2 AND a3 THEN
BUY nLots CONTRACT AT MARKET
ENDIF
//***************************************************************************************
// SHORT trades
//***************************************************************************************
b1 = close < open //BEARish bar
b2 = KlingerTrigger CROSSES UNDER KlingerVal //Klinger trigger is going south
b3 = RviSignal CROSSES UNDER RviVal //RVI short signal occurred
IF b1 AND b2 AND b3 THEN
SELLSHORT nLots CONTRACT AT MARKET
ENDIF
//
SET TARGET PPROFIT TP
SET STOP PLOSS SL
ElSMA indicator:
//-------------------------------------------------//
// ELSMA - Exponential Least Square Moving Average //
//-------------------------------------------------//
DEFPARAM CalculateOnLastBars = 200
Period = MAX(Period, 1)
if NumBars < 1 then
NumBars = 4
endif
LR = LinearRegression[NumBars](close)
AFR = ExponentialAverage[Period](LR)
RETURN AFR
RVI indicator:
// Relative Vigor Index (RVI) by John Ehlers
// Paramètres:
// Per = periods for summation (12 as défault)
DEFPARAM CalculateOnLastBars = 200
diff = close - open
ind1 = (diff + 2*diff[1] + 2*diff[2] + diff[3]) / 6
ind2 = (Range + 2*Range[1] + 2*Range[2] + Range[3]) / 6
cond = Summation[per](ind2)
IF cond = 0 THEN
temp = 0.0001
ELSE
temp = cond
ENDIF
RVI = Summation[per](ind1) / temp
RVIsig = (RVI + 2*RVI[1] + 2*RVI[2] + RVI[3]) / 6
RETURN RVI COLOURED (255, 0, 0) AS"Relative Vigor Index", RVIsig COLOURED (0, 0, 255) AS"Relative Vigor Index Signal"
KLINGER oscillator:
// KLINGER oscillator
// variable AVGTYPE can hold values:
//
// 0 = SMA
// 1 = EMA
// 2 = WMA
// 3 = Wilder MA
// 4 = Triangular MA
// 5 = End point MA
// 6 = Time series MA
//------------------------------------------------
DEFPARAM CalculateOnLastBars = 200
hlc3= (high + low + close)/3
if(hlc3>hlc3[1]) THEN
xTrend = volume * 100
ELSE
xTrend = -volume * 100
ENDIF
if (AvgType < 0) OR (AvgType > 6) then //default to ONE if parameter is
AvgType = 1 // out of range 0-6
endif
xFast = average[FastX,AvgType](xTrend)
xSlow = average[SlowX,AvgType](xTrend)
xKvO = xFast-xSlow
xTrigger = average[TrigLen,AvgType](xKvO)
RETURN xKvO AS "Klinger oscillator", xTrigger AS "trigger"
This strategy is not performing like the first two in the group.
Any suggestion for improvements is highly welcome!