Fix what didn't port

Beginner 4 min

A ported indicator sometimes behaves differently from the original: on another timeframe, on another instrument or on live data.

Describe where it goes wrong, and the agent finds the cause, fixes the code and tests again. It works best in the same chat where the indicator was created.

Prompt
I switched the chart to 15 minutes, and the green highlight no longer matches the hourly EMA. Fix the indicator so the highlight is correct on any timeframe under an hour. Test on 5 and 15 minutes without saving, then save. Tell me what you changed and switch the chart back to 5 minutes.

Describe your own case the same way: where it happens, what should be there and what you got instead.

What happens

The agent found that the highlight was tied to 5 minutes, removed that dependency and tested the indicator on 5 and 15 minutes. It did not fully deliver on "any timeframe" and said why: on timeframes that don't divide the hour evenly, such as 7 minutes, the exact hourly EMA can't be rebuilt from the chart's bars.

Chat with the AI agent
You

I switched the chart to 15 minutes, and the green highlight no longer matches the hourly EMA. Fix the indicator so the highlight is correct on any timeframe under an hour. Test on 5 and 15 minutes without saving, then save. Tell me what you changed and switch the chart back to 5 minutes.

AI agent

I fixed and saved the indicator. The chart is back on BTCUSDT 5m.

  • Removed the fixed 5 minutes: the bar duration is now taken from the bar timestamps.
  • The hourly EMA updates on the last candle of the hour: 20:55 for 5m, 20:45 for 15m.
  • Both versions were tested without saving, with no calculation errors. Different history depth gives a small difference in the starting value of the EMA.

Limitation: an exact rebuild is possible for timeframes that divide the hour evenly. On 7m and similar timeframes a candle crosses the hour boundary, and an exact EMA needs separate lower-timeframe data. So the "any timeframe under an hour" requirement is not fully met yet.