Heiken Ashi scalping

 
Hi,

I am working on a scalping strategy using the Heiken Ashi Indicator. The rules are the following :

- check that historic volume and historic ATR are positive
- if Heiken Ashi reverse (bulish candle to bearish candle) and if we are under the daily pivot (or 10 pip above) then we enter a short (same thing for a long position (bearish candle to bullish candle and above the daily pivot)
-TP and SL are give by the ATR (period = 20)

I have written the code, but I would like to improve it.
First, I do not understand why it is so slow when I try a backtest,, If somebody has an idea or a reference, please do not hesitate

Second point, I would like to open 2 orders one "classic" with fix TP and SL. The other one with a trailing stop, more specially with a stop which will move to breakeven when the TP is reached and then the stop moves as a trailing stop.

I am a newbie. And I only did the code for fix TP and SL. If somebody, can give me a reference to build this trailing stop, it would be great. So far I do not get it how to code this trailing stop and more important I do not know why this code is so slow for backtesting.

Here is the code.

Any comments are welcome. Thanks by advance

PS : I use a smooth version of the Heiken Ashi develop by mister Ed
Files:
hatrend.mq4  7 kb
 
please attach indicators are necessary for the expert
 
NEKSUS_:
please attach indicators are necessary for the expert

That:s right, I forgot the indicators.

Files: