how compute ema10 5min using intraday 1sec real time

Hi! I am creating own trading system. I have classic formula to compute ema (exponencial moving average) using last ema value if exists else use SMA (simple moving average) value. When ema10, ema20 - the number 10, 20 define value for multiplier.

i want create this strategy using c++:

If stock 5min 20 ema crosses above the 5min 50 ema....and if the call option 1min 10ema crosses the 1min option in alert window

I am getting intraday record for my stock/option every 1 second in cycle (or in another period when i need). I need to know how to compute for example 1min or 5min ema10 from my input data.

[Q1] if 1min ema10..than i need:
A) compute ema10 1 time per every 1 minute ? (using input to new ema value before 1min)
B) compute it in every iteration when data come (i get data every 1 sec) and then i need to store computed value 1 time per minute?

when starting to compute 1minute ema10 i need to compute simple moving average SMA from first x values[maybe10] and use SMA as first ema input. From this i conclude: i will get first ema10 1min after 10 x 1 minutes = 10minutes? I am creating short term trader and i think this is too long init time for ema10 1min. Is this correct computing process?

Thanks for helping me
Last edited:

Similar threads