kanwal
1
Hi,
I want a simple strategy:
BUY== 1) price closes above 20 SMA (Low) and 20 SMA ( High) band , 2) Price is above 34 sma
SELL == 1) Price closes below 20 SMA (low) and 20 SMA (high ) band , 2) Price is below 34 SMA
The position should automatically reverse and a new trade should begin when these conditions are met.
How can I backtest this strategy on Index and stocks for last 2-3 years?
Regards
_SECTION_BEGIN("SMA_based_trading");
x = MA(High,20);
y = MA(low,20);
z = MA(Close,34);
Plot(x,"",colorBrightGreen, styleLine, styleThick);
Plot(y,"",colorRed, styleLine, styleThick);
Plot(z,"",colorGreen, styleLine, styleThick);
GraphXSpace=0.5;
Plot(C,"",colorBlue,styleCandle);
Buy = (Close > x) AND (Close > y) AND (Close > z);
Sell = (Close < x) AND (Close < y) AND (Close < z);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
PlotShapes(shapeUpArrow*Buy,colorGreen, 0, L, Offset=-45);
PlotShapes(shapeSmallDownTriangle*Sell,colorred, 0, L, Offset=-45);
_SECTION_END();
Regards
Vivith
www.neotradeanalytics.com