Write an automated trading strategy as five specifications: entries, exits, sizing, sessions and exceptions. For every rule, name the input, evaluation time, enforcing layer and evidence that would show it worked. A backtest can model your Pine rules; it does not observe the receiving MT5 account.[1]
Automation executes rules. It does not create a trading edge. A precise specification makes differences easier to diagnose, but delivery failures, account settings and broker conditions still affect execution.

Part 4 of 8 in From discretionary to automated trading. Previous: Measurable conditions. Next: Choose an implementation path.
Where must each rule be enforced?
Assign an owner to each rule before choosing commands. PineConnector messages describe requested actions; EA controls and broker rules still apply even when a parameter specifies its units explicitly.[2] The following map describes responsibilities, not a fixed processing sequence.

- Pine conditions: entries, exits, simulated size and entry-only session gates. The backtest sees these rules. Record the script's explicit timezone and evaluation moment. Pine position state represents the simulation, not the broker account.[1]
- TradingView alert: the trigger, frequency, saved script configuration and notification schedule. These delivery settings are outside the backtest. A schedule can suppress webhook notifications, including exits.[3]
-
PineConnector message: command, exact broker symbol, volume, requested SL/TP and entry filters.
spread=checks the receiving spread on arrival. Neither these checks nor the EA's outcome appear automatically in the Pine simulation.[2] - Portal Tasks: a trading window or scheduled close, using the timezone displayed on the task tile. A trading window is not a close request. Tasks require the documented MT5 EA version and available account controls; confirm Edge availability in Portal or with Support.[4]
- Receiving EA: position scope, repeated entries, reversal handling and account protection. Active hours use broker-server time. Edge uses fixed EA settings, so inspect the configuration under Connections, your account, EA settings before relying on it.[5][6]
- Broker: symbol hours, accepted volume and price increments, orders, deals and resulting positions. A broker-accepted order is not necessarily a fill. A position's recorded SL/TP is different evidence from a simulated stop.[7]
How does the running example become a complete rule sheet?
Illustrative example, not a recommendation: EURUSD H1 London pullbacks, on a USD account. These numbers demonstrate specification choices; they are not suggested trading settings or observed results. Part 3 defines the conditions.
-
Entry: use the selected TradingView EURUSD H1 feed and evaluate once at the confirmed bar close. The bar must have opened from 07:00 through 10:00 inclusive in
Europe/London, giving evaluation times from 08:00 through 11:00. EMA(50) is above EMA(200) and above its value five bars earlier. At least one of the last three closed bars has a low at or below that bar's EMA(50). The current close is above EMA(50) and the previous bar's high. - Repeated-entry policy: at most one entry request per London calendar day in the script, and no additional simulated long while one is open. The broker-side intention is also one strategy long at a time. Treat a request with an unresolved outcome as pending investigation, not permission to send another.
- Exit: request the stop at the lowest low of the last five closed bars minus 0.0002, equivalent to two EURUSD pips in this example. Target = signal close + 2 × (signal close − stop). These are requested price levels referenced to the signal close, not the later fill.
-
Size: plan about US$100 of loss at the stop on this USD account using
vol_dollar=100andsl_price=. The parameter is in account currency, despite its name. Costs, gaps, slippage and broker constraints can change the actual loss.[2] - Session exit: at the close of the H1 bar opened at 15:00 London time, request a close at 16:00. Delivery, processing and closure happen after the request. Confirm the broker position is closed; this specification does not establish being flat by 16:00.
-
Exceptions: check
spread=2at the receiving account; a spread above two PineConnector pips fails that entry filter. Keep the news decision as a logged manual veto. No news filter is established by the cited PineConnector documentation; identify the calendar and veto procedure separately.
The one-position rule needs two checks. strategy.position_size can limit the simulated strategy. It cannot prove there is no MT5 position, even if messages use comment=LDN-PB. Reconcile actual positions and outstanding requests before re-enabling entries after a discrepancy. A broker-side gate must inspect actual account state; the supplied Pine specification and label do not implement that gate.
EA Pyramiding and position limits can add receiving-side controls, but per-comment counting is not documented. On an MT5 netting account, one common position represents a symbol; labels do not create separate strategy positions. Check account mode, Magic Restriction and actual closure scope on demo.[5][7]
What do the illustrative messages mean?
Destination: TradingView alert, Message field, for a demo setup after completing Part 7. The following are templates, not ready-to-send messages. Replace LicenseID with the complete Portal value and EURUSD with the exact broker symbol. Substitute calculated numeric prices for <stop> and <target>; do not paste the angle-bracket placeholders.
Entry request:
LicenseID,buy,EURUSD,vol_dollar=100,sl_price=<stop>,tp_price=<target>,spread=2,comment=LDN-PB
Session-close request:
LicenseID,closelong,EURUSD,comment=LDN-PB
The current guide documents symbol-and-comment filtering for closelong, closeshort, cancellong and cancelshort, from MT5 EA v2.095. The close template requests matching EURUSD buys within the receiving EA's scope. Verify the installed version and actual account mode. Do not extend this rule to partial closes or account-wide commands.[8]
A License ID can reach multiple connected accounts; a comment does not restrict recipients. If Signal Authentication is enabled, include the configured secret= privately in both entry and closing messages. Do not put broker credentials into an alert.[2][6]
How do sizing and protection differ from the backtest?
Choose one entry-volume method and at most one stop and target method. vol_lots= requests lots; vol_dollar= sizes a planned account-currency loss at a supplied stop. Margin allocation is not a loss budget. An omitted value depends on the receiving EA settings; it does not mean zero.[2]
{{strategy.order.contracts}} describes TradingView's simulated order quantity. It is not automatically MT5 lots, cash risk or a percentage. Establish the instrument-specific conversion and verify the broker volume before using that placeholder. Check volume minimum, maximum and step; the FAQ describes nearest-step rounding, while the syntax reference does not specify a rounding direction. Verify the requested and accepted volume on your installed EA.[9][10]
A Pine stop remains simulated unless your execution path separately requests broker protection. Check the resulting broker SL/TP after entry. A broker stop may close a position while Pine still shows it open. Shadow Targets instead rely on EA monitoring for the intended level. Neither an alert log nor a simulated exit proves that broker exposure ended.[5][7]
Specify exit intent explicitly: sell requests a short entry; it is not a universal instruction to close a long. Partial closes use their own documented quantities and scope. Breakeven does not remove costs, and terminal-managed trailing or shadow controls need separate availability checks. Keep this example to its stated stop, target and session close.
Which session control leaves exits available?
Decide whether the window restricts entries only or all signal processing. If exits must remain available after the entry window, implement an entry-only condition and keep the delivery path available. Check every downstream control as well.
| Window | Clock | Exit implication |
|---|---|---|
| Pine entry condition | Explicit script timezone | Can leave the exit condition independent |
| TradingView notification schedule | Schedule timezone | Suppresses webhook notifications outside it |
| Portal Trading Time Limit | Task tile timezone | Signals halted; exit exemption not documented |
| EA Active hours | Broker-server time | Outside signals ignored; exit exemption not documented |
| Scheduled eaoff/eaon | Sending scheduler's clock | Incoming processing halted; exit exemption not documented |
TradingView recommends keeping notifications available throughout the day for automated trading. Portal's Trading Time Limit has an exclusive end time and does not close positions. Do not assume halted signals queue for later. Confirm these cases on demo before depending on an exit outside a window.[3][4][5]
Core includes Close All Trades and Trading Time Limit with email. Plus and Pro also include Signal Error and Connection Lost notifications. The Tasks guide specifies MT5 EA v3.45 or later; plan entitlement alone does not establish Edge task availability. Inspect Portal. PineConnector Edge hosts MT5 with the PineConnector EA, whose fixed configuration is a design constraint, not an editable copy of your local settings.[4][6]
What goes in the strategy-to-rules worksheet?
Copy these five rows into your own working document. For each row, record plain-language rule; measurable condition; input and clock; enforcing layer; requested action; demo acceptance evidence. A row is incomplete until someone else can explain both the action and its failure case.
- Entry: ______. State versus event: ______. Evaluation time: ______. Repeated requests and unresolved-outcome policy: ______. Done when an eligible and an ineligible demo case each match the specification.
- Exit: ______. Broker SL/TP versus signal-driven request: ______. Exact position scope: ______. Done when the intended positions and pending orders are accounted for after each exit path, including a request outside entry hours.
- Size: ______. Currency and units: ______. Stop dependency: ______. Broker min/max/step: ______. Done when the message, EA calculation and broker volume are reconciled without an unexplained unit conversion.
- Session: ______. Timezone and daylight-saving rule: ______. Inclusive/exclusive boundaries: ______. Done when before-boundary, at-boundary and after-boundary cases agree, with exits checked separately.
- Exceptions: ______. Trigger, action, responsible person and resume condition: ______. Done when a controlled demo failure is classified and resolved without blindly repeating an uncertain order request.
Add an exception row for a rejected request, lost connection, duplicate source, changed script, manual veto and account-limit event. Distinguish a Pine simulated-equity limit from EA account protection and from any broker or firm's rules; the calculations and reset times can differ.[5] A script edit also requires a new alert snapshot before verification.[11]
What can this specification not establish?
The example is an illustrative design, not compiled Pine code or an implemented broker-state gate. No account test was performed. A complete worksheet cannot establish profitability, delivery, available liquidity or maximum realised loss. Undocumented halt, partial-close and Edge-control behaviour must remain a demo acceptance question, not a promised capability.
What is the next step?
Use your completed worksheet to choose no-code alerts, Pine Script or an MT5 Expert Advisor. Then verify the selected path with the per-signal demo checklist.
Reviewed 23 September 2026 against primary documentation captured on that date. Nothing was tested on a trading account, and no Pine Script or MQL5 code was compiled.
Related reading
- From discretionary to automated trading
- Turn setups into measurable conditions
- Choose an implementation path
- Notification schedules and webhooks
Sources
- TradingView – Strategies, accessed 23 September 2026.
- PineConnector – Syntax, accessed 23 September 2026.
- TradingView – Notification schedule for alerts, accessed 23 September 2026.
- PineConnector – Tasks, accessed 23 September 2026.
- PineConnector – EA settings, accessed 23 September 2026.
- PineConnector – Edge, accessed 23 September 2026.
- MetaQuotes – Orders, deals and positions, accessed 23 September 2026.
- PineConnector – Multiple strategies, accessed 23 September 2026.
- PineConnector – No-code alerts, accessed 23 September 2026.
- PineConnector – FAQ, accessed 23 September 2026.
- TradingView – Alerts FAQ, accessed 23 September 2026.
PineConnector executes the instructions you send it. It does not select trades, manage money, or hold funds. Trading carries risk, and past performance of any strategy does not indicate future results.