Need Codes for Heikin Ashi Close and EMA

Hi

I request help in coding my trade strategy. which has following steps.

  1. Use heikin Ashi Charts.
  2. Order should be only for Intraday (MIS)
  3. Leave First Candle as base, than start Buy if the Candle is green Plus HA-Close should be higher than 5 period EMA and sell if Candle is Red Plus HA-Close should be lower than 5 period EMA . (with one lot)
  4. Continue on trade until color change in other direction
  5. Second and there after all trade should be 2x of initial lot, so that every opposite keep trade live.
  6. Close all open the trades at 3.20pm.

As per the above condition

Buy script:

SET HC = (OPEN+HIGH+LOW+CLOSE)/4
SET HO = (REF(OPEN,1) + REF(CLOSE,1))/2
HO>HC AND HC > EMA(CLOSE,5)

Sell Script:

SET HC = (OPEN+HIGH+LOW+CLOSE)/4
SET HO = (REF(OPEN,1) + REF(CLOSE,1))/2
HO<HC AND HC < EMA(CLOSE,5)

Script showing error when run