I don't want to discourage anyone. But the fact is that backtesting this system by any method (whether AmiBroker Backtesting or Manual Backtesting) gives very negative result.
Here is the AmiBroker Code.
It takes care of touching and separating of two EMAs rather than actual crossing. This is done in order to avoid any manual intervention about 'touching and separating'.
Also, I have added a filter so that it doesn't buy in overbought condition and doesn't short in oversold condition
One more thing :
I have also given the option of using 'ExpandLast' and 'ExpandFirst' for expanding Stochastic Oscillators from 30 minute TF to 5 minute TF. While backtesting you can use both option one by one and see the difference in result. But you can't trust the result shown with 'ExpandFirst' condition. This is because the stochastic in 30 min TF may change before the 30 min bar completes.
Backtest it and see the result yourself
Thanks Pride for sharing your system. I really admire you for that.
Thanks
----TIZ-----
Here is the AmiBroker Code.
It takes care of touching and separating of two EMAs rather than actual crossing. This is done in order to avoid any manual intervention about 'touching and separating'.
Also, I have added a filter so that it doesn't buy in overbought condition and doesn't short in oversold condition
_SECTION_BEGIN("Pride Stochastic Indicator");
SetChartBkColor(ParamColor("BackGround Color", colorblack));
periods = Param( "%K Periods", 8, 1, 20, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 4, 1, 20, 1 );
ST_StochK = StochK( periods , Ksmooth);
ST_StochD = StochD( periods , Ksmooth, DSmooth);
PlotST = ParamToggle("Plot ShortTerm Stochastics", "YES|NO", 0);
if (PlotST == 0) { //Plot(ST_StochK, "", colorLime, styleDashed);
Plot(ST_StochD, "ST StochD", IIf(ST_StochK > ST_StochD, colorGreen, colorRed), ParamStyle("ST Style", styleDots));
}
TimeFrameSet(6*Interval());
LT_StochK = StochK( periods , Ksmooth);
LT_StochD = StochD( periods , Ksmooth, DSmooth);
TimeFrameRestore();
expandString = ParamToggle("Expand Type", "Expand Last|Expand First", 0);
if (expandString == 0) {LT_StochK = TimeFrameExpand(LT_StochK, 6*Interval(), expandLast); LT_StochD = TimeFrameExpand(LT_StochD, 6*Interval(), expandLast); }
else {LT_StochK = TimeFrameExpand(LT_StochK, 6*Interval(), expandFirst); LT_StochD = TimeFrameExpand(LT_StochD, 6*Interval(), expandFirst); }
PlotLT = ParamToggle("Plot LongTerm Stochastics", "YES|NO", 0);
if (PlotLT == 0) { //Plot(LT_StochK, "", colorLime, styleDashed);
Plot(LT_StochD, "LT StochD", IIf(LT_StochK > LT_StochD, colorWhite, colorOrange), ParamStyle("LT Style", styleDots));
}
LTBullish = LT_StochK > LT_StochD; LTBearish = LT_StochK < LT_StochD;
STBullish = ST_StochK > ST_StochD; STBearish = ST_StochK < ST_StochD;
OverallBullish = LTBullish AND STBullish; OverallBearish = LTBearish AND STBearish;
EMA_Hist = (EMA(C, 5)- EMA(C, 13));
Plot(EMA_Hist, "Histogram", ParamColor("EMA Histogram Color", colorLightGrey), styleOwnScale|styleHistogram);
EMA_Buy = EMA_Hist > 0 AND Ref(EMA_Hist, -1) < 0; EMA_Short = EMA_Hist < 0 AND Ref(EMA_Hist, -1) > 0;
EMA_Buy_modified = Ref(EMA_Hist, -1) < 1 AND EMA_Hist > 1; EMA_Short_modified = Ref(EMA_Hist, -1) > -1 AND EMA_Hist < -1;
Buy = OverallBullish AND (EMA_Buy OR EMA_Buy_modified) AND ST_StochD < 70; Sell = STBullish == 0;
Short = OverallBearish AND (EMA_Short OR EMA_Short_modified) AND ST_StochD > 30; Cover = STBearish == 0;
Buy = ExRem(Buy, Sell); Sell = ExRem(Sell, Buy);
Short = ExRem(Short, Cover); Cover = ExRem(Cover, Short);
Buyshape = Buy * shapeUpArrow; SellShape = Sell * shapeDownArrow;
Shortshape = Short * shapeHollowDownArrow; CoverShape = Cover * shapeHollowUpArrow;
PlotShapes(BuyShape, colorLime, 0, ST_StochD); PlotShapes(SellShape, colorLime, 0, ST_StochD);
PlotShapes(ShortShape, colorOrange, 0, ST_StochD); PlotShapes(CoverShape, colorOrange, 0, ST_StochD);
Plot(80, "", ParamColor("80 Grid Color", colorLime));
Plot(20, "", ParamColor("20 Grid Color", colorLime));
_SECTION_END();
SetChartBkColor(ParamColor("BackGround Color", colorblack));
periods = Param( "%K Periods", 8, 1, 20, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 4, 1, 20, 1 );
ST_StochK = StochK( periods , Ksmooth);
ST_StochD = StochD( periods , Ksmooth, DSmooth);
PlotST = ParamToggle("Plot ShortTerm Stochastics", "YES|NO", 0);
if (PlotST == 0) { //Plot(ST_StochK, "", colorLime, styleDashed);
Plot(ST_StochD, "ST StochD", IIf(ST_StochK > ST_StochD, colorGreen, colorRed), ParamStyle("ST Style", styleDots));
}
TimeFrameSet(6*Interval());
LT_StochK = StochK( periods , Ksmooth);
LT_StochD = StochD( periods , Ksmooth, DSmooth);
TimeFrameRestore();
expandString = ParamToggle("Expand Type", "Expand Last|Expand First", 0);
if (expandString == 0) {LT_StochK = TimeFrameExpand(LT_StochK, 6*Interval(), expandLast); LT_StochD = TimeFrameExpand(LT_StochD, 6*Interval(), expandLast); }
else {LT_StochK = TimeFrameExpand(LT_StochK, 6*Interval(), expandFirst); LT_StochD = TimeFrameExpand(LT_StochD, 6*Interval(), expandFirst); }
PlotLT = ParamToggle("Plot LongTerm Stochastics", "YES|NO", 0);
if (PlotLT == 0) { //Plot(LT_StochK, "", colorLime, styleDashed);
Plot(LT_StochD, "LT StochD", IIf(LT_StochK > LT_StochD, colorWhite, colorOrange), ParamStyle("LT Style", styleDots));
}
LTBullish = LT_StochK > LT_StochD; LTBearish = LT_StochK < LT_StochD;
STBullish = ST_StochK > ST_StochD; STBearish = ST_StochK < ST_StochD;
OverallBullish = LTBullish AND STBullish; OverallBearish = LTBearish AND STBearish;
EMA_Hist = (EMA(C, 5)- EMA(C, 13));
Plot(EMA_Hist, "Histogram", ParamColor("EMA Histogram Color", colorLightGrey), styleOwnScale|styleHistogram);
EMA_Buy = EMA_Hist > 0 AND Ref(EMA_Hist, -1) < 0; EMA_Short = EMA_Hist < 0 AND Ref(EMA_Hist, -1) > 0;
EMA_Buy_modified = Ref(EMA_Hist, -1) < 1 AND EMA_Hist > 1; EMA_Short_modified = Ref(EMA_Hist, -1) > -1 AND EMA_Hist < -1;
Buy = OverallBullish AND (EMA_Buy OR EMA_Buy_modified) AND ST_StochD < 70; Sell = STBullish == 0;
Short = OverallBearish AND (EMA_Short OR EMA_Short_modified) AND ST_StochD > 30; Cover = STBearish == 0;
Buy = ExRem(Buy, Sell); Sell = ExRem(Sell, Buy);
Short = ExRem(Short, Cover); Cover = ExRem(Cover, Short);
Buyshape = Buy * shapeUpArrow; SellShape = Sell * shapeDownArrow;
Shortshape = Short * shapeHollowDownArrow; CoverShape = Cover * shapeHollowUpArrow;
PlotShapes(BuyShape, colorLime, 0, ST_StochD); PlotShapes(SellShape, colorLime, 0, ST_StochD);
PlotShapes(ShortShape, colorOrange, 0, ST_StochD); PlotShapes(CoverShape, colorOrange, 0, ST_StochD);
Plot(80, "", ParamColor("80 Grid Color", colorLime));
Plot(20, "", ParamColor("20 Grid Color", colorLime));
_SECTION_END();
I have also given the option of using 'ExpandLast' and 'ExpandFirst' for expanding Stochastic Oscillators from 30 minute TF to 5 minute TF. While backtesting you can use both option one by one and see the difference in result. But you can't trust the result shown with 'ExpandFirst' condition. This is because the stochastic in 30 min TF may change before the 30 min bar completes.
Backtest it and see the result yourself
Thanks Pride for sharing your system. I really admire you for that.
Thanks
----TIZ-----
Last edited: