Hi,
Sorry for many questions in the beginning. Very thankfull for all the help I¨ve gotten.
Is there a cleaver way to calculate an average of multiple timeseries.
adding them together and dividing by how many I've added doesnt give the best result as I have quite a few datagaps.
var finalRatio = (BINANCE_RATIO + BYBIT_RATIO_USDT + KRAKEN_RATIO + BITMEX_RATIO)/4;
Or do I have to loop through all .Values and do the averaging that way?
Another question is if I can limit max/min values in a timeseries.
Eg, I want all values in my timeseries that are > 100, to be changed to 100.
Sorry for many questions in the beginning. Very thankfull for all the help I¨ve gotten.
Is there a cleaver way to calculate an average of multiple timeseries.
adding them together and dividing by how many I've added doesnt give the best result as I have quite a few datagaps.
var finalRatio = (BINANCE_RATIO + BYBIT_RATIO_USDT + KRAKEN_RATIO + BITMEX_RATIO)/4;
Or do I have to loop through all .Values and do the averaging that way?
Another question is if I can limit max/min values in a timeseries.
Eg, I want all values in my timeseries that are > 100, to be changed to 100.
Rename
Your finalRatio equation is fine, but you must Synchonize() all the TimeSeries (or Indicators) first.
Where there gaps, Synchonize() will use the last known value.
Where there gaps, Synchonize() will use the last known value.
QUOTE:
if I can limit max/min values in a timeseries.
Eg, I want all values in my timeseries that are > 100, to be changed to 100.
To do exactly that, you're going to have to loop through all the .Value's, but a better way to compression-limit the outliers would be to run them through the InverseFisher indicator. It uses a sigmoidal transfer function so there aren't any sharp cutoffs creating artifacts. Take a look at John Ehlers' paper. https://www.mesasoftware.com/papers/TheInverseFisherTransform.pdf
Of course, you should perform the synchronization discussed in Post #1 first, then linearly scale the values between +/- 1, and then call the InverseFisher indicator on each scaled time series to trim all the outliers. Finally, you can average them together.
On the +/- 1 scaling step, I would keep it simple.
scaledTimeSeries = unscaledTimeSeries / maxValueInTimeSeries;
Since I looked again and assuming all these variables are TimeSeries with the class scope, this should be done once in Initialize.
CODE:
BINANCE_RATIO = TimeSeriesSynchronizer.Synchronize(BINANCE_RATIO, bars); BYBIT_RATIO_USDT = TimeSeriesSynchronizer.Synchronize(BYBIT_RATIO_USDT, bars); KRAKEN_RATIO = TimeSeriesSynchronizer.Synchronize(KRAKEN_RATIO, bars); BITMEX_RATIO = TimeSeriesSynchronizer.Synchronize(BITMEX_RATIO, bars); var finalRatio = (BINANCE_RATIO + BYBIT_RATIO_USDT + KRAKEN_RATIO + BITMEX_RATIO)/4; for (int n = 0; n < finalRatio.Count; n++) { if (finalRatio[n] > 100) finalRatio[n] = 100; }
Your Response
Post
Edit Post
Login is required