Can you code this heikin-ashi strategy

I would need a code for simple strategy as below, can you kindly
provide the same.
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.​

2 Likes

Buy:


SET HC = (OPEN+HIGH+LOW+CLOSE)/4
SET HO = (REF(OPEN,1) + REF(CLOSE,1))/2
SET HH = MAXOF(HIGH, MAXOF(HC, HO))
SET HW = MINOF(LOW, HO, HC)
HC>MAXOF(REF(HH,1),REF(HH,2),REF(HH,3), REF(HH,4))  Sell:SET HC = (OPEN+HIGH+LOW+CLOSE)/4
SET HO = (REF(OPEN,1) + REF(CLOSE,1))/2
SET HH = MAXOF(HIGH, MAXOF(HC, HO))
SET HW = MINOF(LOW, HO, HC)
HC<MAXOF(REF(HH,1),REF(HH,2),REF(HH,3), REF(HH,4)) 
3 Likes

Dear Sir,

The code for HO is not correct. 

SET HO is 

(REF(HO,1) + REF(HC,1))/2 instead of your suggestion:
(REF(OPEN,1) + REF(CLOSE,1))/2

As we are Setting HO now, how can we make it refer to another HO on the RHS?

Could you please suggest the code again?

Thanks.

Hi,
I tried to use this script as a scanner, but, it gives “Your script generated an error”. Am I using this correctly? Can you please advise?
Thanks
Sachin