I have a new indicator, called DepthPriceCorrelation. It's not in the release yet, but it's in SVN http://code.google.com/p/jbooktrader/source/browse/trunk/source/com/jbooktrader/indicator/depth/DepthPriceCorrelation.java
The indicator is based on the idea that current price can be considered "fair" when the correlation between market depth balances and market prices is positive. This positive correlation occurs when: -- high depth balances are accompanied by higher prices or -- low depth balances are accompanied by lower prices When the correlation is negative, the prices are moving in the direction opposite from the direction of depth balances, and I call it a "high tension" condition. This is when my strategy gets into a position on the bet that the tension will ease and the correlation will return to its "normal" positive value. Here is an example of such a strategy: http://code.google.com/p/jbooktrader/source/browse/trunk/source/com/jbooktrader/strategy/TensionSeeker.java Now, to calculate the correlation, the indicator simply updates the running sums for prices and balances, and then uses a standard correlation coefficient formula to come up with the result. This is very efficient, and it works well. The problem is, sometime in the second half of the trading session, the indicator becomes too "stale", because it uses all the data accumulated so far during the trading session. So, at say, 2pm, the indicator would represent the correlation between balances and prices based on all the data from 9:30am to 2pm, while my strategy is looking for a shorter term correlation, such as the last 2 hours. It's certainly possible to recalculate the indicator based on this 2-hour moving window, but it would be very computationally expensive, since every time, I would need to loop through the last two hours of values, instead of simply updating the running sums. So, here is the question for the algorithmically inclined. How do I *efficiently* calculate the correlation between X and Y in a moving time window? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en -~----------~----~----~----~------~----~------~--~---
