The "heikin" strategy is a backtesting strategy that calculates various indicators and generates buy and sell signals based on specific conditions. Here is a breakdown of what the strategy does:
populate_indicators function:
Calculates the 'ohlc4' (average of open, high, low, and close prices), 'ohlc4-1' (previous 'ohlc4'), 'hlc3' (average of high, low, and close prices), and 'haOpen' (average of current and previous 'ohlc4') indicators. Calculates the 'haC' (average of 'ohlc4', 'haOpen', maximum of 'high' and 'haOpen', and minimum of 'low' and 'haOpen') indicator.
Calculates exponential moving averages ('ema1', 'ema2', 'ema3') and triple moving averages ('TMA1') based on 'haC'.
Calculates additional exponential moving averages ('ema4', 'ema5', 'ema6') and triple moving averages ('TMA2') based on 'TMA1'.
Calculates 'ipek' (difference between 'TMA1' and 'TMA2') and 'yasin' (difference between 'TMA1' and 'ipek') indicators. Calculates exponential moving averages ('ema7', 'ema8', 'ema9') and triple moving averages ('TMA3') based on 'hlc3'. Calculates additional exponential moving averages ('ema10', 'ema11', 'ema12') and triple moving averages ('TMA4') based on 'TMA3'. Calculates 'ipek1' (difference between 'TMA3' and 'TMA4') and 'yasin1' (difference between 'TMA3' and 'ipek1') indicators. Returns the updated DataFrame. populate_buy_trend function:
Generates a buy signal when the following conditions are met:
The current closing price crosses above the 'hma16' (Hull Moving Average calculated on 'ohlc4') indicator. 'yasin1' is greater than 'yasin' (current values compared to previous values). 'yasin1' of the previous time step is less than or equal to 'yasin' of the previous time step. Sets the 'buy' column to 1 for the corresponding buy signals. Returns the updated DataFrame. populate_sell_trend function:
Generates a sell signal when the following conditions are met:
'yasin1' is less than 'yasin' (current values compared to previous values). 'yasin1' of the previous time step is greater than or equal to 'yasin' of the previous time step. Sets the 'sell' column to 0 for the corresponding sell signals. Returns the updated DataFrame. Overall, the strategy calculates a range of indicators, including moving averages, and generates buy and sell signals based on specific conditions related to the indicators.