How to Use AlgoWayWS-MT5 EA 2.20 for TradingView to MT5 Webhook Automation
AlgoWayWS-MT5 EA is the MetaTrader 5 execution bridge for AlgoWay. It connects the AlgoWay platform to your MT5 terminal and lets structured signals from TradingView alerts, Telegram signals, manual webhook tests, or other supported sources become real MT5 trading actions.
This page is the current user-facing guide for the AlgoWayWS-MT5 EA 2.20 workflow. The file name still contains v206 because it originated from an earlier documentation cycle, while the content now reflects the current EA build and current AlgoWay platform direction: TradingView to MT5 webhook automation through AlgoWay and the AlgoWayWS-MT5 Expert Advisor.
All EA settings in this guide are named exactly as users see them in the MetaTrader 5 Inputs tab. Internal MQL variable names are intentionally not used for EA settings.
The complete execution route is:
TradingView alert -> AlgoWay webhook -> AlgoWayWS-MT5 EA -> MetaTrader 5 broker account
This guide explains what the EA does, how webhook JSON fields are interpreted, how trade modes work, how SL/TP and trailing rules are applied, and how to troubleshoot the most common MT5 execution problems.
Last updated: 2026-10-13 • Author: AlgoWay
EA 2.20 Update Notes
EA 2.20 adds EA-managed multiple Take Profit with up to four TP levels. Each level can close a percentage of the original position or a fixed number of lots. TP distances can be specified in pips or as percentages. The feature is disabled by default and is configured in the MT5 EA Inputs.
EA 2.19 introduced built-in Telegram Trade Reports, EA-based fixed lot sizing, the STANDARD pip mode, and stronger broker confirmation for position management. Position closes, partial closes and SL/TP modifications are now treated as completed only after the relevant MT5 broker result is confirmed.
The new Override JSON order_contracts for new entries option lets the EA use a fixed lot size for BUY and SELL entries. When enabled, the configured Fixed EA lot size replaces the entry size received in order_contracts. Close/flat sizing continues to use the existing close-volume logic.
Telegram Trade Reports are independent from AlgoWay Telegram notifications configured in the dashboard. Dashboard notifications report incoming alerts received by AlgoWay, while EA Trade Reports report the actual position and pending-order activity occurring in MetaTrader 5.
The new STANDARD pip mode uses one pip as ten broker points for every symbol. Existing AUTO, TRADINGVIEW, PERCENT and POINTS modes remain available, so existing configurations do not need to change unless a different distance interpretation is required.
Start Here: Current Setup and Support Guides
This page explains the EA behavior and JSON logic. For installation and platform setup, use the dedicated guides below.
| Need | Current guide |
|---|---|
| Install the current MT5 Expert Advisor | How to install an MT5 Expert Advisor for AlgoWay automation |
| Connect TradingView alerts to MT5 | How to connect TradingView to MetaTrader 5 with AlgoWay EA |
| Build a valid AlgoWay webhook message | AlgoWay JSON schema guide |
| Understand SL/TP, trailing and risk logic | Advanced risk management and trade automation |
| Choose Hedge, Reverse, Opposite or Inverse behavior | How AlgoWay handles opposite trading signals |
| Fix MetaTrader 5 EA errors | MetaTrader 5 common errors in AlgoWay |
Why AlgoWayWS-MT5 EA Exists
TradingView is powerful for charting, Pine Script strategies and alerts, but TradingView does not directly execute trades inside your MetaTrader 5 broker terminal. MetaTrader 5 can execute trades through Expert Advisors, but it needs a reliable way to receive the signal from outside.
AlgoWayWS-MT5 EA closes this gap:
- TradingView creates the signal;
- AlgoWay receives the webhook alert and validates the message;
- AlgoWayWS-MT5 EA keeps the MT5 terminal connected to AlgoWay;
- MetaTrader 5 executes the order through your broker account.
Competitors describe the same market need as a TradingView-to-MT5 bridge, webhook-to-EA connector, or alert automation layer. AlgoWay focuses this workflow around a dashboard, structured JSON, WebSocket EA delivery, logs, and multi-source signal routing.
What the EA Does and What It Does Not Do
The AlgoWayWS-MT5 EA is an executor. It receives commands routed by AlgoWay and performs trade actions in MetaTrader 5.
The EA can help with:
- opening BUY or SELL positions;
- closing positions with
flatcommands; - modifying SL/TP where supported by the message and current route;
- handling trade modes such as Reverse, Hedge, Opposite and Inverse;
- applying SL/TP, trailing, breakeven and profit lock rules;
- mapping TradingView tickers to exact MT5 broker symbols;
- respecting configured position size mode, session filters and limits;
- writing useful logs in MetaTrader 5.
The EA does not create the strategy. It does not guarantee profit. It does not fix a bad TradingView strategy, invalid signal logic, broker spread, slippage, closed market, insufficient margin or unsupported broker settings.
Runtime Conditions in MetaTrader 5
Before expecting the EA to execute orders, confirm these MT5 conditions:
- AlgoWayWS-MT5 EA is attached to a chart.
- MT5 Algo Trading is enabled.
- The EA is allowed to trade in its chart properties.
- DLL imports are enabled if required by the current WebSocket EA setup.
- The correct AlgoWay webhook UUID is entered in the EA inputs.
- The EA shows connected status in the MT5 Experts log or chart status.
- The broker symbol is visible in Market Watch and receiving quotes.
If MT5 returns Error 4752, the EA is probably blocked by algorithmic trading permissions. Read: How to fix MT5 Error 4752.
Connecting the EA to AlgoWay
The key connection value is shown in MT5 as Your Algoway Webhook here. It identifies which AlgoWay webhook route belongs to this MT5 terminal.
| Name shown in MT5 Inputs | Meaning | Example |
|---|---|---|
| Your Algoway Webhook here | AlgoWay webhook UUID or the full https://algoway.co/<uuid> webhook URL. EA 2.20 extracts the UUID from the full URL automatically. |
b7534616-6c8c-4582-8af4-7c143d323231 |
| MAGIC_NUMBER | Magic number used by the EA to identify and manage only its own positions. | 1973 |
If the EA is connected to the wrong webhook, valid alerts can reach AlgoWay but never reach the intended MT5 terminal. Do not attach two active EA instances to the same webhook: the single-instance guard keeps only one instance active.
Complete EA 2.20 Inputs Reference
The names below follow the labels shown in the MetaTrader 5 Inputs tab. This section explains only what a user needs to configure; internal MQL names and implementation details are intentionally omitted.
Connection and Execution
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Your Algoway Webhook here | Connects this EA instance to the AlgoWay webhook assigned to this MT5 terminal. Enter the webhook UUID or supported full webhook URL. |
| MAGIC_NUMBER | Identifies trades managed by this EA. Keep the same value for trades that should belong to the same AlgoWay EA instance, and use a different value when separate EAs must not manage each other’s trades. |
| Reverse / Hedge / Opposite / Inverse | Selects how a new BUY or SELL command interacts with positions already open on the same symbol. |
| Coefficient for work with Lots | Multiplies the order size before the trade is sent to MT5. Use 1 for the original size, 0.5 for half size, 2 for double size, and so on. |
| Order filling type: AUTO, FOK or IOC | Selects the MT5 filling policy. AUTO is recommended for most users because it lets the EA use a filling mode supported by the broker symbol. |
| Pending orders: Legacy / Reject / Chase | Controls what happens when a LIMIT or STOP price is no longer valid for the requested pending-order type. Legacy can convert LIMIT and STOP when required, Reject keeps the requested type and refuses an invalid price, and Chase keeps the requested type while adjusting the entry toward a valid broker price. |
| PIP type: AUTO/TRADINGVIEW/PERCENT/POINTS/STANDARD | Defines how distance values such as Stop Loss, Take Profit, trailing, breakeven and profit lock are interpreted. Use STANDARD when one pip must always equal ten broker points, including broker symbols such as GOLD or XAUUSD variants. |
| SL/TP reference: Bid/Ask or Entry Price | Selects whether distance-based SL/TP is measured from the current Bid/Ask quote or from the trade entry price. |
Symbols Mapping
TView Ticker N1 through TView Ticker N5 are the incoming ticker names. Broker Ticker N1 through Broker Ticker N5 are the exact MT5 symbols that should be used instead. Example: XAUUSD can be mapped to GOLD.pro. Leave unused pairs empty.
Position Size Mode
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Position size: Lots / Risk% / Balance% | Selects what order_contracts means for a new entry: an MT5 lot amount, a percentage of equity risk based on Stop Loss, or a percentage of balance used for sizing. |
| Override JSON order_contracts for new entries | Uses the EA fixed lot size for BUY and SELL entries and ignores the entry size received in order_contracts. This override has priority over Lots, Risk% and Balance% entry sizing. |
| Fixed EA lot size | Sets the lot size used for new BUY and SELL entries while the fixed-lot override is enabled. |
| LEGACY: force Risk% (by SL) | Compatibility option for older setup files. Enable only when an older configuration expects order_contracts to be treated as risk percentage. |
| Close size: Lots / Percent % | Selects what order_contracts means for a flat command: lots to close or a percentage of the position’s initial size. |
EA Based Trailing, Breakeven and Profit Lock
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Enable Trailing SL | Turns the EA trailing stop on for trades that do not override trailing through the incoming signal. |
| Trailing Step in pips | Sets the trailing distance used to keep Stop Loss behind the current market price. |
| Start trailing after N pips, 0 = immediate | Sets the profit distance required before trailing begins. Zero starts trailing immediately. |
| Enable Breakeven | Allows the EA to move Stop Loss to the entry price after the configured profit threshold is reached. |
| Move SL to BE after X pips profit | Sets the profit distance that activates breakeven. |
| Enable Profit Lock factor | Enables a protected-profit Stop Loss after the trade reaches the configured trigger. |
| Profit Lock after XX pips | Sets the amount of profit the EA should protect once Profit Lock is active. |
| Delta trigger | Sets the profit distance that activates Profit Lock. |
EA Based SL and TP
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Use fixed SL/TP (pips) inside EA | Uses the fixed Stop Loss and Take Profit distances configured in the EA instead of distance values received with the entry signal. |
| Do not place SL in MT5 | Prevents the EA from placing a Stop Loss on new trades. |
| Do not place TP in MT5 | Prevents the EA from placing a Take Profit on new trades. |
| Internal SL distance in pips | Sets the fixed Stop Loss distance used when fixed EA SL/TP is enabled. |
| Internal TP distance in pips | Sets the fixed Take Profit distance used when fixed EA SL/TP is enabled. |
EA-Based Multiple Take Profit (EA 2.20)
Version 2.20 supports up to four internal Take Profit targets. This feature is optional: with Enable EA-managed multiple TP disabled, existing TP behavior is unchanged. All values below are set in the EA Inputs, not in webhook JSON.
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Enable EA-managed multiple TP | Enables EA-managed partial closes at up to four profit targets. Default: disabled. |
| TP distance: Pips / Percent | Interprets TP1–TP4 distances as pips or percentages of the position entry price. |
| TP close size: Percent / Lots | Chooses whether each target closes a percentage of the position's initial volume or a fixed number of MT5 lots. |
| TP1 distance, 0 = disabled | Sets the first target distance; zero disables TP1. |
| Close % of initial position at TP1 | Percentage closed at TP1 in Percent close-size mode. |
| Fixed lots to close at TP1 | Lots closed at TP1 in Lots close-size mode. |
| TP2 distance, 0 = disabled | Sets the second target distance; zero disables TP2. |
| Close % of initial position at TP2 | Percentage closed at TP2 in Percent close-size mode. |
| Fixed lots to close at TP2 | Lots closed at TP2 in Lots close-size mode. |
| TP3 distance, 0 = disabled | Sets the third target distance; zero disables TP3. |
| Close % of initial position at TP3 | Percentage closed at TP3 in Percent close-size mode. |
| Fixed lots to close at TP3 | Lots closed at TP3 in Lots close-size mode. |
| TP4 distance, 0 = disabled | Sets the fourth target distance; zero disables TP4. |
| Close % of initial position at TP4 | Percentage closed at TP4 in Percent close-size mode. |
| Fixed lots to close at TP4 | Lots closed at TP4 in Lots close-size mode. |
Enabled TP distances must increase from one target to the next. In Percent close-size mode, total configured closing percentages must not exceed 100%. In Lots mode, each enabled stage must specify a positive lot amount that complies with the broker's volume step. The EA must remain running to monitor targets and execute these partial closes.
Martingale and Trade Limits
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Enable increasing the lot after a losing trade | Enables the optional lot-increase sequence after a losing trade. |
| Lot increase coefficient | Sets the multiplier applied to the next lot size while the lot-increase sequence is active. |
| Max daily loss in % | Sets the maximum daily loss threshold for this EA. Zero disables the limit. When triggered, EA positions are closed and new entries remain blocked until the next trading-day reset. |
| Max drawdown per trade in % | Sets the maximum adverse price movement allowed for an individual EA trade. Zero disables this protection. |
| Max positions, if 0 = no limit | Limits the total number of positions the EA may keep open. Zero means no limit. |
| Max positions per direction, if 0 = no limit | Limits how many BUY or SELL positions the EA may keep open in the same direction. Zero means no limit. |
| Max spread in points, 0 = disabled | Blocks new entries when the current broker spread is above the configured number of points. Zero disables the spread filter. |
| Max price deviation in points, 0 = AUTO | Sets the maximum allowed market-order price deviation in broker points. Zero lets the EA choose an adaptive value automatically. |
Sessions, Daily Window and Auto-Close
| Name shown in MT5 Inputs | What it controls |
|---|---|
| NY session: Winter or Summer | Selects the seasonal New York trading-day boundary used by daily reset and Auto-Close calculations. |
| London (07:00-16:00) | Allows new entries during the London UTC session. |
| New York (12:00-22:00) | Allows new entries during the New York UTC session. |
| Tokyo (22:00-07:00) | Allows new entries during the Tokyo UTC session. |
| Daily Window Time Mode | Selects which clock is used for Daily Trade Window: UTC, MT5 broker/server time, or the local Windows/VPS time. |
| Daily Trade Window | Sets the allowed daily entry interval in HH:MM-HH:MM format using the selected Daily Window Time Mode. |
| Auto close: None / End of Day / End of Week | Selects whether EA positions stay open normally, close before the calculated end of the trading day, or close before the end of the trading week. |
| Close positions before market end, minutes | Sets how many minutes before the selected day or week end the Auto-Close process begins. |
| Allow new trades after market open, minutes | Delays new entries for the configured number of minutes after the calculated market/trading-week open. Zero allows entries immediately. |
The informational rows SUMMER start 2nd Sunday of March and WINTER start 1st Sunday of November are reminders for the seasonal New York setting; they are not trading parameters.
Telegram Notifications and Diagnostics
| Name shown in MT5 Inputs | What it controls |
|---|---|
| Telegram notify for AlgoWay disconnect | Sends Telegram notifications when the EA loses its AlgoWay connection and when the connection is restored. |
| Telegram reports for positions and pending orders | Sends EA-side Telegram reports about position and pending-order activity. |
| Telegram chat id | Sets the Telegram chat that receives EA notifications and reports. |
| Telegram bot token | Sets the Telegram bot token used by the EA to send messages. |
| Debug logging: 0 = disabled, 1 = enabled | Enables additional diagnostic records in the MT5 Experts log. Keep it disabled during normal operation and enable it when detailed troubleshooting is needed. |
Telegram requirement: add https://api.telegram.org to MT5 under Tools >> Options >> Expert Advisors >> Allow WebRequest for listed URL before using EA Telegram notifications or trade reports.
Core TradingView to MT5 JSON Fields
A basic AlgoWay message for MetaTrader 5 contains four main fields:
| Field | Example | Purpose |
|---|---|---|
platform_name |
metatrader5 |
Tells AlgoWay to route the command to MetaTrader 5. |
ticker |
EURUSD |
Defines the trading symbol. It may need mapping to the broker symbol. |
order_contracts |
0.10 |
Defines the size value before final sizing mode and coefficient logic. |
order_action |
buy |
Defines the action: buy, sell, flat, modify or mode-specific action. |
When Override JSON order_contracts for new entries is enabled in the EA, the EA ignores the order_contracts value for BUY and SELL entry sizing and uses Fixed EA lot size instead. The field can still be present in the webhook message.
Basic market order:
{
"platform_name": "metatrader5",
"ticker": "EURUSD",
"order_contracts": 0.10,
"order_action": "buy"
}
TradingView Strategy Alert Example
For a TradingView strategy alert, use TradingView placeholders. TradingView replaces them when the alert fires.
{
"platform_name": "metatrader5",
"ticker": "{{ticker}}",
"order_contracts": "{{strategy.order.contracts}}",
"order_action": "{{strategy.market_position}}",
"price": "{{close}}"
}
If this message reaches AlgoWay but MT5 does not trade, check the EA connection, symbol mapping, lot size, trade mode, broker session, margin and MT5 logs.
Supported Trade Actions
| Action | Meaning | Typical use |
|---|---|---|
buy |
Open or process BUY-side command | Long entry |
sell |
Open or process SELL-side command | Short entry |
long |
Directional value treated as BUY where supported | TradingView strategy state mapping |
short |
Directional value treated as SELL where supported | TradingView strategy state mapping |
flat |
Close position logic | Exit signal or partial close workflow |
modify |
Modify an existing position | Update SL/TP by identifier |
Trade Modes: Reverse, Hedge, Opposite and Inverse
The dropdown shown as Reverse / Hedge / Opposite / Inverse defines how the EA behaves when a new signal arrives while a position already exists on the same symbol.
| Mode | Behavior | Best use case |
|---|---|---|
| Reverse | One-side model. The EA closes the opposite side and opens or keeps the new side according to signal logic. | Simple TradingView strategy automation where one side should be active. |
| Hedge | BUY and SELL can exist at the same time if the account supports it. | Hedging systems and independent long/short logic. |
| Opposite | The latest signal controls direction. The current position can be closed and the opposite side opened. | Strategies that flip immediately from long to short or short to long. |
| Inverse | Incoming direction is inverted before execution logic. BUY becomes SELL, SELL becomes BUY. | Counter-signal workflows or inverse strategy execution. |
Detailed mode guide: How AlgoWay handles opposite trading signals.
Position size: Lots / Risk% / Balance%
The same order_contracts value can mean different things depending on the value selected in Position size: Lots / Risk% / Balance%.
EA-based fixed lot override
Override JSON order_contracts for new entries is a hard entry-size override. When enabled, BUY and SELL entries use Fixed EA lot size and the EA does not use the incoming order_contracts value to size that new entry.
This is useful for TradingView indicators or other signal sources where the signal determines direction while position size should remain fixed in MT5. The override applies to new entries only; flat commands continue to use Close size: Lots / Percent %.
Lots
order_contracts is treated as lots before coefficient and broker validation.
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "0.10"
}
Risk%
order_contracts is treated as percent risk of equity. This mode requires a usable Stop Loss because the EA needs stop distance to calculate position size.
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "1.0",
"stop_loss": "100"
}
Balance%
order_contracts is treated as percent of balance. This is not the same as risk-by-stop-loss mode.
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "5.0",
"stop_loss": "100"
}
Coefficient for work with Lots
Coefficient for work with Lots multiplies lot sizing derived from order_contracts. When the EA-based fixed lot override is enabled for a new entry, the configured Fixed EA lot size is used instead of the JSON-derived entry size.
1- keep the computed or provided size.0.5- use half the size.2- double the size.
Always test final lot size in a demo or small-volume environment before live trading. Wrong coefficient values can create invalid volume errors or oversized positions.
Order filling type: AUTO, FOK or IOC
- Auto Mode - lets the EA select a filling mode supported by the broker symbol.
- FOK - Fill or Kill. The requested volume must be filled completely or the order is rejected.
- IOC - Immediate or Cancel. The broker may fill the available part and cancel the remainder.
Use Auto Mode unless the broker or prop firm explicitly requires another mode. MT5 retcode 10030 means the selected filling mode is not supported for that symbol.
Pending orders: Legacy / Reject / Chase
This setting controls how the EA handles a LIMIT or STOP order when the requested entry price is no longer valid for that pending-order type at the moment MT5 receives the command.
- Legacy - keeps compatibility with older setups and can switch between LIMIT and STOP when the requested price is on the wrong side of the market.
- Reject - keeps the requested pending-order type and rejects the order when the requested price is invalid for that type.
- Chase - keeps the requested pending-order type and adjusts the entry toward the nearest valid broker price instead of changing LIMIT to STOP or STOP to LIMIT.
Use Legacy for existing configurations that already rely on automatic conversion. Use Reject when the strategy must preserve the exact requested type and should fail instead of changing the order. Use Chase when preserving the requested type is important but a small price adjustment is acceptable.
Symbol Mapping: TradingView Ticker vs MT5 Broker Symbol
TradingView and MT5 brokers often use different symbol names. Enter the TradingView value in TView Ticker N1 and the exact MT5 symbol in Broker Ticker N1. The same rule applies to pairs N2 through N5.
| TradingView ticker | MT5 broker symbol |
|---|---|
DE40 |
GER40 |
XAUUSD |
GOLD |
US30 |
DJ30 |
EURUSD |
EURUSD.a |
If the symbol is not found, the trade will not open. Always confirm the exact broker symbol in MT5 Market Watch.
SL/TP Model A: Levels from JSON
Model A means the alert message itself sends Stop Loss, Take Profit or trailing fields.
Exact SL/TP Prices
{
"platform_name": "metatrader5",
"order_action": "sell",
"ticker": "XAUUSD",
"order_contracts": "0.05",
"sl_price": "2055.50",
"tp_price": "2038.00"
}
Distance-Based SL/TP
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "BTCUSDT.P",
"order_contracts": "0.10",
"stop_loss": "150",
"take_profit": "300"
}
Priority rule: if sl_price or tp_price are set and non-zero, price levels should take priority. Otherwise distance fields such as stop_loss and take_profit are used.
SL/TP Model B: Levels from EA Inputs
Model B means the EA applies internal SL/TP values from the Inputs tab.
- Use fixed SL/TP (pips) inside EA - enables fixed EA distances for new entries.
- Internal SL distance in pips - fixed Stop Loss distance.
- Internal TP distance in pips - fixed Take Profit distance.
- Do not place SL in MT5 - suppresses Stop Loss placement.
- Do not place TP in MT5 - suppresses Take Profit placement.
When Use fixed SL/TP (pips) inside EA is enabled, the EA uses the internal distances for that entry instead of the alert-provided distance values. Exact behavior still depends on the selected PIP type and broker stop restrictions.
PIP type: AUTO/TRADINGVIEW/PERCENT/POINTS/STANDARD
This setting defines how every distance expressed through Stop Loss, Take Profit, trailing, breakeven or profit-lock values is converted into an MT5 price distance.
- AUTO - follows the broker symbol’s digits and point format.
- TRADINGVIEW - keeps the existing AlgoWay TradingView-compatible behavior: Forex symbols use ten broker points per pip, while other broker calculation types use one broker point per pip.
- PERCENT - treats distance values as percentages of the relevant price instead of pips or points.
- POINTS - treats each distance unit as exactly one broker point.
- STANDARD - treats one pip as ten broker points for every symbol. This is useful when different brokers classify the same market differently, for example when gold is exposed as
XAUUSD,GOLDor a broker-specific symbol suffix.
Example: when a broker symbol has a point size of 0.01, STANDARD uses a pip size of 0.10. A distance of 20 therefore represents a price distance of 2.00 before the selected Bid/Ask or Entry Price reference is applied.
Existing users can keep their current mode. STANDARD is an additional option and does not change the behavior of AUTO, TRADINGVIEW, PERCENT or POINTS.
SL/TP Reference: Bid/Ask or Entry Price
The setting shown as SL/TP reference: Bid/Ask or Entry Price controls which price is used as the reference for distance-based Stop Loss and Take Profit calculations.
- Bid/Ask - preserves the quote-side calculation used by the EA. For distance-based SL/TP, the reference depends on trade direction and whether the level is a Stop Loss or Take Profit.
- Entry Price - bases distance-based SL/TP on the position entry price. For market orders, the EA first opens the trade, resolves the actual MT5 position and actual fill price, then recalculates the applicable distance-based SL/TP and applies the corrected levels to that position.
Absolute sl_price and tp_price values are not converted into distances by this selector. When explicit price levels are supplied, those levels keep priority over stop_loss and take_profit distance fields.
For pending orders, Entry Price mode can use the requested pending-order price as the reference before the order is sent. For market orders, the actual executed entry price is used after the position is opened and identified.
Practical difference: use Bid/Ask when you want the legacy quote-side behavior. Use Entry Price when a strategy expects a 100-pip Stop Loss or Take Profit to be measured from the actual trade entry rather than from the current Bid or Ask reference.
Trailing Stop from JSON and EA Inputs
Trailing can be enabled per trade with trailing_pips.
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "GBPUSD",
"order_contracts": "0.10",
"stop_loss": "120",
"trailing_pips": "80"
}
If trailing_pips is present, trailing is enabled for that trade. If it is absent, the EA uses Enable Trailing SL, Trailing Step in pips and Start trailing after N pips, 0 = immediate.
Delayed Trailing Activation with trail_points
trail_points allows trailing stop to start only after the trade moves a specified number of pips into profit.
trail_points = 0- trailing starts immediately after the position opens.trail_points = 50- trailing starts only after 50 pips of profit.
{
"platform_name": "metatrader5",
"ticker": "SP500",
"order_action": "buy",
"order_contracts": "4",
"trailing_pips": "20",
"trail_points": "50"
}
In this example, the trailing step is 20 pips, but trailing starts only after the trade moves 50 pips in profit.
Breakeven
Breakeven logic moves Stop Loss to the entry area after the trade reaches a configured profit distance.
- Enable Breakeven - enables breakeven logic.
- Move SL to BE after X pips profit - defines when breakeven activates.
Breakeven is useful when a strategy should remove open risk after the market moves in the intended direction.
Profit Lock
Profit Lock is more advanced than basic breakeven. It can move Stop Loss so that a defined amount of profit is protected after the trade reaches a trigger.
- Enable Profit Lock factor - enables profit lock logic.
- Delta trigger - profit threshold that activates the feature.
- Profit Lock after XX pips - profit distance the EA tries to protect after activation.
In simple terms: first the trade reaches the trigger, then the EA moves SL to protect the configured profit.
Partial Close with Close Size Mode
The setting shown as Close size: Lots / Percent % controls whether the EA closes positions by lots or by percentage of the initial position volume.
- Lots -
order_contractsin aflatsignal is treated as lots. - Percent % -
order_contractsin aflatsignal is treated as percent of the initial position.
{
"platform_name": "metatrader5",
"ticker": "SP500",
"order_action": "flat",
"order_contracts": "25"
}
If the initial position was 4.00 lots and Close size: Lots / Percent % is set to Percent %, this command closes 25% of the initial position, which is 1.00 lot.
close_side for Hedge Workflows
close_side is used with flat to close only one side where supported.
{
"platform_name": "metatrader5",
"order_action": "flat",
"ticker": "EURUSD",
"close_side": "long"
}
longorbuy- close BUY-side positions.shortorsell- close SELL-side positions.
If close_side is used with buy, sell or modify, treat it as invalid. It belongs to close/flat logic.
Modify Existing Positions
modify is used to update an existing position instead of opening a new one. The position must be identified by comment or tv_order_id depending on your route.
{
"platform_name": "metatrader5",
"order_action": "modify",
"ticker": "ETHUSDT",
"comment": "TV#12345",
"stop_loss": "140",
"take_profit": "280"
}
If no matching position is found, the modification cannot be applied.
Martingale
Enable increasing the lot after a losing trade activates martingale sizing. Lot increase coefficient defines the multiplier for the next step. This is a high-risk feature and should be tested carefully before live use.
Do not enable martingale just because it exists. Use it only if the trading system was designed and tested for this risk model.
Trade Limits, Sessions, Daily Window and Auto-Close
Trade Limits
- Max daily loss in % - closes all EA positions and blocks new trading for the rest of the calculated trading day after the threshold is reached. Zero disables it.
- Max drawdown per trade in % - closes an individual EA position when adverse price movement from its open price reaches the configured percentage. This is a price-drawdown calculation, not account-equity risk. Zero disables it.
- Max positions, if 0 = no limit - limits all open positions belonging to the EA magic number.
- Max positions per direction, if 0 = no limit - separately limits BUY and SELL positions.
- Max spread in points, 0 = disabled - blocks new entries when the current Ask-Bid spread exceeds the selected broker-point value. Closing actions remain available.
- Max price deviation in points, 0 = AUTO - sets the allowed market-order price deviation in broker points. Zero lets the EA select an adaptive value automatically.
Fixed UTC Sessions
The three session switches are always evaluated in UTC:
- London (07:00-16:00)
- New York (12:00-22:00)
- Tokyo (22:00-07:00)
At least one selected session must be active when an entry command arrives. The enabled sessions are combined: an entry is allowed when the current UTC time is inside any enabled session and also inside the Daily Trade Window.
NY session: Winter or Summer
NY session: Winter or Summer controls the trading-day reset used by daily-loss calculations and Auto-Close:
- WINTER - reset at 22:00 UTC.
- SUMMER - reset at 21:00 UTC.
This setting does not move the fixed New York (12:00-22:00) session row.
Daily Window Time Mode and Daily Trade Window
Daily Window Time Mode selects which clock is used to evaluate Daily Trade Window:
- UTC - coordinated universal time. This is the default and preserves older EA behavior and existing setup files.
- Broker Time - MT5 trading-server time, the same time basis used in broker trade history.
- Local Time - the Windows clock of the computer or VPS running MT5.
Daily Trade Window uses HH:MM-HH:MM. Example: 01:30-23:30. A range that crosses midnight is valid, for example 23:30-21:30.
For verification, the MT5 Experts log writes the current UTC, Broker and Local timestamps together with the selected window mode in the [SCHEDULE] record. When using Local Time, make sure the Windows/VPS clock and time zone are correct.
Example: A user who wants entries from 01:30 to 23:30 by the clock visible on the Windows desktop should select Local Time and enter 01:30-23:30. No UTC conversion is required.
Auto-Close and entry delay
Auto close: None / End of Day / End of Week controls automatic position closing near the calculated end of the trading day or week. Close positions before market end, minutes defines how early the closing process begins.
Allow new trades after market open, minutes blocks new entries for the selected number of minutes after the calculated market or trading-week open. Zero disables the delay.
If a signal is rejected by a session, Daily Trade Window, spread, entry delay or position limit, the webhook is not necessarily broken. The EA followed the configured Inputs.
Telegram Notifications and Trade Reports from the EA
The EA can use a Telegram bot for two separate purposes: connection notifications and trade reports. These EA-side features are also independent from AlgoWay Telegram notifications configured in the dashboard.
- Telegram notify for AlgoWay disconnect - notifies the selected chat when the EA loses its AlgoWay connection and when the connection is restored.
- Telegram reports for positions and pending orders - reports actual MT5 position and pending-order activity, including trading operations observed by the EA.
- Telegram chat id - destination chat for the messages.
- Telegram bot token - bot token used to send the messages.
Dashboard Telegram notifications and EA Trade Reports serve different purposes: dashboard notifications report incoming alerts received by AlgoWay, while EA Trade Reports report the resulting trading operations in MetaTrader 5. Enabling or disabling one does not enable or disable the other.
Add https://api.telegram.org in MT5 under Tools >> Options >> Expert Advisors >> Allow WebRequest for listed URL before enabling these EA features.
Debug logging: 0 = disabled, 1 = enabled is separate from Telegram. Set it to 1 only when detailed MT5 diagnostics are needed; normal users can leave it at 0.
EA-side Telegram reporting is not the same as using Telegram as a signal source. For Telegram signal copying, use: AI Telegram signal copier in AlgoWay.
Wrapped Values
Some alerts may send wrapped values such as:
{
"platform_name": "metatrader5",
"order_action": "buy",
"ticker": "EURUSD",
"order_contracts": "0.10",
"stop_loss": "stop_loss=100",
"take_profit": "take_profit=200",
"trailing_pips": "trailing_pips=80"
}
Wrapped values should be used only when the current route explicitly supports them. Clean numeric JSON values are easier to debug.
Common Problems and Where to Fix Them
| Problem | Likely layer | Guide |
|---|---|---|
| AlgoWay does not receive the alert | TradingView webhook / JSON | Webhook Error 415 guide |
| EA does not receive commands | Webhook UUID / EA connection | MT5 setup guide |
| MT5 says trading disabled | Algo Trading permission | Error 4752 guide |
| Order is rejected | Broker execution / request parameters | Error 4756 guide |
| Wrong symbol | Symbol mapping | Common MT5 errors guide |
| SL/TP rejected | Stop level, freeze level, points/pips | Risk management guide |
| SL/TP distance is correct but the resulting level is shifted by the spread | SL/TP reference mode | Compare Bid/Ask with Entry Price in the EA Inputs |
| Trade opens outside the expected daily time | Daily Window Time Mode does not match the clock used by the user | Check UTC, Broker Time or Local Time, then verify Daily Trade Window |
| Entry rejected while the market is open | Max spread, session, daily window or position limit | Check the MT5 Experts log for [SPREAD], [SCHEDULE] or [LIMIT] |
Safe Testing Procedure
When setting up a new MT5 automation route, test in layers:
- Confirm that the EA is connected in MT5.
- Confirm Reverse / Hedge / Opposite / Inverse, Position size: Lots / Risk% / Balance%, and Pending orders: Legacy / Reject / Chase.
- Keep Daily Window Time Mode on UTC for an existing configuration, or deliberately select Broker Time or Local Time for a new one.
- Temporarily use Daily Trade Window
00:00-23:59and ensure at least one UTC session is enabled. - Send a simple market order with a very small valid lot.
- Check AlgoWay Webhook Logs and MT5 Experts/Journal logs.
- Test Max spread in points, 0 = disabled with a safe value before enforcing it live.
- Add exact SL/TP prices, then test distance-based SL/TP with the intended PIP type: AUTO/TRADINGVIEW/PERCENT/POINTS/STANDARD.
- If you use distance-based SL/TP, compare Bid/Ask and Entry Price reference modes and confirm the resulting levels in MT5.
- Add trailing stop, breakeven or profit lock one feature at a time.
- Test close/flat logic and partial close only after full close works correctly.
How to Use This v206 Reference
The URL contains v206 because it was created during an earlier documentation cycle. The content has since been updated to match the current AlgoWayWS-MT5 EA 2.20 workflow while preserving the existing address for users who may still have older links or references.
This reference now covers the main topics required for the current MT5 automation workflow:
- TradingView to MT5 EA;
- MT5 webhook EA;
- TradingView alerts to MetaTrader 5;
- MT5 Expert Advisor JSON fields;
- MT5 EA trailing stop automation;
- MetaTrader 5 WebSocket EA;
- AlgoWayWS-MT5 EA guide.
Related AlgoWay Guides
- How to connect TradingView to MetaTrader 5 with AlgoWay EA
- How to install an MT5 Expert Advisor for AlgoWay automation
- AlgoWay JSON schema guide
- Advanced risk management and trade automation
- How AlgoWay handles opposite trading signals
- MetaTrader 5 common errors in AlgoWay
- How to fix MT5 Error 4752
- How to fix MT5 Error 4756
- How to fix AlgoWay webhook Error 415
- AI Telegram signal copier in AlgoWay
Final Summary
AlgoWayWS-MT5 EA 2.20 is the current MT5 execution component for AlgoWay automation. It adds four configurable EA-managed Take Profit stages with pips/percent distances and percent/lots partial-close sizing. It supports Reverse, Hedge, Opposite and Inverse execution, lot/risk/balance sizing, an EA-based fixed lot override for new entries, configurable pending-order handling, broker-compatible filling, five distance modes including STANDARD, Bid/Ask or Entry Price SL/TP reference, fixed or signal-driven SL/TP, trailing, breakeven, profit lock, partial close, symbol mapping, spread and price-deviation controls, position limits, UTC sessions, selectable Daily Trade Window clocks, End-of-Day or End-of-Week Auto-Close, delayed entries after market open, independent Telegram connection notifications and EA Trade Reports, stronger confirmation for closes and SL/TP modifications, and optional debug diagnostics.
If you want to automate TradingView alerts to MetaTrader 5, start with a clean AlgoWay webhook, install the current EA, confirm the WebSocket connection, send valid JSON, test a small market order, and only then enable advanced risk and management features.