1
$\begingroup$

The chart below is the 15-minute EURUSD from earlier today. The blue lines represent dividers between three subjective but reasonable segments that can easily be made out by the eye. I would characterize the three segments as:

  1. Low volatility (mostly) neutral/horizontal trend
  2. Higher volatility neutral or slight down trend
  3. Higher volatility linear up trend

enter image description here

I'm wondering if there are any existing algorithms or methods that could be used to identify dividing points between segments. By comparison, it's relatively straightforward to divide a chart into up and down swings given some minimum price increment but dividing based on multiple factors (trend and volatility in this case) seems more difficult. In theory, one could use any number of characteristics, including indicators. Something like comparing multiple moving averages would be easy, whereas determining where real-time volatility changes is not as easy (e.g., one large bar after a series of small might just be one outlier rather than a change in market dynamics).

I'm not necessarily concerned about being able to do this perfectly in real time. Again for something like volatility, it would likely take multiple bars to know that the dynamic has changed, but even being able to do this on historical data might be helpful in terms of backtesting different strategies.

Bounty Update: I've read about a number of different algorithms but can't seem to find one that will best capture what I'm looking for here. I think I could use a dynamic sliding window algorithm that uses spikes in Wasserstein distance that exceed a threshold, but I haven't seen anything that says that specifically. I'd really like to be able to do this over a year of minute data so calculation time is a factor.

There's so much scattered information about time series segmentation so I'm hoping someone can give some more direct advice.

$\endgroup$
  • $\begingroup$ I think you would need to start by thinking about specifc thresholds for what you consider as volatile and part of a trend for example. That way you lay the ground work for a potential ML classification task. $\endgroup$ – Hamish Gibson May 8 at 15:30
  • 2
    $\begingroup$ Hint: start playing with simple partitional clustering techniques, like K-means, applied to price according to some features among which there must be a time index. $\endgroup$ – Lisa Ann May 9 at 8:18
  • $\begingroup$ I’ve come across some K-means techniques but trying to get a grasp of which options are best. I didn’t realize how much information was out there about time series segmentation. Regarding the time index, wouldn’t this be very sensitive to my selection of K? If I understand your suggestion correctly, if K is too large, the algorithm might try to divide sections that are homogeneous to the naked eye or fail to divide heterogeneous sections if K is too small. The other issue is that a lot of these algorithms seem to be O(n^2) or worse, which could be problematic for minute data. $\endgroup$ – SuperCodeBrah May 9 at 8:34
  • $\begingroup$ Yes, you need some tuning process of K-means hyperparameters in order to solve the trade-off. But then, you'll probably switch to better clustering methods, like DBSCAN. $\endgroup$ – Lisa Ann May 13 at 9:00
0
$\begingroup$

Why not using a volatility indicator if volatility is the only factor? set 2 thresholds and you are done.

Separately recommend the read of a time series analysis or econometrics book, which will provide you with a deeper understanding.

| improve this answer | |
$\endgroup$
  • $\begingroup$ If I used a volatility indicator, I think I'd have to do some sort of averaging/smoothing, which means that rather than a hard cutoff, the indicator would slowly start to increase in times of increased volatility. I suppose I could find highs/lows in the indicator (similar to how I could segment by finding highs and lows in price), but this still presents an opportunity for inaccuracy due to the averaging effect. I'm not sure it's possible to achieve what I'm looking for without long calculation times to determine the segments. $\endgroup$ – SuperCodeBrah May 15 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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