Heinkin Ashi Tradescript required

Hi,

Can you please help me correct following code?

Go Long if : 

Heinkin Ashi Candle Closing EMA of 3 period is > simple moving average of 13 period closing and simple moving average of 34 period closing

Exit Long if :

Heinkin Ashi Candle Closing EMA of 3 period is < simple moving average of 13 period closing OR

Heinkin Ashi Candle Closing EMA of 3 period is < simple moving average of 34 period closing 

Further, I want to execute trade in only long trades. i.e. Long and Exit Long. No short trades. How is it possible with help of Expert Advisor?

Currently, I have coded this strategy like following:

Buy:

SMA((OPEN+CLOSE+HIGH+LOW)/4,3) > EMA(CLOSE,13) AND 
SMA((OPEN+CLOSE+HIGH+LOW)/4,3) > EMA(CLOSE,34)

Sell:

SMA((OPEN+CLOSE+HIGH+LOW)/4,3) < EMA(CLOSE,34)  OR 

SMA((OPEN+CLOSE+HIGH+LOW)/4,3) < EMA(CLOSE,13) 

However, trade script generates multiple orders for this. When I backtest above script for long only trades - it gives only 3-4 long trades in a day whereas alerts generated by EA are close to 60-65 trades in a single day. I can't understand why it behaves like this.

Further, is it possible to have a simulated run for certain period - i.e. live market simulation for particular period in Zerodha Pi? This could ease the testing phase. Similar feature is available in Amibroker where you can play / pause / stop and see kind of live testing post market (and office ;) ) hours.

Thanks & Regards,

Birju

In the backtest alerts comes as sell signal will follows with buy signal and vise-versa and it checks with historical data, In EA continues signals will get with live market once the pattern matches, so the number of signals may vary.

live market simulation or playback feature is not available in pi as of now.

give me code for following conditions:
buy =
period=1hour

crossover{sma(20,50,100,200);
period=30min

crossover{sma(20,50,100,200);

period=15 min

crossover{sma(20,50,100,200);