The GBA (Grid-Based Algorithm) strategy is an automated trading strategy implemented as a class in Python. It is designed to backtest and execute trading decisions based on certain market conditions. The strategy employs multiple indicators and conditions to determine when to enter and exit trades.
Here's a brief breakdown of its main components:
Indicators and Parameters:
The strategy uses various indicators to make trading decisions.
These indicators include moving averages (MA), linear regression channels (LRC), and other custom parameters like lengths and thresholds.
The values of these indicators and parameters are adjusted according to different trading pairs. Populating Indicators:
The strategy's populate_indicators function calculates and sets the indicator values based on the provided market data and metadata. The strategy adjusts these indicators differently for various trading pairs like LINK/USDT, XLM/USDT, ADA/USDT, and XMR/USDT. It sets parameters like length (iLen), grid count (iGrids), moving average type (iMA), LZ value (iLZ), ELSTX value (iELSTX), and GI value (iGI) based on the trading pair. Linear Regression Channels:
The strategy utilizes linear regression channels to determine potential price channels. It calculates upper and lower channel boundaries and adds these values to the dataframe. Populating Buy Trend:
The populate_buy_trend function identifies potential buy opportunities based on specific conditions. It marks the corresponding rows in the dataframe as potential buy signals when certain criteria are met. These criteria include checking for a buy (Buy_s) or sell (Sell_s) signal and ensuring that the trading volume is not zero. Populating Sell Trend:
The populate_sell_trend function is responsible for populating potential sell signals in the dataframe. The exact conditions for sell signals are not provided in the provided code snippet, but it can be assumed that they are determined based on specific market conditions. Interaction with 3Commas API:
The strategy interacts with the 3Commas API to manage active deals. It tracks open positions and decides whether to close deals based on the current market conditions and trading signals. It considers different factors, such as the type of bot (long or short) and the number of open positions relative to the specified pyramiding value (c3_pyramiding). Please note that the provided code snippet is not complete and lacks some parts of the logic, such as the conditions for populating sell signals, some interactions with the 3Commas API, and other potential parts of the strategy. This description offers a basic overview of the strategy's components and its interaction with indicators, buy/sell trends, and position management.