EA・自動売買

How Does an EA Actually Work? Understanding Automated Trading Through Ticks and OnTick | Visualizing a System of Conditional Logic

2026-07-03  / Ya

how-ea-works

‘I attached the EA and pressed the button, but for some reason no order gets placed.’ ‘I’m sure I turned automated trading off, but the EA still seems to be doing something.’ This sense of not knowing whether the EA is running or stopped is the first thing that confuses people who are just starting out with EAs. If this stays unclear, you won’t know what to check when the EA doesn’t behave the way you expected.

This page explains, with diagrams and plain-language breakdowns of the jargon, that an EA is a program that makes a decision every time the price moves, and that underneath it is nothing more than a collection of conditional branches (if this, then do that). If you’ve already grasped from What Is an EA / Automated Trading? (E01) that an EA is not magic, it’s a set of written rules, this article is the next step: understanding how those rules actually get executed. By the end, you’ll also see how EAs differ from discretionary trading and AI, and get a glimpse of the more advanced practice of using AI to analyze an EA’s behavior.

An EA Is a Program That ‘Decides Every Time the Price Moves’ (Why It Runs)

In a single sentence, an EA is a program that checks a fixed set of rules, in order, from top to bottom, every time a new price comes into the market. Where a human trader looks at the chart and thinks, ‘maybe it’s about time to buy,’ an EA automatically goes and checks its rules the instant the price updates. Once you understand this, it clicks: you can see exactly when, and on what trigger, the EA is making its decisions.

What Is a Tick? The Market’s Heartbeat

A tick refers to a single update of the exchange rate. Every time the price of USD/JPY changes — 150.123 to 150.124 to 150.122, and so on — each single change counts as one tick. During active trading hours, several ticks can arrive within a single second; during quiet overnight hours, there might be only one tick every few seconds. Think of a tick as the market’s heartbeat. Just as a heart keeps beating, the market keeps ticking out price updates.

The EA fires every single time one of these ticks arrives. More precisely, a part of the EA called OnTick gets called and executed once per tick. Read literally, ‘OnTick’ means ‘when a tick comes in’ — it is quite literally the place that runs when a new price arrives. OnTick — which is also this article’s focus keyword — is worth remembering as the heart of the EA; keeping that in mind will make the rest of this page easier to follow.

OnInitOnTickRuns every tickOnDeinitLoops on every price updateSetup → Repeated decisions → Cleanup
Figure: Each time a market tick (price update) arrives, the EA’s OnTick runs once — like a single heartbeat.

What matters here is that an EA does not run on a clock — it isn’t driven by ‘every minute’ or ‘every hour.’ The only thing that matters is how many times the price has moved. That’s why, right after a high-impact economic release sends prices swinging wildly, OnTick gets called over and over in rapid succession, while during quiet periods when the price barely moves, OnTick is hardly called at all. The reason an EA suddenly gets busy, then goes quiet, is that it’s directly tied to how many ticks the market is producing.

Setup at Startup (Once) → Decisions on Every Price Move (the Core) → Cleanup at Shutdown

Besides OnTick, an EA has other places that get called at fixed moments. The three most important ones are listed below, and this whole mechanism — where processing runs in response to an event — is called event-driven design. It’s easiest to understand by comparing each one to a human task, so let’s line them up.

Where in the program When it’s called Human-task analogy What it does (example)
OnInit Once only, the instant the EA is attached to the chart Arriving at work and setting up your desk Loading settings, initial checks, preparation
OnTick Every single time a tick arrives Serving a customer every time one walks in (the actual job) Deciding and executing entries, exits, martingale add-ons, etc.
OnDeinit Once only, the instant the EA is removed or MT4 is closed Clearing your desk and clocking out Cleanup, removing on-chart objects, writing logs

In other words, an EA’s entire lifecycle follows the flow: setup (OnInit) → endlessly repeating decisions on every price move (OnTick) → cleanup (OnDeinit). Almost all of the actual job happens inside OnTick. Whether to enter, whether to close a position, whether to add another martingale layer — all of these decisions are checked inside OnTick, every single time a tick arrives.

OnInitOnTickRuns every tickOnDeinitLoops on every price updateSetup → Repeated decisions → Cleanup
Figure: An EA’s lifecycle — OnInit (setup, once) → OnTick (repeated decisions, every tick) → OnDeinit (cleanup, once).

In Plain AI Terms

‘The logic runs inside OnTick’ means the EA is simply reviewing a fixed checklist from top to bottom every single time the price changes by one tick. A martingale-style EA like our own MAC v2.0 is no different: inside that same OnTick, it repeats the same check every tick — has the current unrealized loss opened up to 30 pips? If so, should it add another layer?*This is an AI-generated interpretation and does not guarantee future performance.

