Research Article
A Trend-Based Segmentation Method and the Support Vector Regression for Financial Time Series Forecasting
Algorithm 2
A pseudocode for trend segments by TBSM in time series.
Input: length, oldTs // input data length and vector. | Output: newTs // a new time series vector of trading signal. | Method: | 1: Start = oldTs 1 | 2: End = oldTs[length] | 3: If Start = = −1 and End = = 1 | 4: newTs 1 = 0 | 5: For i = 1: length−1 | 6: newTs[i+1] = 1/(lenghth−1)*i | 7: End For | 8: Else If Start = = 1 and End = = −1 | 9: newTs[length] = 0 | 10: For i = 1 : length−1 | 11: newTs[i+1] = 1/(lenghth−1)*(length−i) | 12: End For | 13: Else | 14: For i = 2 : length−1 | 15: newTs[i] = 0.5 | 16: End For | 17: End If |
|