-
Notifications
You must be signed in to change notification settings - Fork 252
Open
Description
I noticed that MACD Signal always repaints for the last two candles, forcing a lookahead bias in backtest. In live/dry run it would always show up as 0 or an extremely small value, making it useless.
Steps to reproduce:
- Use freqtrade or similar software
- Use a strategy with MACD Signal, such as: https://github.com/davidzr/freqtrade-strategies/blob/main/strategies/TheForce/TheForce.py
- Log the values, observe the following. MACD Signal is 0 for the past two candles.
2025-03-16 06:41:06,339 - TheForce5m - INFO - [DEBUG] NEAR/USDT:USDT - 2025-03-16 04:30:00+00:00 | Close: 2.64 | MACD: -0.0038208040952749656 | MACD Signal: -6.701088123062249e-06 | FastK: 62.06896551724162 | FastD: 67.56045052940304
2025-03-16 06:41:06,341 - TheForce5m - INFO - [DEBUG] NEAR/USDT:USDT - 2025-03-16 05:00:00+00:00 | Close: 2.655 | MACD: -0.0021882205918517528 | MACD Signal: 0.0003464176237795158 | FastK: 85.41666666666643 | FastD: 81.00651439338785
2025-03-16 06:41:06,343 - TheForce5m - INFO - [DEBUG] NEAR/USDT:USDT - 2025-03-16 05:30:00+00:00 | Close: 2.666 | MACD: -6.701088123062249e-06 | MACD Signal: 0.0 | FastK: 97.22222222222254 | FastD: 94.32473509437078
2025-03-16 06:41:06,345 - TheForce5m - INFO - [DEBUG] NEAR/USDT:USDT - 2025-03-16 06:00:00+00:00 | Close: 2.649 | MACD: 0.0003464176237795158 | MACD Signal: 0.0 | FastK: 50.00000000000062 | FastD: 62.961995384913024
Expected behaviour:
MACD Signal should be based on the historical data and should never be forward looking, creating a lookahead bias.