The Program Keeps Running Even With Auto-Trading Off — Trading Disabled Does Not Mean Stopped

This is the single biggest source of confusion for beginners, so let’s be precise about it. MT4/MT5 has an AutoTrading button in the top right of the screen, and when it’s OFF (red), the EA cannot place orders. Seeing this, many people assume AutoTrading off equals the EA being stopped. But strictly speaking, OnTick keeps running even when AutoTrading is off. The EA is still running — it’s just that only the order placement is blocked.

In other words, the EA calculating and deciding and the EA actually placing an order are two separate things. With the AutoTrading button off, here’s roughly what happens inside the EA: a price arrives → OnTick runs → it decides ‘the buy condition is met right now!’ → but the moment it tries to place the order, the system stops it with ‘AutoTrading is not permitted.’ The EA is, in short, running but with its hands and feet tied.

  • AutoTrading OFF (red): OnTick runs, and the EA still makes decisions. But it cannot place new orders or close positions (this is trading being blocked, not the EA being stopped).
  • AutoTrading ON (green, smiley face icon): OnTick runs, and if conditions are met, the EA actually goes ahead and places the order. This is the EA’s intended, fully operational state.

Knowing this distinction lets you properly diagnose the classic ‘I pressed the button but no order goes through’ problem. The cause is rarely that the EA is stopped — it’s more likely to be that AutoTrading is off, that the EA isn’t correctly attached to the chart, or that it’s outside the trading-hours filter window, among other possibilities. The practical payoff of understanding this mechanism is that you can start troubleshooting from the assumption that the EA is running. The actual steps for setting up and confirming operation are covered in EA Operating Environment (E09).

A Word From Our Researcher

Some people get spooked when the EA’s lines and arrows keep updating even after they turned AutoTrading off — but that’s actually proof OnTick is working normally, which is a healthy sign. An EA is truly stopped only when the smiley icon in the top right of the chart turns into a frown. Get in the habit of checking two separate axes — is it running, and can it place orders — and you’ll stop panicking when something looks off.

What an EA Is Actually Made Of (A Collection of Conditional Branches)

Let’s go one level deeper into what’s actually happening inside OnTick. To cut to the conclusion: an EA’s insides are nothing more than a stack of if-this-then-do-that conditional branches (if statements). It isn’t some sophisticated artificial intelligence, and it isn’t some mystical ability to read the market. It’s simply a machine executing rules that a human already decided on — without fatigue, without hesitation, without emotion. Once you understand this, both the excessive hope and the excessive fear people project onto EAs tend to fade away.

Entry Conditions, Exit Conditions, and SL/TP

These three are the most basic building blocks. Writing them out as plain-language rules makes the true nature of an EA easy to see.

  • Entry conditions: the ‘getting in’ rule, such as ‘buy if the moving average is pointing upward and the price hasn’t broken below the recent low.’
  • Exit conditions: the ‘getting out’ rule, such as ‘close the position once profit reaches a set number of pips, or once an opposite signal appears.’
  • SL (stop-loss) and TP (take-profit): the automatic exits set at the same time as the order. A mechanism that reserves an exit price in advance, such as ‘stop out at -20 pips, take profit at +40 pips.’

For example, an EA configured with SL 20 pips below entry and TP 40 pips above entry will automatically place both of those stop and limit orders the instant the entry order fills. From there, all that’s left is to wait and see which one the market touches first. The ratio between the SL and TP distances (1:2 in this example) is what’s known as the risk-reward ratio (D08), and it’s a major factor that shapes an EA’s overall performance.

Lot Sizing, Martingale (Nanpin) Conditions, and Trailing Stops

Next come the parts that govern how much you trade and how you let profits run. These connect directly to risk, so they deserve extra-careful reading whenever you’re evaluating an EA.

  • Lot sizing: the rule that decides how many lots to trade at what balance, such as ‘0.1 lot for every 10,000 yen in the account.’ Set this too aggressively, and the swings in your P&L — whether winning or losing — balloon immediately.
  • Martingale (nanpin) conditions: a rule such as ‘if the unrealized loss opens up to 30 pips, add another layer at 1.2x the previous lot size.’ The aim is to lower the average entry price when the market moves against you, but if the adverse move continues, this structure causes the unrealized loss to expand stage by stage.
  • Trailing stop: a rule that chases the SL (stop-loss line) in the direction of profit as the trade moves favorably, locking in gains while still letting the position run. A typical example is ‘once the trade is up 30 pips, move the SL to breakeven.’

