It all starts on a TradingView screen.
You watch the chart, build an indicator, or write your own Pine Script — until one day the condition you have been waiting for actually happens. TradingView fires an alert. And the next question is the one that decides everything.
Should that signal become a live order right away?
The whole iNakaTrader alert system — alertS, alertX, alertY, alertZ — grew out of the answer to that question.
Why a single signal should not always execute immediately
One signal carries less information than we like to think.
Indicator A says "entry valid," but it does not know which side you want to trade today. It does not know how many stop losses you have already taken. It does not know that you meant to wait for indicator B to agree. And it does not know whether the candle it fired on was a false signal.
If you wire alerts straight to order placement, one for one, then every mistake a signal makes becomes a real position immediately — including alerts that fire wrongly, fire twice, or fire at a moment you never intended them to work.
So the idea behind iNakaTrader is not "turn alerts into orders." It is to split intent into separate steps, and let each step do one clearly defined job.
- The step that controls whether you are open for trading at all → alertS
- The step that prepares an order → alertX
- The step that confirms it → alertY
- The step that closes → alertZ (and alertZ1 + alertZ2 when you want more care)
Every magic number keeps its own state, so separate strategies never contaminate each other.
alertS — start, stop, and set the boundaries of the loop
alertS controls the trading loop for a given magic through the loop_action field, which accepts START, STOP, START BUY, STOP BUY, START SELL, and STOP SELL.
What matters is that the one-sided commands are not a plain toggle — they act on the current state. For example:
STOP BUYwhile both BUY and SELL are enabled → SELL only remainsSTOP BUYwhile BUY only is enabled → everything is disabledSTART SELLwhile BUY only is enabled → both BUY and SELL are enabled
Beyond direction, alertS can carry starting values along with it — volume, tp, sl, atr_period, atr_timeframe — as well as ceilings such as max_open_buy, max_open_sell, max_exec_buy, max_exec_sell, tp_limit, and sl_limit (where 0 means unlimited). alertS is also where Pine Script mode is registered, together with that mode's default parameters.
The parameter priority documented in the manual is:
- Values from
alertY(highest) - Values from
alertX pine_defaultscarried byalertS(Pine Script mode only)- The EA's own input settings (lowest — used when the signal omits the field)
The distinction people miss most often is between "not sending a field" and "sending 0." The EA's own input is used only when the field is omitted (an empty string "" counts as omitted — and in alertY that is what lets a blank field inherit the value alertX already armed). An explicit 0, by contrast, is an instruction in its own right: it is passed through to the EA and replaces the EA's default. In most cases 0 means "off" or "unlimited" — tp_limit: 0 and sl_limit: 0 switch the TP/SL counters off, while max_open_buy: 0 means no position cap. If you want the EA's own setting to apply, leave the field out entirely.
Put simply: alertS sets the frame, and later alerts are allowed to write over it.
alertX — the step that prepares, not the step that fires
alertX tells the system if we trade, this is how we trade — which direction, what size, what TP and SL.
The required fields are alert_name, magic, symbol, and action, where action covers both market orders (BUY, SELL) and pending orders such as BLM (buy limit), SLM (sell limit), BST (buy stop), and SST (sell stop), which are used together with the price field.
{
"alert_name": "alertX",
"magic": 999888,
"symbol": "XAUUSD",
"action": "BUY",
"volume": 0.01,
"tp": 500,
"sl": 250
}
The thing to remember is that alertX does not open a position. It only arms one — the parameters are held on the server side and nothing else. If no follow-up alert arrives, nothing at all happens to your account.
This is the point where a false signal from a single indicator stops short of becoming a real order.
alertY — the confirmation step (and the last-minute correction)
alertY is the confirmation. When it arrives, the order that alertX prepared is finally handed to the EA.
The key condition is that alertY must always arrive after alertX. Without a prior alertX, the alertY is rejected.
Its shortest form carries almost no information, because everything was already set at the X step.
{
"alert_name": "alertY",
"magic": 999888,
"symbol": "XAUUSD"
}
But alertY can also override every value alertX prepared — volume, tp, sl, price, comment, and even action itself. That means if your second indicator reads the market differently, it can flip a BUY into a SELL at the moment of confirmation.
So the X→Y structure matches the way many people already trade: indicator A raises the idea, indicator B decides. If only A fires, no position is taken.
xy_timeout — how long an armed signal stays valid
The next question is unavoidable: what if alertX arms a trade and alertY only arrives several hours later? By then the market may be nothing like it was.
That is the job of xy_timeout, which is set on the alertX payload. It defines how many seconds an armed X stays valid. If alertY arrives after that window, it is rejected and you have to send a fresh alertX.
According to the manual, the default value of xy_timeout is 0, which means it never expires — not a window the system picks for you. If you want a limited window, you have to set it yourself.
And do not confuse it with pending_timeout, which is a different thing entirely:
xy_timeout— governs the server-side X→Y handshake before any order is sent outpending_timeout— governs a pending order (BLM/SLM/BST/SST) already placed in MT5, cancelling it after the given number of seconds
alertZ — closing immediately, when immediate is what you want
alertZ works the opposite way to X/Y: no confirmation needed. It arrives, it closes.
What gets closed depends on close_type, which accepts all (the default), buy, sell, profit (close only positions in profit), and loss (close only positions at a loss). And if you want the strategy state wiped after the close, you can send reset_after_close as true along with it.
Immediate closing has its place — stepping out before news, or closing at the end of the session on schedule. Waiting for a confirmation in those situations helps nobody.
alertZ1 + alertZ2 — when closing needs a guard too
But closing can be just as dangerous as opening. One mistaken close signal can flatten an entire account in a single pass.
So alertZ1 + alertZ2 is the two-step version of closing, using the same logic as X→Y.
alertZ1arms the close. It takes the sameclose_typevalues asalertZ, and its lifetime is set throughtimeout_seconds, where the default is 300 seconds (5 minutes).alertZ2is the confirmation. It has to arrive within that window. If Z1 has already expired, thealertZ2is rejected.
The result is the same pattern as on the entry side: indicator A calls for the exit, indicator B confirms within five minutes, and only then do positions close. If only A fires, nothing closes.
The roles of S / X / Y / Z at a glance
| Alert | Role | Acts immediately? |
|---|---|---|
alertS |
Starts/stops the loop, controls direction, carries starting values and ceilings for that magic | Does not open a position by itself |
alertX |
Prepares the order and its parameters (arms it) | No — waits for alertY |
alertY |
Confirms the order and can override X's values | Yes — when an unexpired X exists |
alertZ |
Closes positions per close_type |
Yes — immediately |
alertZ1 + alertZ2 |
Two-step close with a timeout (default 300 seconds) | Closes when Z2 arrives in time |
None of this was designed to make the system smarter. It was designed so that one mistake does not automatically become one loss.
iNakaTrader is execution infrastructure — the strategy is still yours, the signals are still yours, and the broker is still yours.
Risk disclaimer
Trading foreign exchange and other financial instruments carries a high level of risk and may not be suitable for all investors. Past performance is not indicative of future results. This article is for informational purposes only and does not constitute investment advice. iNakaTrader provides execution infrastructure only — it does not provide trading signals, strategies, or financial advice.
Trade Wisely, Sleep Well