Maxim, tell us more about how you cluster the price trajectory of a currency pair by the asymmetry coefficient.
It is calculated in a sliding window as a trait and added to the dataset. Clustering is performed according to this feature, cluster labels are assigned to the whole dataset. Then the rows that belong to one of the clusters are selected. Prices and all other attributes remain there. That's all.
Probably, throwing some vertices out of the ZZ-row would have the same effect.
import pandas as pd
from scipy.signal import find_peaks
@njit
def calculate_labels_zigzag(peaks, troughs, len_close):
"""
Generates labels based on the occurrence of peaks and troughs in the data.
Args:
peaks (np.array): Indices of the peaks in the data.
troughs (np.array): Indices of the troughs in the data.
len_close (int): The length of the close prices.
Returns:
np.array: An array of labels.
"""
labels = np.empty(len_close, dtype=np.float64)
labels.fill(2.0) # Initialise all labels to 2.0 (no signal)for i inrange(len_close):
if i in peaks:
labels[i] = 1.0# Sell signal at peakselif i in troughs:
labels[i] = 0.0# Buy signal at troughsreturn labels
def get_labels_filter_ZZ(dataset, peak_prominence=0.1) -> pd.DataFrame:
"""
Generates labels for a financial dataset based on zigzag peaks and troughs.
This function identifies peaks and troughs in the closing prices using the 'find_peaks'
function from scipy.signal. It generates buy signals at troughs and sell signals at peaks.
Args:
dataset (pd.DataFrame): DataFrame containing financial data with a 'close' column.
peak_prominence (float, optional): Minimum prominence of peaks and troughs,
used to filter out insignificant fluctuations.
Defaults to 0.1.
Returns:
pd.DataFrame: The original DataFrame with a new 'labels' column and filtered rows:
- 'labels' column:
- 0: Buy
- 1: Sell
- Rows where 'labels' is 2 (no signal) are removed.
- Rows with missing values (NaN) are removed.
"""# Find peaks and troughs in the closing prices
peaks, _ = find_peaks(dataset['close'], prominence=peak_prominence)
troughs, _ = find_peaks(-dataset['close'], prominence=peak_prominence)
# Calculate buy/sell labels using the new zigzag-based labelling function
labels = calculate_labels_zigzag(peaks, troughs, len(dataset))
# Add the calculated labels as a new 'labels' column to the DataFrame
dataset['labels'] = labels
# Remove rows where the 'labels' column has a value of 2.0 (no signal)
dataset = dataset.drop(dataset[dataset.labels == 2.0].index)
# Return the modified DataFrame return dataset
Evgeni Gavrilovi #: Of course, it would be possible to add drawdowns, because the smooth lines are confusing, I feel that there the drain was up to -80% or even more).
I don't accept any suggestions for improvement of the article, only discussion of the existing/questions.
Window# instances are returned by calls: and . instances are returned by calls: and . instances are returned by calls: and . Rolling window functions# Weighted window functions# Expanding window functions# Exponentially-weighted window functions...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
It is calculated in a sliding window as a trait and added to the dataset. Clustering is performed according to this feature, cluster labels are assigned to the whole dataset. Then the rows that belong to one of the clusters are selected. Prices and all other attributes remain there. That's all.
Why not ZZ then?
However, I found a small explanation.
Probably, throwing some vertices out of the ZZ-row would have the same effect.You can add this code to the deal markup library yourself.
It got worse.
It got worse.
Is it possible to combine models in MT5? Let's say I selected top 20, therefore 40 onnx files appeared. What should I do in this case?
Is it possible to combine models in MT5? Let's say I selected top 20, therefore 40 onnx files appeared. What should I do in this case?
Of course, it would be possible to add drawdowns, because the smooth lines are confusing, I feel that there the drain was up to -80% or even more).
Added all the basic attributes from the pandas module.
https://pandas.pydata.org/docs/reference/window.html
As a result, I got this graph. Maxim, thank you for your labour.