Our own MAC v2.0 uses exactly this kind of martingale condition, configured as a 1.2x multiplier, up to 15 layers maximum, 30-pip spacing, with no hard SL (managed by the EA itself). Inside OnTick, every single tick, it simply and repeatedly checks whether the unrealized loss has reached the next 30-pip level, and if so, opens the next layer. Why this martingale-condition component can look like a high win rate while actually carrying unrealized-loss risk is worked out with worst-case numbers in EA Money Management (E07) and Stop-Loss and Money Management (D08). Once you understand the mechanism, make sure you go on to quantify the risk as well.

Trading-Hours Filters and News-Avoidance Filters

Finally, there are the filters that control when the EA does or doesn’t act. An EA is capable of running 24 hours a day, but there are times when it’s better off not acting at all.

  • Trading-hours filter: a rule that restricts trading to active hours only, such as ‘trade only from 9:00 to 2:00 the next day, Japan time.’ Its purpose is to avoid the widened spreads and false signals common during quiet hours.
  • News-avoidance filter: a rule such as ‘skip new entries for 15 minutes before and after a high-impact release.’ This is a dodge that avoids getting filled at unfavorable prices during sudden moves like the U.S. jobs report or an FOMC decision.

When these filters are active, you can end up with a situation where the conditions are met, but the EA still doesn’t place an order. Just like with AutoTrading being off, the EA is running (OnTick is firing) — it’s just that a filter has decided not to enter right now. Being able to suspect the filter settings whenever an EA doesn’t behave as expected is another practical benefit of understanding how it works.

Adverse move0.10.20.40.8 lotUnrealized loss accelerates
Figure: The conditional-branch checklist that runs inside OnTick (trading hours → news avoidance → entry conditions → exit/SL/TP → martingale → trailing stop)

Why You Need to Understand This Mechanism

You might think, ‘if I can just use it, do I really need to know what’s inside?’ But if you never learn how an EA actually operates, then when it behaves differently from what you expected, you have no way to tell whether that’s a malfunction or simply working as designed. And without that judgment, most people swing to one of two extremes: this EA is broken or a scam, or the opposite — I don’t really understand it, but I’ll just trust it and keep running it. Both are dangerous.

If you understand the mechanism, you can work through the same symptom — no order goes through — by ruling out possibilities one by one: the AutoTrading button, the filter’s time window, insufficient margin from the lot-sizing calculation, and so on. This connects directly to How to Spot a Dangerous EA (E08), because an EA vendor who can’t explain what triggers this EA, and under what conditions it acts, either doesn’t understand their own product, or is hiding something. Understanding the mechanism also gives you the ability to spot the holes in a seller’s explanation.

How What You Learn From Discretionary Trading Helps You Evaluate an EA (Discretionary Judgment vs. EA Logic)

If you’ve studied discretionary trading even a little, that experience becomes a direct asset for understanding EAs. Discretionary trading and EAs share the same skeleton — watch the market, get in, get out — and the only difference is whether a person makes the call, or a written rule does.

A discretionary trader can look at the chart and make an in-the-moment, holistic judgment — ‘the price action looks off today, I’ll sit this one out,’ or ‘there’s a release coming up, I’ll pass.’ Handling ambiguity and exceptions is a human strength. An EA, on the other hand, only looks at whether a fixed condition is met or not. It has no flexibility, but in exchange it has the strength of executing the same standard, 24 hours a day, without fatigue, without hesitation, and without being swayed by emotion. It all clicks into place once you think of an EA as the personal rules a discretionary trader talks about, kept without exception by a machine.

Common discretionary term SMC term How an EA (automated trading) handles it
A level where it looks about ready to bounce Support / resistance, a pool of liquidity Checked inside OnTick as a numeric condition: has price reached the specified level or line
Wait for a pullback, then buy A pullback into a discount zone A conditional branch: buy on a reversal signal once price falls below a set level
Stop out if it breaks below here Outside the most recent swing / outside liquidity The SL price is set automatically at entry
Let it run once a trend appears Following through after a BOS (break of structure) Trailing stop automatically moves the SL in the direction of profit
Sit out difficult market conditions Avoiding ranges / directionless price action Skipped via the trading-hours filter and news-avoidance filter

What we want to emphasize here is that an EA is neither discretionary judgment itself nor AI. An EA merely executes rules that a human has already put into words in advance — it doesn’t think anything new on the spot. It operates on a completely different layer of technology from AI, which can recognize patterns in the market or propose improvements. How far SMC’s discretionary logic can be automated, and where the human element still has to remain, is explored further in the SMC Beginner’s Roadmap (D09) and Types of EAs (E03).

A More Advanced Use: Analyzing an EA’s Behavior With AI to Extract Improvements

An EA itself is not AI. But it is entirely possible to have an AI read and analyze the trade logs and behavior an EA has produced, after the fact. This is exactly where our lab specializes — it’s the part where our whole positioning, translating difficult verification work through AI and publishing it, really comes into its own.

