The MarkovV4 strategy is a trading strategy that uses a Markov regression model to identify potential buying and selling opportunities. Here's a breakdown of how the strategy works:
The strategy uses the '30m' timeframe for trading. It reads historical price data from a JSON file, specifically for the BTC/USDT pair on the Binance exchange.
It calculates the logarithmic returns of the closing prices to analyze price movements.
It fits a Markov regression model with three regimes (states) to the recent returns data.
The strategy then populates various indicators based on the price data, such as the volume gap, daily change, fractal high, and fractal low. It prepares the endogenous variable (forecast variable) and exogenous variables (volume gap, daily change, fractal high, and fractal low) for the Markov regression model. It fits another Markov regression model with three regimes, using the prepared variables. The strategy calculates smoothed marginal probabilities for each regime (state) based on the fitted model. In the 'populate_buy_trend' method, the strategy identifies a buy signal when the probability of an upward regime is greater than 0.8, and the probabilities of the other two regimes are both less than 0.5. In the 'populate_sell_trend' method, the strategy identifies a sell signal when the probability of a downward regime is greater than 0.8, and the probabilities of the other two regimes are both less than 0.5. Overall, the MarkovV4 strategy uses a Markov regression model to capture different market regimes and generates buy and sell signals based on the probabilities associated with each regime.