---
title: "Comment by Arnold Holm on \"From TradingView Strategy to MT5 Expert Advisor: A Developer's Checklist\" | Hashnode"
description: "The new-bar helper also needs a startup rule. With lastBar initially zero, the first tick after a restart counts as a new bar even if that candle began earlier."
url: "https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954/comment/6ac9e7979712736ed962af4a"
---

[Discussion](https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954)

Comment [From TradingView Strategy to MT5 Expert Advisor: A Developer's Checklist](https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954)

[Arnold Holm](https://hashnode.com/@stratcorealpha)

[Oct 10](https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954/comment/6ac9e7979712736ed962af4a)

The new-bar helper also needs a startup rule. With lastBar initially zero, the first tick after a restart counts as a new bar even if that candle began earlier. I would add one comparison case: restart midway through a candle with an existing position, then check that the closed-bar signal does not create a second entry. Decide explicitly whether startup may act on that old signal or must wait for the next bar.

[Omais Ali](https://hashnode.com/@omaisali)

[Oct 10](https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954/comment/6ac9e7979712736ed962af4a#reply-6ac9f26ad085a8a2b08a2a37)

Good catch Arnold, thanks. You're right, with lastBar at 0 the first tick after attaching or restarting fires as a new bar even mid candle. The fix is to seed it in OnInit with lastBar = iTime(\_Symbol, \_Period, 0); so the EA waits for the next real bar open. Agreed on the restart comparison case too, I've added it to the checklist.

[Arnold Holm](https://hashnode.com/@stratcorealpha)

[Oct 13](https://hashnode.com/posts/from-tradingview-strategy-to-mt5-expert-advisor-a-developer-s-checklist/6ac8f36430d4862710868954/comment/6ac9e7979712736ed962af4a#reply-6acde2b8c456b1b6b533975c)

Your updated OnInit now seeds the current bar, so attaching midway through a candle waits for the next bar. One further negative case is a new bar whose CopyBuffer values are not ready yet. If the helper advances lastBar before a successful read, that closed-bar evaluation can be lost. I would advance the processed-bar marker only after the required values are available, keeping entry deduplication separate.