For example, you can hand an EA’s entire trade history to an AI and let it take on the kind of labor-intensive reading that would be tedious for a human: which time windows show a lopsided win/loss ratio, at what martingale layer the unrealized loss tends to peak, how the results would likely change if the trading-hours filter were adjusted. The AI translates these behavioral quirks and promising areas for improvement into plain human language. Think of it this way: the EA produces the facts of what it did (the log), and the AI adds an interpretation of why it happened that way, and where it could plausibly be fixed.

In Plain AI Terms

When we have our lab’s AI read the backtest results of SMC Gold Sniper (GOLD, M30, PF 1.87, max drawdown 8.2%, tested over 2018-2026), it puts behavioral quirks into words like: entries skew heavily toward clear trending phases, with more entries skipped during ranges by design; unrealized losses tend to deepen right at the initial stage of a trend reversal. But what the AI produces is an interpretation of past behavior — not a prediction of future price movement.*This is an AI-generated interpretation and does not guarantee future performance.

What’s worth keeping in mind is that AI-driven analysis can offer hints for improving an EA, but it does not guarantee winning. No matter how precisely you dissect the past logs, it’s still the past. That’s exactly why we always pair any AI interpretation with the discipline of verification: confirming it against backtesting (E04) and forward testing (E05), and checking what the numbers actually mean in How to Read EA Performance Metrics (E06). Drawing the line that AI is a translator, not a prophet, is exactly what keeps us an honest verification-focused publication.

Summary

The mechanics behind how an EA runs come wrapped in a lot of jargon, but at its core it’s very simple. Every time a new price (a tick) arrives in the market, OnTick inside the EA gets called, and it checks the conditional branches written there — entry, exit, SL/TP, lot sizing, martingale, trailing stop, trading-hours/news-avoidance filters — from top to bottom, executing whichever ones match. That’s the whole of it. Together with OnInit for setup and OnDeinit for cleanup, this event-driven design forms the entire skeleton.

Now that you’ve grasped the biggest point of confusion — OnTick keeps running even with AutoTrading off, since trading disabled does not mean stopped — you should be able to tell whether an EA behaving unexpectedly is a malfunction or simply working as designed. And an EA is neither discretionary judgment nor AI, but rather a device that executes human-written rules without emotion, whose behavior can later be analyzed by AI to extract areas for improvement. That’s the destination this page set out to reach.

Next, let’s look at what types this collection of rules breaks down into. Trend-following, counter-trend, martingale/nanpin, grid, SMC-replication — each strategy carries an entirely different risk profile. Head to Types of EAs (E03) and you’ll see concretely why the EAs that look like they have the highest win rates are exactly the ones that need the most caution. Also check the EA / Automated Trading Hub (learning roadmap) to see the overall learning order, and confirm the actual verification numbers in our Performance Archive (losing months included).

A Word From Our Researcher

For anyone touching an EA for the first time, my recommendation is to spend a full day just watching it on a demo account with AutoTrading off. Watching the lines, arrows, and logic displays keep updating even though no orders go through gives you a gut-level feel for the fact that OnTick is running, and it’s only the order placement that’s blocked. Rather than memorizing the mechanism as words, actually seeing this running-but-not-firing state with your own eyes, even once, is what makes it truly click.

Frequently Asked Questions

  • Q. If I turn the AutoTrading button off, does the EA stop completely?
    A. Order placement stops, but the EA itself (OnTick) keeps running. It’s still making calculations and decisions every time a price arrives — only the actual order placement is blocked. If you want to truly stop the EA, either remove it from the chart or close MT4/MT5 (at which point OnDeinit runs the cleanup).
  • Q. Does OnTick run once every minute?
    A. No — it isn’t tied to a clock, it fires on every tick (price update). If price action is volatile it might fire several times a second; during quiet periods it might fire only once every few seconds. The frequency depends on how active the market is. Note that this is not once a minute just because it’s an M1 EA.
  • Q. Does an EA use AI to intelligently read the market?
    A. No. A typical EA simply executes conditional branches (if this, then do that) that a human wrote in advance — it doesn’t learn or think on the spot. That said, it is possible to later have an AI analyze the trade logs an EA produced to extract behavioral quirks and areas for improvement, and that’s exactly where our lab makes use of AI.

Risk Disclosure

This page is not investment advice; it is analysis and verification information provided by our lab. Past performance, including backtests and forward tests, does not guarantee future profit. Offshore brokers (such as HFM) carry high-leverage risk; our lab treats them as a small, high-risk verification allocation, with domestic brokers (JFX/OANDA) as the core of our operations. FX and automated trading carry the risk of loss. Please trade only with disposable funds, and always at your own discretion and responsibility.