Comment on Code your Technical Analysis strategy

Nithin Kamath commented on 26 Apr 2013, 10:33 AM


You are looking at MACD crossover, buy if MACD crossover, provided the RSI has moved from less than 30 to more than 30 and similarly sell if RSI has moved from above 70 to below 70.

For those of you who don’t understand MACD crossover and RSI, you can google for it. The thing is we are combining 2 strategies and we have to take a buy or sell only if both the strategies meet the conditions set.

@sebu, you have given me the MACD line which is 12 and 26, but you haven’t given me the signal line, so will take the default 9.


Buy Expression:

MACD(26,12,9,EXPONENTIAL)>MACDSIGNAL(26,12,9,EXPONENTIAL) AND RSI(Close,10)>30 AND REF(RSI(Close,10), 1)<30

Buy exit: 0

Sell Expression:


Sell exit: 0

The above is actually pretty simple if you look at it. The new thing which is used here is the ” AND” expression. You can use all boolean logic like AND, NOT, OR etc. In this case AND because you want a buy/sell indicator only if all the conditions are met.

Have explained about REF in the previous example, in the case of buy, you want to buy only if RSI was below 30 the previous candle and it is above 30 at the close of this candle. Do check out the REF example above, should clarify .


View the full comment thread »