Comment on Code your Technical Analysis strategy

Nithin Kamath commented on 26 Apr 2013, 04:51 PM

Pradeeep TV asked:

Basically i want to use heikin-ashi charts, so my close, open, low and
high are specified below —

HA-Close = (Open(0) + High(0) + Low(0) + Close(0)) / 4

HA-Open = (HA-Open(-1) + HA-Close(-1)) / 2

HA-High = Maximum of the High(0), HA-Open(0) or HA-Close(0)

HA-Low = Minimum of the Low(0), HA-Open(0) or HA-Close(0)

Buy —> If the close goes above highest close of last 4 candles then buy.

Sell —> If the close goes below lowest close of last 4 candles then sell

Answer:

For all those who don’t know Heiken-Ashi is a type of candle stick chart with the difference being in the following parameters.

Close = (Open+High+Low+Close)/4
Open = [Open (previous bar) + Close (previous bar)]/2
High = Max (High,Open,Close)
Low = Min (Low,Open, Close)

Your condition is the below to buy/sell, which is based only on the close, so you really don’t need to worry about open, high, low.
Buy —> If the close goes above highest close of last 4 candles then buy.
Sell —> If the close goes below lowest close of last 4 candles then sell

The below should be self explanatory.

Buy expression:

SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC>MAXOF(REF(HAC,1), REF(HAC,2), REF(HAC,3), REF(HAC,4))

Buy exit: 0

Sell expression:

SET HAC = (OPEN+HIGH+LOW+CLOSE)/4
HAC < MINOF(REF(HAC,1), REF(HAC,2), REF (HAC,3), REF (HAC,4))

Sell exit: 0

You can check out the example above where I have mentioned the use of REF function. REF basically takes reference of the candle, so REF(HAC,1) would mean HAC for 1 candle before, REF(HAC,2) 2 candles before and so on.

View the full comment thread »