0

I'm writing a bot that acts on market signals - currently just based on exponential moving averages. At the moment, I have the program watching the market on multiple different period lengths. For example, it will grab the last price right now, calculate and log a moving average if there is enough data, and then 60 minutes from now do the same. It can be doing this for 5min, 15min, 30min, 2h, 4h, etc. etc. time periods.

However, If I have an algorithm making decisions every 60 minutes, It could very easily lose a lot of money in between the two calculations. My thought is that I should be grabbing market data and calculating values every 1 or 2 minutes, and base those calculations on data from period_length time ago. It still obviously charts a 60 min or 2h or w/e chart, but does so every 1 min in order to react as fast as possibly to changes.

Is this the correct approach, or am I way off on this?

2 Answers 2

1

The normal approach is as you suggest, to update the average regularly - that's pretty much the definition of a moving average. For example Bollinger Bands are a similar metric and use a moving average which is continually updated. A true moving average would be updated with every trade made but it makes sense to break it down into periods of 30 seconds or a minute.

1
  • Thanks, that's informative. How I wrote it to work, is it fetches a new price every 60 seconds. If it is trying to calculate a 5 minute period EMA, it will create a calculation with a "period index", starting from 0 and counting up until it reaches 4. The EMA calculator will always use the data from the same period index, but it can be calculated every 60 seconds once there is enough historical data.
    – Andy Bas
    Jan 1, 2014 at 23:01
0

For any Moving average calculation you have to start with tick by tick calculation, then 1 minute ,then 5 minutes,30 minutes, 1 hr, 4 hrs ,daily, weekly and monthly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.