Comment on Code your Technical Analysis strategy

Nithin Kamath commented on 25 Apr 2013, 12:43 PM

14 EMA crossover will give a lot of buy/sell and you might get chopped when markets are flat.

RSI(Relative Strength Index) as investopedia explains is a technical momentum indicator that compare the magnitude of recent gains to recent losses in an attempt to determine overbought and oversold conditions of an asset. In simple words, RSI ranges from 0 to 100 and typically if the value is more than 70 it is said to be overbought and if lesser than 30 oversold. So according to RSI, it is not a good time to buy if above 70 or to short if below 30.

So what Dip wants to do is, he wants to buy when 14 EMA is crossing over only if RSI is below 40, the RSI condition acts like a secondary condition to filter trades by taking on those crossovers where the contract is close to oversold, but definitely not overbought.

Similarly he wants to sell on a crossover only if RSI above 60, close to being overbought but definitely not oversold.

This additional logic is a good filter to have for someone starting off on technical analysis. The number 40 or 60, you have to decide based on backtesting.

RSI again has a time period to it which Dip has forgot to mention, but since we are looking at 14 EMA, will assume he meant a 14 candle RSI.

For the above example:

Your buy expression would be: Close>EMA(Close,14) AND RSI(Close,14)<40

Your sell expression would be : Close < EMA(Close,14) AND RSI(Close,14) > 60

Your buy exit expression: 0

Your sell exit expression: 0

Basically when you mention a 0 on the buy/sell exit expression, your exit for the buy would be your sell expression and vice versa.

So for example, if your preset order size is 1 lot, if your buy expression gives you a prompt, you buy 1 lot and when the sell expression comes, you sell the 1 lot you are holding and take a fresh selling 1 lot.

You can follow the steps in this blog to save this expression, backtest and take live.

Backtest result for the last 22 days intraday on 1 min candles:

1st trade Short at 5610 , buy at 5509 profit of 101 points.

2nd trade Short at 5629, if you had put a 50 point SL, loss of 50 points.

Net profit of around 50 points, but do note that strategies like these which work on moving averages can be choppy in flat markets.

Hope this helps,

Cheers,

View the full comment thread »