The Circles strategy is a trading strategy implemented in a backtesting website. It performs the following steps:
In the populate_indicators function:
It retrieves the current trading pair from the metadata. If the current pair is identified as a bull market or bear market, it gets an informative pair.
It fetches historical data for the informative pair in two different timeframes: inf_slow and inf_fast.
It calculates and adds several indicators to the main dataframe, such as VIDYA, KaufOSCI, SAR, and RMI.
It calculates additional columns based on the RMI indicator to determine upward and downward trends. In the populate_buy_trend function:
It initializes empty lists for short and long conditions and adds an empty column for the enter tag. If the current pair is identified as a bull market, it adds a condition for entering a long trade when the volume is greater than 0. If the current pair is identified as a bear market, it adds a condition for entering a short trade when the volume is greater than 0. If either long or short conditions exist, it updates the 'enter_long' column accordingly. Otherwise, it sets 'enter_long' to 0 for all rows where the close price is not null. In the populate_sell_trend function:
It initializes empty lists for short and long conditions and adds an empty column for the exit tag. If the current pair is identified as a bull market, it adds a condition for exiting a long trade. If the current pair is identified as a bear market, it adds a condition for exiting a short trade. If either short or long conditions exist, it updates the 'exit_long' column accordingly. Otherwise, it sets 'exit_long' to 0 for all rows where the close price is not null. The strategy also includes several helper functions that are not explicitly described in the provided code snippet. Overall, the Circles strategy calculates various indicators, identifies market conditions (bull or bear), and determines the conditions for entering and exiting trades based on volume and market type. The specific trading logic and profitability calculations are not fully described in the given code snippet.