Serious degrade in speed when adopted the program to EMA graph

I have been developing AFL applications to autotrade. One program I have written is to use macd crossover to trigger trades. This program continuously netvigate the candles sticks to plot buy/sell signals based on the program logic.

Recently, I try to adopt the same program into EMA graphs. However, I found that when I apply the same logic onto ema graphs, the performance of the whole program deteriorate seriously.

I found that each redraw of the indicators requires more then 1 min (instead of nearly instantly).

Anyone has any hints to me?

@roger without seeing any of the code you are using is difficult to understand what's going on.

If you would like to see further help from other forum members, it is always better to post a relevant AFL code snippet.

Anyway, in your formula, do you use the standard AmiBroker's Macd() and Ema() functions or you wrote your own variations?

And, above all, are you using ANY LOOP over individual bars (accessing the single array elements with the square brackets []?

In general, formulas speed decrease significantly if you loop individually over a huge number of bars doing complex calculations and/or repeatedly call plots (or interact with some other not officially supported plugins) in nested loops. But the slow down reason may also be elsewhere....

This documentation chapter will give you few hints on how to make the program perform as it was originally designed to: Performance tuning tips

As @beppe wrote - your formula is a sole reason of your problems. Send the formula and then anybody can point you the error you are making. If you get slow down from adding EMA it means that you placed it in wrong place (for example inside a loop, while array functions should be outside the loop) so you are calling the same function (loop invariant code) over and over without any sense