How-To & Platform Guides

Understanding Candle Indexing in DrawMyEA: How to Look Back in Time

Hanz Osborne

· 4 min read
Diagram explaining candle indexing on a MetaTrader daily chart for automated trading and EA development, showing candle 0 as the current moving price for today, candle 1 as yesterday, candle 2 as two days ago, and older candles counting back to 10 and 15 candles ago.

Hello traders!

If you’ve ever tried to build an Expert Advisor (EA), you know that timing is everything. You don't just want to know what the market is doing right now; you often need to know what it was doing one, five, or ten candles ago.

In our latest YouTube video, we dive deep into how DrawMyEA handles Candle Indexing. Whether you are checking if a candle closed above a moving average or looking for a moving average crossover, understanding how to count candles is the key to building a precise trading strategy.

Let's break down exactly how it works!

Image

Caption: The DrawMyEA workspace showing how the Rank Node (configured to look 'At' index 1) and the Cross Node connect to your MT5 strategy's global inputs.

The Golden Rule: How DrawMyEA Counts Candles

Before we look at the nodes, we need to understand how the platform counts time. In DrawMyEA, candle indexing always starts from the right side of your chart (the most recent data) and moves backward to the left.

  • Index 0: The current candle that is actively forming. Its price changes with every tick.
  • Index 1: The previous candle that just closed.
  • Index 2: The candle before that, and so on.
💡 Pro Tip: If your strategy relies on a candle being fully closed to avoid false signals, you will almost always want to look at Index 1, not Index 0!

1. The "Rank" Node: Targeted Indexing

In the video, we use the example of checking if the Close price is above the EMA 200. To do this, we use the Rank node.

The Rank node gives you total control over exactly which candles you want to analyze using two primary modes:

Mode Single: "At" (Exact Index)

This looks at one specific candle and one candle only.

  • Example: Setting it to At: 1 means the EA will check if only the most recently completed candle closed above the EMA 200.

Mode Range: "Start" and "End" (Range Inclusive)

This allows you to scan a specific window of time.

  • Example: Setting Start: 1 and End: 5 means the EA will check if all candles from the last 5 completed bars met your condition.
Image

Caption: Think of it like this: on a daily chart, Index 1 is always yesterday's full body of work. We recommend strategies use Index 1 for consistent, confirmed signals!

2. The "Cross" Node: Range Indexing via Default Inputs

Next in the video, we look at the Cross node (e.g., when a fast EMA crosses over a slow EMA). You might notice something different here: The Cross node does not have the "At/Start/End" parameter built into it.

Why? Because a crossover inherently requires a range of time to be detected.

Instead of configuring it inside the node itself, DrawMyEA handles this globally. The EA refers to a default input parameter located in your EA settings called:

"Number of Previous Candles to Search (at least 1)"

How it works:

If you set this default parameter to 3, your EA will automatically look back within the last 3 candles to see if a crossover occurred. This keeps your workspace clean while still giving you the flexibility to change your look-back period directly from your MetaTrader inputs without rewriting your logic!

Summary Checklist for Your Strategy

Node TypeHow it handles IndexingWhere to configure it
Rank NodeSpecific candle (At) or strict windows (Start/End)Inside the Node properties
Cross NodeLook-back window over multiple candlesVia EA Default Input Parameters

Watch the Full Tutorial!

Seeing it in action makes it much easier to understand. Watch the full video embedded below to see exactly how to wire these nodes together and see the EA execute trades based on these index settings.

Don't forget to like, subscribe, and drop a comment if you have any questions about candle indexing. Happy trading and see you in the next tutorial!

Disclaimer: MetaTrader®, MT4, and MT5 are trademarks of MetaQuotes Software Corp.
DrawMyEA is an independent service and is not affiliated with, endorsed by, or sponsored by MetaQuotes.
Copyright © 2026 DrawMyEA. All rights reserved.
Made by Web3Templates·