Comment on Code your Technical Analysis strategy

Nithin Kamath commented on 30 Apr 2013, 01:41 PM

Dr Suhas had asked this query:

Dear Sir/Madam,
I want to write strategy, but I am not able to fit my startegy in this algo. Anybody please let me know how to write this.
1) I want to buy when closing of the candle is higher than highes of previous 9 candles & sell when closing of candle is lower than lows of previous 9 candles. This will be in hourly TF.
2) Secondly buy will be only when the trend is uptrend confirmed by cross-over of 8 & 34 EMA in hourly TF. Sell will be vice-versa.
3) In this system , exit from buy will be when candle closes below the lows of previous 9 candles with closing price below 8 EMA and exit from sell will be when candle closes above highes of previous 9 candles with closing price below 8 EMA.
Please let me know how to write this strategy?

Answer:

Buy expression: CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND EMA(CLOSE,8) > EMA (CLOSE,34)

Sell expression: CLOSE MINOF(MIN(LOW,8), REF(LOW,9)) AND EMA (CLOSE,8) < EMA (CLOSE,34)

Buy Exit: CLOSE < MINOF(MIN(LOW,8), REF(LOW,9))AND CLOSE < EMA (CLOSE,8)

Sell Exit:CLOSE > MAXOF(MAX(HIGH,8), REF(HIGH,9)) AND CLOSE > EMA (CLOSE,8)

View the full comment thread »