<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: AlgoHand</title>
    <description>The latest articles on DEV Community by AlgoHand (@algohand).</description>
    <link>https://dev.to/algohand</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4268974%2Fb4ca8f57-48fd-4074-b7ba-abc2002df364.png</url>
      <title>DEV Community: AlgoHand</title>
      <link>https://dev.to/algohand</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/algohand"/>
    <language>en</language>
    <item>
      <title>Why MetaTrader reports disagree about profit and drawdown</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:59:58 +0000</pubDate>
      <link>https://dev.to/algohand/why-metatrader-reports-disagree-about-profit-and-drawdown-3oh6</link>
      <guid>https://dev.to/algohand/why-metatrader-reports-disagree-about-profit-and-drawdown-3oh6</guid>
      <description>&lt;p&gt;An account balance fell by 12, yet the trading report shows a profit of 88. Both numbers can be correct.&lt;/p&gt;

&lt;p&gt;The first measures the change in money recorded as balance. The second measures trading postings during a chosen period. Deposits, withdrawals, fees, open positions and missing history can make the two diverge. A reporting interface has to explain the basis of a number before comparing it with another number.&lt;/p&gt;

&lt;p&gt;Here is how to make that comparison when reading MT4 or MT5 reports through AlgoHand.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reconcile money movements before comparing returns
&lt;/h2&gt;

&lt;p&gt;Consider this fictional account, with no credit or other adjustments:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Posting&lt;/th&gt;
&lt;th&gt;Amount&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Opening balance&lt;/td&gt;
&lt;td&gt;1,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Deposit&lt;/td&gt;
&lt;td&gt;+200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Withdrawal&lt;/td&gt;
&lt;td&gt;-300&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Entry commission&lt;/td&gt;
&lt;td&gt;-6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Closing trade profit&lt;/td&gt;
&lt;td&gt;+100&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Swap booked at close&lt;/td&gt;
&lt;td&gt;-4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fee booked at close&lt;/td&gt;
&lt;td&gt;-2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Closing balance&lt;/td&gt;
&lt;td&gt;988&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The net trading result is &lt;code&gt;100 - 6 - 4 - 2 = 88&lt;/code&gt;. External cash flow is &lt;code&gt;200 - 300 = -100&lt;/code&gt;. The resulting balance change is &lt;code&gt;88 - 100 = -12&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If the same simplified account also has floating P&amp;amp;L of -40, its equity is 948 at that observation. The open loss is relevant to current equity, but it is not another closed trading posting in the table.&lt;/p&gt;

&lt;p&gt;AlgoHand separates booked trading P&amp;amp;L from cash flow and other balance changes. Credit is reported separately from balance. Do not add a broker's credit change to a reconstructed balance merely because it increased available account resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choose the posting period deliberately
&lt;/h2&gt;

&lt;p&gt;Suppose the -6 entry commission was booked on Monday and the remaining +94 was booked on Tuesday. A Monday report shows the entry cost. A Tuesday report shows the closing postings. A report covering both days shows +88.&lt;/p&gt;

&lt;p&gt;The API's booked P&amp;amp;L uses the requested half-open time interval, &lt;code&gt;[from, to)&lt;/code&gt;. This lets adjacent periods meet at a boundary without counting a posting twice. It also means a report for “trades closed Tuesday” is not necessarily the same calculation as “all money booked Tuesday.”&lt;/p&gt;

&lt;p&gt;Closing-deal statistics need their own label. A partial close can produce more than one closing deal for a position. Win rate, average close and profit factor computed from closing rows are not automatically complete round-trip position statistics, and earlier entry costs may sit outside those rows.&lt;/p&gt;

&lt;p&gt;For per-EA reports, inspect attribution as well. A separate broker charge may be account-level rather than reliably attributable to a particular EA. Assigning it to whichever EA was recently active would produce a cleaner-looking chart with a less defensible result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ask which drawdown is being measured
&lt;/h2&gt;

&lt;p&gt;There are several useful questions behind the word drawdown:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Basis&lt;/th&gt;
&lt;th&gt;What can lower the curve&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Raw balance&lt;/td&gt;
&lt;td&gt;Trading postings, withdrawals and other balance adjustments&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observed equity&lt;/td&gt;
&lt;td&gt;Floating losses, booked results and cash flows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cumulative booked trading P&amp;amp;L&lt;/td&gt;
&lt;td&gt;Trading profit and costs included in that series&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A withdrawal can create a drop in raw balance without being a trading loss. Conversely, a position can suffer a large floating loss and later close near break-even, leaving little evidence of that intratrade loss in closed history.&lt;/p&gt;

&lt;p&gt;AlgoHand labels these bases in its reports. Its grouped P&amp;amp;L drawdown is a money drawdown on cumulative booked trading P&amp;amp;L, not a percentage drawdown of the whole account's equity.&lt;/p&gt;

&lt;p&gt;Sampling adds another limit. If equity observations are 1,000 and 960, the observed drop is 40. Equity might have reached 900 between those samples. Without an intervening observation, the report cannot claim to have measured that deeper drop.&lt;/p&gt;

&lt;p&gt;The current sampled-equity path is approximately minute-based, with a 90-day retention policy. Read the actual returned bounds and sample gaps; a retention policy does not prove every minute was captured.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check whether the requested history exists
&lt;/h2&gt;

&lt;p&gt;MT4's &lt;code&gt;OrdersHistoryTotal&lt;/code&gt; operates on history loaded in the terminal, and the Account History selection affects the available list. Scanning that list successfully is not proof that the broker's complete lifetime history was available. &lt;a href="https://docs.mql4.com/trading/ordershistorytotal" rel="noopener noreferrer"&gt;MQL4 history reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AlgoHand incrementally retains MT4 history it has learned, so a narrower later terminal filter need not erase already collected rows. That cache still cannot invent trades it never received. MT5 has a different history-reading mechanism, but a recent account heartbeat alone does not prove all older deals have synchronized there either.&lt;/p&gt;

&lt;p&gt;The reporting API exposes &lt;code&gt;coverage&lt;/code&gt; alongside the numbers. Inspect the stored bounds, observed bounds for the request, &lt;code&gt;window_overlap&lt;/code&gt;, sample gaps where applicable and &lt;code&gt;complete&lt;/code&gt;. In the current implementation, &lt;code&gt;complete: null&lt;/code&gt; means completeness has not been established. Even &lt;code&gt;window_overlap: "full"&lt;/code&gt; describes overlap with the stored time envelope, not proof that no records are missing inside it.&lt;/p&gt;

&lt;p&gt;Unknown financial values should stay unknown. Replacing &lt;code&gt;null&lt;/code&gt; with zero turns “we do not have the data” into “there was no loss.”&lt;/p&gt;

&lt;h2&gt;
  
  
  Compare like with like
&lt;/h2&gt;

&lt;p&gt;Before calling a difference a reporting bug, align:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The platform, login and broker server.&lt;/li&gt;
&lt;li&gt;The period boundaries and timezone interpretation.&lt;/li&gt;
&lt;li&gt;Closed postings versus open-position P&amp;amp;L.&lt;/li&gt;
&lt;li&gt;Entry costs, exit costs and separate account charges.&lt;/li&gt;
&lt;li&gt;Cash flows and credit handling.&lt;/li&gt;
&lt;li&gt;Stored-history coverage and equity-sampling gaps.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;AlgoHand labels its report timestamps UTC, but historical broker offsets and older imported data can require inspection. Do not shift a whole dataset by today's broker offset without evidence about the original timestamps.&lt;/p&gt;

&lt;p&gt;The relevant &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;AlgoHand API resources&lt;/a&gt; are account history, equity and P&amp;amp;L. Keep their coverage and metric descriptions next to the displayed result. That makes a discrepancy something an operator can investigate, instead of a contest between two unexplained totals.&lt;/p&gt;

</description>
      <category>api</category>
      <category>testing</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Verifying remote MetaTrader commands after confirmation</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:59:47 +0000</pubDate>
      <link>https://dev.to/algohand/verifying-remote-metatrader-commands-after-confirmation-31pa</link>
      <guid>https://dev.to/algohand/verifying-remote-metatrader-commands-after-confirmation-31pa</guid>
      <description>&lt;p&gt;A customer presses Apply. The API returns a command ID. A few seconds later, their connection drops.&lt;/p&gt;

&lt;p&gt;At that point, a controller has to answer two different questions: did the server accept the request, and did MetaTrader finish the change? Treating either question as the other can produce a misleading success message or a duplicate attempt.&lt;/p&gt;

&lt;p&gt;AlgoHand exposes the request, resolved plan and observed result separately. A reliable integration keeps those distinctions visible all the way to the user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preserve the approved action
&lt;/h2&gt;

&lt;p&gt;For an input change, obtain a preview with &lt;code&gt;dry_run: true&lt;/code&gt;. Show the exact account, EA instance, changed values and warnings. Store the approved action in the application backend along with its &lt;code&gt;preview_hash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;On confirmation, submit that action with &lt;code&gt;dry_run: false&lt;/code&gt; and the hash as &lt;code&gt;expected_preview_hash&lt;/code&gt;. If the resolved plan changed, the server can return &lt;code&gt;PREVIEW_STALE&lt;/code&gt; instead of queuing the new version. The user should review a fresh preview.&lt;/p&gt;

&lt;p&gt;The hash checks the plan; it does not prove that a person approved it. A custom interface must enforce its own confirmation flow. This matters because raw REST commands default to execution when &lt;code&gt;dry_run&lt;/code&gt; is omitted. Preview-first behaviour in a chat tool is not a property every API caller automatically inherits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Save the receipt before updating the interface
&lt;/h2&gt;

&lt;p&gt;HTTP 202 means accepted. Save the returned &lt;code&gt;command_id&lt;/code&gt; and continue observing it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="na"&gt;GET /v1/commands/cmd_example?wait&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;CLIENT_API_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The example uses a fictional ID and a client-scoped key. A long-poll can return because an outcome is available or because its wait elapsed. HTTP 200 alone does not indicate command success; read the body's &lt;code&gt;status&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Status&lt;/th&gt;
&lt;th&gt;What the interface should communicate&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;queued&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Waiting for execution&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;dispatched&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delivered for agent handling&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;running&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Work or verification is still in progress&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;succeeded&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The command's required result checks passed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;unconfirmed&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The EA change was applied, but initialization lacks confirmation; inspect before another change&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;failed&lt;/code&gt;, &lt;code&gt;rejected&lt;/code&gt;, &lt;code&gt;expired&lt;/code&gt;, &lt;code&gt;cancelled&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Read the error, timeline and observed result; these labels are not interchangeable rollback guarantees&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Display &lt;code&gt;summary&lt;/code&gt;, relevant &lt;code&gt;result.observed&lt;/code&gt; fields and the error's explanation. The operation determines what evidence is required. A successful screenshot and a successful EA start do not have the same verification contract.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate input readback from initialization
&lt;/h2&gt;

&lt;p&gt;For a settings operation, reading back the intended values answers whether those values are visible in the terminal. It does not alone establish that the EA initialized successfully or that its trading logic will work as intended.&lt;/p&gt;

&lt;p&gt;MetaTrader calls an EA's initialization handler when loading it; MQL5's &lt;code&gt;OnInit&lt;/code&gt; can report failure. That is why a chart name or a requested template is insufficient evidence by itself. &lt;a href="https://www.mql5.com/en/docs/event_handlers/oninit" rel="noopener noreferrer"&gt;MQL5 OnInit reference&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AlgoHand can report &lt;code&gt;unconfirmed&lt;/code&gt; when an applied change lacks initialization confirmation after the verification period. The current command reference specifies 15 minutes. Present that as an applied change requiring inspection, and keep the receipt available. Do not silently turn it into either success or an automatic second application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changing inputs reinitializes the EA. If it has open trades, check the author's guidance on changing settings while trading.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Retry the delivery without inventing a new action
&lt;/h2&gt;

&lt;p&gt;Persist an &lt;code&gt;Idempotency-Key&lt;/code&gt; before sending an execution request. If the response is lost, reuse the same key and exact action to recover the existing receipt while it is retained by the server. A different body or account with that key is a conflict.&lt;/p&gt;

&lt;p&gt;This protects one API operation from repeated submission. It is not a general guarantee of exactly-once behaviour across every failure of Windows, the terminal and the network. Do not rotate the key merely because the first request took longer than expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lost HTTP response
    |
    +-- known command ID -&amp;gt; read that command
    |
    +-- no command ID -&amp;gt; retry exact delivery with its saved idempotency key

Unclear terminal outcome -&amp;gt; inspect receipt and current state
                         -&amp;gt; do not create a fresh application automatically
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cancellation needs the same care. Requesting cancellation does not reverse an input change already applied inside MetaTrader. Read the cancellation response and the current command state rather than treating a Cancel button as an undo operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expect evidence to arrive late
&lt;/h2&gt;

&lt;p&gt;A timeout means the expected evidence did not arrive within a deadline. It does not prove that nothing happened. A later result may clarify a command's outcome, so refresh its current record before deciding on a recovery action.&lt;/p&gt;

&lt;p&gt;Webhook consumers should also tolerate repeated and out-of-order events. Deduplicate by event ID, correlate by command ID and consult the current command record when a delayed event conflicts with what the interface already knows. An arrival timestamp is not the execution order.&lt;/p&gt;

&lt;p&gt;For support, retain the command ID, target identity, approved diff, timestamps and result. That is enough to investigate a particular operation without teaching users to press Apply repeatedly until the UI changes.&lt;/p&gt;

&lt;p&gt;The complete request and outcome fields are in the &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;AlgoHand command API&lt;/a&gt;, including the &lt;a href="https://algohand.com/docs/openapi.yaml" rel="noopener noreferrer"&gt;OpenAPI schema&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>api</category>
      <category>architecture</category>
      <category>testing</category>
      <category>automation</category>
    </item>
    <item>
      <title>Running multiple MT4 and MT5 terminals on one Windows VPS</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:53:31 +0000</pubDate>
      <link>https://dev.to/algohand/running-multiple-mt4-and-mt5-terminals-on-one-windows-vps-19kc</link>
      <guid>https://dev.to/algohand/running-multiple-mt4-and-mt5-terminals-on-one-windows-vps-19kc</guid>
      <description>&lt;p&gt;Two MetaTrader windows can look almost identical while using different account databases, chart profiles and EA folders. Add another Windows user, a tester copy and an old shortcut, and “the terminal on my VPS” stops being a precise target.&lt;/p&gt;

&lt;p&gt;For an AlgoHand installation, the useful starting point is an inventory connecting each broker account to its executable, data directory and Windows session. Reinstalling the agent before establishing that mapping can preserve the same ambiguity under a new registration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give each terminal an identity beyond its window title
&lt;/h2&gt;

&lt;p&gt;For two fictional demo terminals, write down a table like this:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Item&lt;/th&gt;
&lt;th&gt;MT4 demo&lt;/th&gt;
&lt;th&gt;MT5 demo&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Windows user&lt;/td&gt;
&lt;td&gt;TradingUser&lt;/td&gt;
&lt;td&gt;TradingUser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Installation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;C:\Trading\MT4-Demo&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;C:\Trading\MT5-Demo&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Executable&lt;/td&gt;
&lt;td&gt;&lt;code&gt;terminal.exe&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;terminal64.exe&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Broker identity&lt;/td&gt;
&lt;td&gt;DemoBroker-A plus its login&lt;/td&gt;
&lt;td&gt;DemoBroker-B plus its login&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data directory&lt;/td&gt;
&lt;td&gt;From File → Open Data Folder&lt;/td&gt;
&lt;td&gt;From File → Open Data Folder&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AlgoHand identity&lt;/td&gt;
&lt;td&gt;Returned &lt;code&gt;account_id&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Returned &lt;code&gt;account_id&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The login and broker server belong together. A login number alone does not identify an account across every broker. Likewise, the executable path alone does not prove which account is connected now. Confirm the broker identity from a fresh terminal/manager report after any login change.&lt;/p&gt;

&lt;p&gt;A PID helps identify a running process, but Windows can reuse it. Operational tools that later act on a process need additional identity checks, such as its executable and creation time. The inventory below is for inspection only.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate the installation and data paths
&lt;/h2&gt;

&lt;p&gt;In MT5's normal mode, editable terminal data lives under the Windows user's profile. MetaQuotes documents that the data directory differs by Windows account and that &lt;code&gt;origin.txt&lt;/code&gt; relates it to an installation. Use &lt;strong&gt;File → Open Data Folder&lt;/strong&gt; in the actual terminal to inspect it. &lt;a href="https://www.metatrader5.com/en/terminal/help/start_advanced/start" rel="noopener noreferrer"&gt;MT5 startup and data-directory documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Portable mode changes that arrangement by keeping data with the installation. It is a deployment choice, not a generic repair step. Adding &lt;code&gt;/portable&lt;/code&gt; to an existing shortcut can make the terminal open a different set of local data instead of the profile the operator was using.&lt;/p&gt;

&lt;p&gt;Choose the mode when provisioning a new isolated installation. For an existing setup, preserve its current mode until you have recorded and backed up the relevant configuration. Do not copy an active terminal's entire directory into a new location and assume account credentials, licensing and profiles will migrate correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspect processes without stopping them
&lt;/h2&gt;

&lt;p&gt;This PowerShell command lists candidate MT4 and MT5 processes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nc"&gt;Get&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;CimInstance&lt;/span&gt; &lt;span class="nc"&gt;Win32_Process&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Where&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nv"&gt;$_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; @&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'terminal.exe'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'terminal64.exe'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;
    &lt;span class="nc"&gt;Select&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Object&lt;/span&gt; &lt;span class="nc"&gt;ProcessId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SessionId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;CreationDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ExecutablePath&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It does not print command-line arguments, which can contain private connection settings. Some fields can be unavailable without permission to inspect the process. An empty field is not evidence that the process is safe to remove.&lt;/p&gt;

&lt;p&gt;Use Task Manager's &lt;strong&gt;Users&lt;/strong&gt; and &lt;strong&gt;Details&lt;/strong&gt; views to correlate the session IDs with their Windows users. Identify tester copies separately. A temporary Strategy Tester process is not another customer account that should automatically be enrolled for ordinary management.&lt;/p&gt;

&lt;p&gt;Do not resolve a duplicate-looking list with a blanket &lt;code&gt;Stop-Process terminal*&lt;/code&gt; command. Another Windows session may belong to somebody actively trading or testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Align discovery with the intended terminals
&lt;/h2&gt;

&lt;p&gt;AlgoHand discovers terminal processes and their data directories. Discovery is not simply “manage whichever MetaTrader window is in front.” On a shared machine, another user's terminal can be relevant to the inventory even when it is invisible in the current RDP session.&lt;/p&gt;

&lt;p&gt;The installation should therefore have an agreed operating Windows user and an explicit set of intended terminals. Compare that set with the agent's configured paths and newly discovered entries. Ambiguous data-directory matches need investigation; creating another VPS registration does not resolve which files belong to which process.&lt;/p&gt;

&lt;p&gt;MT4 and MT5 also host their management components differently. MT5 normally uses a manager service. MT4 uses a manager EA on a dedicated chart. That manager chart is infrastructure: do not remove it while tidying up customer charts. The two platforms share the customer API, but a service check for MT5 is not a complete MT4 readiness check.&lt;/p&gt;

&lt;h2&gt;
  
  
  Validate the mapping before issuing commands
&lt;/h2&gt;

&lt;p&gt;In AlgoHand, check each account's platform, broker server, login, VPS association, reported paths and observation time. Confirm that the expected manager is reporting. Show AutoTrading separately: OFF is an intentional switch state, not by itself a connection failure.&lt;/p&gt;

&lt;p&gt;For the API, &lt;code&gt;GET /v1/clients/{client_id}/state&lt;/code&gt; supplies this mapping. The compatibility fields &lt;code&gt;mt5_login&lt;/code&gt; and &lt;code&gt;mt5_server&lt;/code&gt; are used for both platforms; &lt;code&gt;terminal.platform&lt;/code&gt; distinguishes them. Use the returned &lt;code&gt;account_id&lt;/code&gt; for commands, then identify the particular EA through &lt;code&gt;instance_id&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For a new installation, a useful acceptance check is:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Both intended broker accounts appear with fresh observations.&lt;/li&gt;
&lt;li&gt;The installation and data paths match the inventory.&lt;/li&gt;
&lt;li&gt;Each manager reports from the intended terminal.&lt;/li&gt;
&lt;li&gt;The current AutoTrading setting matches the operator's choice.&lt;/li&gt;
&lt;li&gt;No unexpected old or tester terminal has been adopted into that working set.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Test the Windows lifecycle separately
&lt;/h2&gt;

&lt;p&gt;Closing RDP, logging out and rebooting Windows are different events. A disconnected session can remain active, subject to Windows session policies; logging out ends that user's session. Microsoft documents &lt;a href="https://learn.microsoft.com/windows-server/remote/remote-desktop-services/clients/windows" rel="noopener noreferrer"&gt;how disconnecting differs from leaving an active remote session&lt;/a&gt;. Scheduled tasks must start the agent and terminals in the intended context after the relevant lifecycle event.&lt;/p&gt;

&lt;p&gt;Test this on a dedicated demo setup. Observe what starts automatically after a fresh Windows sign-in before manually launching anything. Then check the same account identities and paths again. A manually repaired desktop is not evidence that unattended startup worked.&lt;/p&gt;

&lt;p&gt;When an account is wrong, start with its process and data mapping. When an account is stale, investigate reporting as well. Keeping those two questions separate usually produces a more useful diagnosis than another installation attempt.&lt;/p&gt;

&lt;p&gt;The shared account fields are documented in the &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;AlgoHand API reference&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>tutorial</category>
      <category>automation</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Build a MetaTrader monitoring dashboard with Python and AlgoHand</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:52:49 +0000</pubDate>
      <link>https://dev.to/algohand/build-a-metatrader-monitoring-dashboard-with-python-and-algohand-1130</link>
      <guid>https://dev.to/algohand/build-a-metatrader-monitoring-dashboard-with-python-and-algohand-1130</guid>
      <description>&lt;p&gt;A hosting panel does not need a Start button to be useful. A small table showing which terminal last reported, which broker server it uses and whether AutoTrading is on can answer the first few support questions before anybody opens RDP.&lt;/p&gt;

&lt;p&gt;This example reads AlgoHand's account state and writes a local HTML dashboard. It works with the common MT4/MT5 account API, uses Python's standard library and sends one GET request. It does not submit commands.&lt;/p&gt;

&lt;p&gt;The output is deliberately a snapshot. Its generation time and each account's observation time stay visible, so a page left open overnight does not pretend to be a live monitor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Request only the state you need
&lt;/h2&gt;

&lt;p&gt;The endpoint is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="na"&gt;GET /v1/clients/{client_id}/state?include&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;vps&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;accounts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="n"&gt;instances&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;CLIENT_API_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use an authorized client API credential and its &lt;code&gt;client_id&lt;/code&gt;, not the customer's email address or broker login. Keep the key in the Python process or application backend. A client-scoped key limits the customer scope; it is not necessarily a read-only credential. This script is read-only because it only performs GET. Never put the key in the generated HTML or browser JavaScript.&lt;/p&gt;

&lt;p&gt;The response contains &lt;code&gt;vps&lt;/code&gt; and &lt;code&gt;accounts&lt;/code&gt; arrays. Each account includes its &lt;code&gt;account_id&lt;/code&gt;, &lt;code&gt;vps_id&lt;/code&gt;, &lt;code&gt;terminal&lt;/code&gt;, &lt;code&gt;as_of&lt;/code&gt;, &lt;code&gt;stale&lt;/code&gt; and requested &lt;code&gt;instances&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Some names are historical: &lt;code&gt;mt5_server&lt;/code&gt; identifies the broker server on both platforms. Read &lt;code&gt;terminal.platform&lt;/code&gt; to distinguish MT4 from MT5.&lt;/p&gt;

&lt;h2&gt;
  
  
  Check freshness at the account level
&lt;/h2&gt;

&lt;p&gt;Suppose one VPS reports every few seconds while a second VPS stops reporting. The client's top-level timestamp can still be recent because it represents the latest observation across its resources. That does not make the second terminal's stored state current.&lt;/p&gt;

&lt;p&gt;The example requires a fresh account timestamp, &lt;code&gt;stale: false&lt;/code&gt;, an online associated VPS and a recent VPS heartbeat. Missing or implausibly future timestamps produce unknown state. The extra 120-second threshold is this dashboard's display policy, not a replacement for the server's command safety checks.&lt;/p&gt;

&lt;p&gt;AutoTrading has its own column. A fresh, healthy terminal can legitimately have AutoTrading OFF. Conversely, an old stored ON value should not be presented as its current switch state.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create the snapshot
&lt;/h2&gt;

&lt;p&gt;Save the following as &lt;code&gt;monitor.py&lt;/code&gt;. Run it with Python 3.10 or later using &lt;code&gt;python monitor.py&lt;/code&gt;, enter the client ID and paste the API key at the hidden prompt. Alternatively, supply &lt;code&gt;ALGOHAND_API_KEY&lt;/code&gt; through your existing secret-management setup. Open the resulting &lt;code&gt;monitor.html&lt;/code&gt; locally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="s2"&gt;"""Local HTML snapshot using AlgoHand's authenticated GET state endpoint."""&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;getpass&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timezone&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pathlib&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;quote&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;urllib&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;HTTPRedirectHandler&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;build_opener&lt;/span&gt;

&lt;span class="no"&gt;MAX_BYTES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2_000_000&lt;/span&gt;
&lt;span class="no"&gt;MAX_AGE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;120&lt;/span&gt;  &lt;span class="c1"&gt;# Local display policy, not the server's command safety limit.&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;NoRedirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;HTTPRedirectHandler&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;redirect_request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fp&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;msg&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;newurl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;HTTPError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Redirect refused"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fetch_state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://api.algohand.com/v1/clients/"&lt;/span&gt;
           &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;quote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;safe&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"/state?include=vps,accounts,instances"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;req&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"Authorization"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bearer "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                                &lt;span class="s2"&gt;"Accept"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"GET"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;build_opener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;NoRedirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;MAX_BYTES&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="no"&gt;MAX_BYTES&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Response too large"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"client_id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt;
            &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"accounts"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"vps"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Unexpected state response"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;stamp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromisoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Z"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"+00:00"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;stamp&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;total_seconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;age&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="no"&gt;MAX_AGE&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;AttributeError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;TypeError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;OverflowError&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;html&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;escape&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"unknown"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;vps_by_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"vps_id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"vps"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"accounts"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;terminal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"terminal"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;vps&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vps_by_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"vps_id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"stale"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
                   &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"as_of"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                   &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="n"&gt;vps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"online"&lt;/span&gt;
                   &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nf"&gt;recent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vps&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"last_seen"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;health&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"unknown / stale"&lt;/span&gt;
        &lt;span class="n"&gt;switch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;terminal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"trade_allowed"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
        &lt;span class="n"&gt;autotrading&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ON"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;switch&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"OFF"&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;switch&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"unknown"&lt;/span&gt;
        &lt;span class="n"&gt;instances&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"instances"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instances&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="nb"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instances&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;list&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;
        &lt;span class="n"&gt;values&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"account_id"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;terminal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"platform"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"mt5_server"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;health&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;autotrading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;terminal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                  &lt;span class="n"&gt;account&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"as_of"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;tr&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;td&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/td&amp;gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;values&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/tr&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Refresh failed. Current account state is unknown."&lt;/span&gt;
               &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="s2"&gt;"Snapshot only. Run the script again to fetch a new observation."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s2"&gt;" No accounts were returned; check the selected client and agent setup."&lt;/span&gt;
    &lt;span class="n"&gt;headings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Account ID"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Platform"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Broker server"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Reported health"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                &lt;span class="s2"&gt;"AutoTrading"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Build"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Active instance records"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"Account observation UTC"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;!doctype html&amp;gt;&amp;lt;html lang='en'&amp;gt;&amp;lt;meta charset='utf-8'&amp;gt;"&lt;/span&gt;
            &lt;span class="s2"&gt;"&amp;lt;meta name='viewport' content='width=device-width, initial-scale=1'&amp;gt;"&lt;/span&gt;
            &lt;span class="s2"&gt;"&amp;lt;title&amp;gt;AlgoHand terminal snapshot&amp;lt;/title&amp;gt;&amp;lt;style&amp;gt;"&lt;/span&gt;
            &lt;span class="s2"&gt;"body{font:15px system-ui;margin:2rem;color:#172033;background:#f5f7fb}"&lt;/span&gt;
            &lt;span class="s2"&gt;"section{overflow:auto}table{border-collapse:collapse;background:white;width:100%}"&lt;/span&gt;
            &lt;span class="s2"&gt;"th,td{padding:.7rem;text-align:left;border:1px solid #ccd3df}"&lt;/span&gt;
            &lt;span class="s2"&gt;"th{background:#e8eef8}p{max-width:70ch}&amp;lt;/style&amp;gt;&amp;lt;body&amp;gt;"&lt;/span&gt;
            &lt;span class="s2"&gt;"&amp;lt;h1&amp;gt;MetaTrader terminal snapshot&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;Generated UTC: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nf"&gt;cell&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isoformat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/p&amp;gt;&amp;lt;p&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/p&amp;gt;&amp;lt;section&amp;gt;&amp;lt;table&amp;gt;&amp;lt;thead&amp;gt;&amp;lt;tr&amp;gt;"&lt;/span&gt;
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;lt;th&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/th&amp;gt;"&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;h&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;headings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/tr&amp;gt;&amp;lt;/thead&amp;gt;&amp;lt;tbody&amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;/tbody&amp;gt;&amp;lt;/table&amp;gt;&amp;lt;/section&amp;gt;"&lt;/span&gt;
            &lt;span class="s2"&gt;"&amp;lt;p&amp;gt;Active records can include starting, paused or uncertain instances. "&lt;/span&gt;
            &lt;span class="s2"&gt;"This count is not proof that all EAs are trading. Stored identifiers remain "&lt;/span&gt;
            &lt;span class="s2"&gt;"visible to help diagnose stale accounts.&amp;lt;/p&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;


&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;client_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;input&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"AlgoHand client_id (not email): "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;strip&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;environ&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"ALGOHAND_API_KEY"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;getpass&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getpass&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Client API key (hidden): "&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;client_id&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;ValueError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Missing configuration"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;fetch_state&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;True&lt;/span&gt;
        &lt;span class="n"&gt;page&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;render&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Fetch failed. Check connectivity, credentials and client scope; no raw response was logged."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;target&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Path&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"monitor.html"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;with_suffix&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".tmp"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write_text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;page&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encoding&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"utf-8"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Saved "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="kt"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;target&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;resolve&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;SystemExit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The script refuses redirects so it cannot forward the authorization header to a different destination. HTTPS certificate validation stays enabled. A response limit and timeout bound the fetch; a failure replaces the output with an explicit unknown-state page instead of silently retaining a successful-looking snapshot. If writing the file itself fails, Python exits with an error and the old page's generation time remains the clue that it has not refreshed.&lt;/p&gt;

&lt;p&gt;All response text inserted into HTML is escaped. Broker names and identifiers are data, even when the upstream API is authenticated.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interpret the result
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Observation&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fresh account, online VPS, health &lt;code&gt;ok&lt;/code&gt;, AutoTrading OFF&lt;/td&gt;
&lt;td&gt;The control path can be healthy while automated trading is disabled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fresh VPS but stale account&lt;/td&gt;
&lt;td&gt;The agent has contacted AlgoHand, but this account lacks fresh evidence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Unknown build or AutoTrading&lt;/td&gt;
&lt;td&gt;The page does not have enough current evidence to show those values&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No accounts&lt;/td&gt;
&lt;td&gt;The request succeeded without account rows; investigate client selection and terminal reporting&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Refresh failed&lt;/td&gt;
&lt;td&gt;The latest fetch did not establish current state&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The instance count is the number of returned active instance records. It can include a paused or starting EA; it is not a count of EAs currently placing orders. A useful next extension would list each instance's &lt;code&gt;status&lt;/code&gt;, symbol, timeframe and &lt;code&gt;input_observation&lt;/code&gt; separately.&lt;/p&gt;

&lt;p&gt;The HTML contains operational identifiers. Keep it on the operator's machine, outside a public web directory. If you turn this into a hosted panel, add authenticated access and enforce each user's client mapping in the backend before fetching data. A client ID supplied by a browser is not authorization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add refresh without hiding failures
&lt;/h2&gt;

&lt;p&gt;For a continuously running version, fetch in a backend worker at a measured interval, preserve the last successful observation with its timestamp and show a separate refresh-error state. Stop uncontrolled retries on authentication failures, respect rate-limit responses and use backoff after transport failures. Keep the UI's age calculation running even when the network does not recover.&lt;/p&gt;

&lt;p&gt;Those changes can be added without introducing any terminal commands. The first useful integration is often a clear answer to “what do we actually know right now?”&lt;/p&gt;

&lt;p&gt;The request and field reference is in the &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;AlgoHand API documentation&lt;/a&gt; and &lt;a href="https://algohand.com/docs/openapi.yaml" rel="noopener noreferrer"&gt;OpenAPI specification&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>api</category>
      <category>tutorial</category>
      <category>automation</category>
    </item>
    <item>
      <title>Connecting Telegram to AlgoHand: from account linking to confirmed EA changes</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:16:00 +0000</pubDate>
      <link>https://dev.to/algohand/connecting-telegram-to-algohand-from-account-linking-to-confirmed-ea-changes-2lpn</link>
      <guid>https://dev.to/algohand/connecting-telegram-to-algohand-from-account-linking-to-confirmed-ea-changes-2lpn</guid>
      <description>&lt;p&gt;You can ask AlgoHand about your MetaTrader accounts from Telegram and request changes to supported Expert Advisors. The EA continues running in MT4 or MT5 on your computer or VPS. Telegram provides the conversation and confirmation buttons; it does not run the trading software.&lt;/p&gt;

&lt;p&gt;The setup uses the existing AlgoHand bot. You do not need to create a bot in BotFather, supply a bot API token or send your broker password in a message.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect the right AlgoHand account
&lt;/h2&gt;

&lt;p&gt;Before linking, sign in to the AlgoHand Dashboard and check that it shows the intended trading accounts. For live observations and terminal commands, the Windows agent, terminal and manager component must be running and connected. You can link Telegram before they are ready, but linking alone will not bring a disconnected terminal online.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open &lt;a href="https://app.algohand.com/app?workspace=trader#settings/b-telegram" rel="noopener noreferrer"&gt;Settings in the AlgoHand Dashboard&lt;/a&gt; and find &lt;strong&gt;Alerts and the assistant in Telegram&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Connect Telegram&lt;/strong&gt;. If a chat is already linked, the button offers &lt;strong&gt;Connect another Telegram&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Follow the generated link to &lt;strong&gt;@algohand_bot&lt;/strong&gt; and press &lt;strong&gt;Start&lt;/strong&gt; in Telegram. Use the link from your Dashboard: opening the bot by its username alone does not identify your AlgoHand account.&lt;/li&gt;
&lt;li&gt;Check the bot's welcome message. It names the AlgoHand account email that was linked. Return to the Dashboard and check that the expected Telegram identity appears in the list.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Send a test&lt;/strong&gt; in the Dashboard. This sends a notification to the linked chats; it does not issue a MetaTrader command.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the generated link within 15 minutes. It is a one-use account-linking credential, so do not post it in a public channel or send it to somebody who should not have access. If it expires, generate a fresh link from the Dashboard.&lt;/p&gt;

&lt;p&gt;Start with a private conversation with the bot. If Telegram opens under a different personal identity than you intended, correct that before pressing Start.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make the first message a status check
&lt;/h2&gt;

&lt;p&gt;Send &lt;code&gt;/status&lt;/code&gt;. The reply lists reported accounts and EAs, with a stale-data indication when the VPS has not reported recently. Compare the account suffix and broker with the account you intended to manage.&lt;/p&gt;

&lt;p&gt;Then try a read-only question such as:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Which EAs are running on my MT5 account, and is its VPS online?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If there are several accounts, include the platform and enough account or chart detail to identify the target. “My EURUSD EA” can be ambiguous when the same EA runs on multiple charts.&lt;/p&gt;

&lt;p&gt;Useful shortcuts include:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Command&lt;/th&gt;
&lt;th&gt;What it does&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/status&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows reported accounts, EAs and VPS state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/ea&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lists EAs and offers pause/resume requests through the confirmation flow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/pnl 30d&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Requests closed P&amp;amp;L for the last 30 days&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/alerts&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Lists configured alert rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/language&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Selects English, Russian, Spanish, Portuguese or German&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/new&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Starts a new assistant conversation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;/help&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Shows the bot's command help&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Read financial reports with their coverage notes. Closed P&amp;amp;L is not floating P&amp;amp;L, and a report based on stored history is not automatically a complete account-lifetime report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Change an input through a preview
&lt;/h2&gt;

&lt;p&gt;Suppose a fictional EA exposes an editable &lt;code&gt;StartHour&lt;/code&gt; input and its author defines it in broker-server time. A request might be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On the MT5 EURUSD H1 chart, change StartHour from 8 to 9 for SessionExampleEA. Show me the change first.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The input and EA name here are examples. Use the exact settings available in your EA's reviewed onboarding profile. The profile supplies meanings, types and permissions; Telegram does not make an unknown input editable.&lt;/p&gt;

&lt;p&gt;Read the preview before pressing &lt;strong&gt;Apply&lt;/strong&gt;. Check the account, EA instance, chart, old and new values, and any warnings. For a preview containing several actions, the bot can offer &lt;strong&gt;Apply all&lt;/strong&gt;, &lt;strong&gt;Only …&lt;/strong&gt; and &lt;strong&gt;Cancel&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A typed “yes” does not confirm the change. Use the button under the preview. If you enabled a PIN, the bot asks for it after the button press.&lt;/p&gt;

&lt;p&gt;The Telegram preview expires after 10 minutes. Request a fresh preview when it expires. This is separate from the 15-minute link used during initial setup. A changed plan can also require a new preview even before the button expires.&lt;/p&gt;

&lt;p&gt;After confirmation, follow the status message through the actual result. &lt;strong&gt;Confirmed&lt;/strong&gt; records your approval; it does not mean the terminal has completed the change. AlgoHand reports execution and verification separately. If initialization remains unconfirmed or the observed values differ, inspect the result in the Dashboard before requesting the same action again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changing inputs reinitializes the EA. If it has open trades, check the author's guidance on changing settings while trading.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The underlying path is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Telegram request -&amp;gt; preview -&amp;gt; Apply (+ optional PIN)
                 -&amp;gt; server validation -&amp;gt; Windows agent -&amp;gt; MT4/MT5 manager
                 -&amp;gt; observed result -&amp;gt; Telegram status
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bot uses AlgoHand's existing command flow. It does not bypass parameter restrictions, current account checks or maintenance-window requirements for operations that need them. AutoTrading OFF is reported separately from connection health; linking Telegram does not switch it on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add a confirmation PIN
&lt;/h2&gt;

&lt;p&gt;In the same Dashboard section, enter a separate &lt;strong&gt;4–8 digit PIN&lt;/strong&gt; and your current AlgoHand account password, then select &lt;strong&gt;Save PIN&lt;/strong&gt;. Enter the account password only in the Dashboard form, not in Telegram.&lt;/p&gt;

&lt;p&gt;After saving, enable &lt;strong&gt;Ask my PIN in Telegram after the Apply button, too&lt;/strong&gt;. Saving a PIN and enabling its use are separate steps. Once enabled, a button press is followed by a PIN request before the pending action proceeds.&lt;/p&gt;

&lt;p&gt;Five incorrect PIN attempts lock PIN confirmation for 15 minutes. The PIN is an additional action check; it does not turn a linked chat into a read-only notification channel. Treat access to that Telegram account accordingly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Add alerts and manage linked chats
&lt;/h2&gt;

&lt;p&gt;You can ask, for example:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Notify me if my VPS goes offline.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Review the proposed alert rule and confirm it. Creating an alert is a configuration change too. &lt;code&gt;/alerts&lt;/code&gt; shows the rules you have configured; receiving the initial test message does not create any rules.&lt;/p&gt;

&lt;p&gt;A single AlgoHand account can have several linked chats. Treat each additional link as an access decision, not just another delivery address. Configured Telegram alerts can reach the linked chats; notification delivery depends on the rule's channels and notification settings.&lt;/p&gt;

&lt;p&gt;Each chat has a &lt;strong&gt;Disconnect&lt;/strong&gt; action in the Dashboard. With multiple chats, &lt;strong&gt;Disconnect all&lt;/strong&gt; is also available. Alternatively, send &lt;code&gt;/unlink&lt;/code&gt; in the bot and confirm &lt;strong&gt;Disconnect&lt;/strong&gt;. Removing the link removes that chat's AlgoHand access; it does not close MetaTrader or stop an EA.&lt;/p&gt;

&lt;p&gt;One Telegram chat belongs to one AlgoHand account at a time. Linking that chat from another Dashboard account moves the association. If the bot suddenly shows an unexpected account, check the linked account rather than installing another agent.&lt;/p&gt;

&lt;h2&gt;
  
  
  When something does not work
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symptom&lt;/th&gt;
&lt;th&gt;What to check&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;The bot says the chat is not linked&lt;/td&gt;
&lt;td&gt;Open Connect Telegram in the intended Dashboard account and press Start using its generated link&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The link has expired&lt;/td&gt;
&lt;td&gt;Generate a new connection link; it is valid for 15 minutes and can be used once&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The preview has expired&lt;/td&gt;
&lt;td&gt;Ask for a new preview; an old approval button is valid for 10 minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The test arrives, but no trading account appears&lt;/td&gt;
&lt;td&gt;Check the agent, manager and broker account in the Dashboard; Telegram delivery and terminal connectivity are separate&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A command was confirmed but has not finished&lt;/td&gt;
&lt;td&gt;Read its status and freshness in the Dashboard before sending another request&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This guide covers text messages. The current Telegram handler does not process voice notes; the Dashboard's microphone feature is a separate interface.&lt;/p&gt;

&lt;p&gt;For the first real change, use a demo account and a documented input on a test EA. Confirm the resulting value in MetaTrader as well as in the bot. Once that works, the everyday interaction is short: ask, review, confirm and read the result.&lt;/p&gt;

</description>
      <category>tutorial</category>
      <category>automation</category>
      <category>telegram</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Adding MetaTrader controls to a VPS hosting panel with AlgoHand</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 14:06:51 +0000</pubDate>
      <link>https://dev.to/algohand/adding-metatrader-controls-to-a-vps-hosting-panel-with-algohand-10n8</link>
      <guid>https://dev.to/algohand/adding-metatrader-controls-to-a-vps-hosting-panel-with-algohand-10n8</guid>
      <description>&lt;p&gt;A VPS can answer a ping while MetaTrader is disconnected from its broker. The terminal can be connected while its control component is missing. Neither condition is visible in a hosting panel that only reports CPU, RAM and whether Windows is running.&lt;/p&gt;

&lt;p&gt;AlgoHand adds a view of the terminals and a customer-facing control interface. A customer can request an EA parameter change through chat, review the proposed values and confirm it. A provider can inspect terminal health across its fleet without opening every desktop. The integration connects those two sides to the provider's existing customer and server records.&lt;/p&gt;

&lt;p&gt;This walkthrough covers the API, Windows installation and support workflow. The IDs and request bodies are examples, not production credentials or an instruction to change an existing customer's VPS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with a provider workspace
&lt;/h2&gt;

&lt;p&gt;The integration needs a provisioned provider tenant and a tenant-level backend API key. Provider Dashboard access also needs an operator-assigned mapping. Selecting Business in an ordinary user's profile does not grant access to other customers.&lt;/p&gt;

&lt;p&gt;Keep the tenant key in the hosting backend. It has broad authority within the provider tenant; it is not a read-only monitoring credential. Do not distribute it to customers, browser JavaScript or Windows VM images.&lt;/p&gt;

&lt;p&gt;Three credentials serve different purposes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Credential&lt;/th&gt;
&lt;th&gt;Where it belongs&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Provider API key&lt;/td&gt;
&lt;td&gt;Hosting backend&lt;/td&gt;
&lt;td&gt;Provision customers/VPS records and access provider operations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One-use enrolment token&lt;/td&gt;
&lt;td&gt;One machine's installation process&lt;/td&gt;
&lt;td&gt;Register that Windows machine with AlgoHand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Customer chat code&lt;/td&gt;
&lt;td&gt;That customer's authenticated panel session&lt;/td&gt;
&lt;td&gt;Open chat scoped to the customer's AlgoHand client&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The Windows agent polls outbound over HTTPS. AlgoHand does not require an inbound control port on each VPS. Initial Windows setup and broker login still need to be handled; outbound polling does not remove those steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Provision with your own stable IDs
&lt;/h2&gt;

&lt;p&gt;Use the hosting system's customer and server IDs, rather than an IP address that may change or be reassigned. Store the internal AlgoHand IDs returned by the API alongside them.&lt;/p&gt;

&lt;p&gt;First create or update the customer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;provisioning&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;clients&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1042&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;algohand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;PROVIDER_BACKEND_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Example customer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"metadata"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"service"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"windows-trading-vps"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then register one VPS for that customer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;PUT&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;provisioning&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;clients&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;customer&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1042&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;vps&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;server&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;7781&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;algohand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;PROVIDER_BACKEND_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Trading VPS - Frankfurt"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These PUT operations are idempotent. Retrying the same active mapping returns the same internal record. A server ID already assigned to a different active customer is rejected.&lt;/p&gt;

&lt;p&gt;The first VPS response includes &lt;code&gt;enroll_token&lt;/code&gt;, its expiry, &lt;code&gt;bootstrap_url&lt;/code&gt;, &lt;code&gt;bootstrap_arguments&lt;/code&gt; and &lt;code&gt;bootstrap_environment&lt;/code&gt;. The token is usable once and expires after 24 hours. Treat the response as sensitive: do not write it wholesale to job logs.&lt;/p&gt;

&lt;p&gt;A retry does not reveal the original token. If the first response was lost, append &lt;code&gt;/enrollment-token&lt;/code&gt; to the VPS resource path and POST &lt;code&gt;{ "replace_existing": false }&lt;/code&gt; to issue a fresh one. An already enrolled machine is refused by this recovery request. Do not turn a lost HTTP response into another customer or VPS record.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install in the Windows session that owns the terminals
&lt;/h2&gt;

&lt;p&gt;The current installer supports Windows Server 2016 or newer and Windows 10/11; Server 2012/R2 is not supported by this package. Run setup elevated under the intended terminal user. Keep the agent and the intended MT4/MT5 instances in that user's interactive-session workflow. Running installation as SYSTEM in a VM provisioning job is not equivalent to completing this setup.&lt;/p&gt;

&lt;p&gt;For unattended installation, the provisioning response supplies &lt;code&gt;-NoPrompt -AttachRestart window&lt;/code&gt; and the token through &lt;code&gt;ALGOHAND_ENROLL_TOKEN&lt;/code&gt;. Your provisioning runner should download the returned official HTTPS bootstrap and inject that environment only into the installation process. For example, after saving the bootstrap at the path below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Run elevated as the intended terminal user.&lt;/span&gt;
&lt;span class="c1"&gt;# The provisioning runner supplies ALGOHAND_ENROLL_TOKEN to this process.&lt;/span&gt;
&lt;span class="nv"&gt;$ErrorActionPreference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'Stop'&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="nv"&gt;$env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;ALGOHAND_ENROLL_TOKEN&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="s1"&gt;'Missing one-use enrolment token'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="s1"&gt;'C:\Provisioning\algohand-install.ps1'&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;NoPrompt&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;AttachRestart&lt;/span&gt; &lt;span class="n"&gt;window&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Remove&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Item&lt;/span&gt; &lt;span class="nc"&gt;Env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;\&lt;span class="no"&gt;ALGOHAND_ENROLL_TOKEN&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;ErrorAction&lt;/span&gt; &lt;span class="nc"&gt;SilentlyContinue&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bootstrap downloads the EXE installer and checks its Authenticode publisher and timestamp before running it. The token is passed to that installer through its environment, rather than in command-line arguments. Do not bake an enrolled agent, its keys or a used token into a reusable VM image.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;window&lt;/code&gt; defers a required restart of an already-running terminal to the configured maintenance window. It does not mean the terminal is immediately controllable. An interactive installation can offer Connect now; use that only with agreement to restart the selected terminals. Installation must not become an excuse to force-close a customer's work.&lt;/p&gt;

&lt;p&gt;After setup, compare the platform, broker login and server reported by AlgoHand with the intended terminal. Check the executable and data-directory mapping when several installations exist. A broker account number alone is not enough, and an agent heartbeat does not prove that it found the correct account.&lt;/p&gt;

&lt;p&gt;Plan for Windows sign-in after a reboot. An RDP disconnect and a Windows sign-out are different events. Do not promise uninterrupted terminal operation merely because an installer returned success.&lt;/p&gt;

&lt;h2&gt;
  
  
  Put the customer's chat inside your panel
&lt;/h2&gt;

&lt;p&gt;The provider backend can create a customer-scoped chat session:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;clients&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;cl_example&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;codes&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;algohand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;PROVIDER_BACKEND_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Hosting panel session"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"ttl_hours"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"lang"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"en"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;cl_example&lt;/code&gt; with the internal &lt;code&gt;client_id&lt;/code&gt; returned during provisioning. Derive it from your authenticated customer record, not a client ID supplied unchecked by the browser.&lt;/p&gt;

&lt;p&gt;The response provides &lt;code&gt;embed_url&lt;/code&gt; for an iframe and &lt;code&gt;widget_snippet&lt;/code&gt; for a chat widget. The chat code grants access to that client, so treat it as a credential. Keep it out of analytics and shared caches, use an appropriate lifetime, and revoke it with &lt;code&gt;DELETE /v1/chat-codes/{code}&lt;/code&gt; when the panel session ends. Closing an iframe alone does not revoke a code.&lt;/p&gt;

&lt;p&gt;This is where the customer can ask to change a supported EA's inputs. An onboarded EA profile supplies the parameter meanings and permissions. The customer reviews the proposed change before applying it; provisioning a VPS does not onboard every EA or authorize trading changes.&lt;/p&gt;

&lt;p&gt;A provider building its own command interface instead of embedding chat must implement approval itself. Use explicit &lt;code&gt;dry_run: true&lt;/code&gt; previews, preserve the approved plan, and inspect the eventual command result. HTTP 202 means accepted, not completed. The &lt;a href="https://dev.to/algohand/changing-ea-inputs-remotely-the-stale-state-problem-in-mt4-and-mt5-2kjh"&gt;API walkthrough&lt;/a&gt; covers preview hashes, idempotency and result polling.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give support staff terminal-level evidence
&lt;/h2&gt;

&lt;p&gt;Business Dashboard offers fleet operations, readiness checks, tags, notes, incident triage, version exports and optional daily summaries. The corresponding API can feed an existing support panel:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Request&lt;/th&gt;
&lt;th&gt;Use&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/business/fleet?attention=true&amp;amp;limit=100&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find machines needing inspection; follow pagination&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/fleet/{vps_id}/diagnostics&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Inspect one machine's agent, terminal and manager evidence&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/business/incidents&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Read operational incidents and their current triage state&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/business/versions.csv&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Export reported agent and manager versions&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check freshness as well as status. Missing or stale evidence is not proof of health. AutoTrading OFF is a separate state and does not, by itself, mean the terminal is degraded.&lt;/p&gt;

&lt;p&gt;The diagnostics response omits balances, positions, orders and EA input values. It can reference an existing customer screenshot; requesting diagnostics does not capture a new one. Do not assume a screenshot is redacted just because the structured response excludes those fields.&lt;/p&gt;

&lt;p&gt;Fleet inspection and incident notes do not issue terminal commands. Marking an incident in progress records support activity; it does not repair the terminal. A provider API key's authority is broader than these read-only endpoints, so enforce staff permissions in your own backend too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Connect events to your support workflow
&lt;/h2&gt;

&lt;p&gt;Register a public HTTPS receiver with &lt;code&gt;POST /v1/webhooks&lt;/code&gt; and select events such as &lt;code&gt;vps.offline&lt;/code&gt;, &lt;code&gt;terminal.not_responding&lt;/code&gt; or &lt;code&gt;agent.update_stalled&lt;/code&gt;. The endpoint secret is returned once.&lt;/p&gt;

&lt;p&gt;Verify the &lt;code&gt;AlgoHand-Signature&lt;/code&gt; header against the exact raw body before parsing or acting on it. Its format is &lt;code&gt;t=&amp;lt;timestamp&amp;gt;,v1=&amp;lt;hex digest&amp;gt;&lt;/code&gt;; the digest is HMAC-SHA256 over the ASCII timestamp, a dot and the raw request bytes. Use a constant-time comparison and a bounded timestamp tolerance.&lt;/p&gt;

&lt;p&gt;Persist accepted events before returning success, and deduplicate using the signed body's event ID. Delivery can be retried and events can arrive out of order. Use the delivery log to investigate failures and fetch current state before making an operational decision. An outage event should not automatically become permission to restart a customer's terminal.&lt;/p&gt;

&lt;p&gt;For rebuilds, the enrolment-token endpoint requires &lt;code&gt;replace_existing: true&lt;/code&gt; before replacing an enrolled machine; that revokes the old agent key immediately. On cancellation, decommission the VPS mapping. The agent removes its local AlgoHand state on its next request; decommissioning does not shut down MetaTrader or cancel the hosting subscription.&lt;/p&gt;

&lt;p&gt;A useful first pilot is one customer with an MT4 and an MT5 demo terminal. Check account mapping, manager readiness, sign-in after reboot, reconnect behaviour, duplicate provisioning requests, token recovery, webhook retries and one confirmed parameter change on a non-trading test EA. This is a rollout checklist, not a claim that every Windows image and broker combination has been qualified.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;API reference&lt;/a&gt; and &lt;a href="https://algohand.com/docs/openapi.yaml" rel="noopener noreferrer"&gt;OpenAPI document&lt;/a&gt; describe the request and response formats. Keep the boundary clear in the hosting UI: monitoring shows what is happening; a separate, authorized command changes it.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>api</category>
      <category>automation</category>
      <category>architecture</category>
    </item>
    <item>
      <title>Your EA's inputs are an interface. Document them like one.</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 13:57:30 +0000</pubDate>
      <link>https://dev.to/algohand/your-eas-inputs-are-an-interface-document-them-like-one-2g7j</link>
      <guid>https://dev.to/algohand/your-eas-inputs-are-an-interface-document-them-like-one-2g7j</guid>
      <description>&lt;p&gt;“Start trading at nine” sounds like a clear request. An Expert Advisor might expose &lt;code&gt;StartHour=9&lt;/code&gt;, but nine in which time zone? Does the setting affect new entries only? Does another switch disable the schedule altogether?&lt;/p&gt;

&lt;p&gt;The customer should not have to discover those answers by trial and error. They need to come from the EA's author.&lt;/p&gt;

&lt;p&gt;In AlgoHand, chat-based parameter changes use an EA compatibility profile. Onboarding is the process of describing the EA's inputs and reviewing how they may be used. The previous article covered &lt;a href="https://dev.to/algohand/changing-ea-inputs-remotely-the-stale-state-problem-in-mt4-and-mt5-2kjh"&gt;how a request reaches MetaTrader through the API&lt;/a&gt;. This one focuses on the information an author supplies before that request can make sense.&lt;/p&gt;

&lt;h2&gt;
  
  
  A variable name leaves a lot unsaid
&lt;/h2&gt;

&lt;p&gt;Consider these fictional inputs:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Input&lt;/th&gt;
&lt;th&gt;What the name tells us&lt;/th&gt;
&lt;th&gt;What the author still needs to explain&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;StartHour&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Probably an hour&lt;/td&gt;
&lt;td&gt;Broker time, UTC or local time? What happens when daylight saving changes?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;Mode&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A selection&lt;/td&gt;
&lt;td&gt;Which numeric value corresponds to each option?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;FixedLot&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A position size&lt;/td&gt;
&lt;td&gt;Is it ignored when another sizing mode is selected?&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;MagicNumber&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;An identifier&lt;/td&gt;
&lt;td&gt;Does changing it affect how the EA finds its existing positions?&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;A chat model can produce plausible explanations for all four. Plausible is not enough when an explanation determines which setting gets changed.&lt;/p&gt;

&lt;p&gt;Good descriptions answer the operational question. For example: “First hour for opening new positions, in broker-server time; used only when the session filter is enabled.” That sentence is more useful than “Trading start hour.” It gives the interface something concrete to explain to the customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Describe meaning separately from permission
&lt;/h2&gt;

&lt;p&gt;AlgoHand's EA Spec Protocol uses JSON to carry parameter descriptions. Here is a simplified parameter excerpt for a fictional EA:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"key"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"StartHour"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"int"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"terminal"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"default"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;9&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"label"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Trading start hour"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"meaning"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"First hour for opening new positions, in broker-server time; used only when the session filter is enabled."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"unit"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"hours"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"safe_range"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;"min"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"max"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"requires_restart"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is one illustrative parameter, not a complete profile to import. Provenance and permission details are omitted. The field called &lt;code&gt;safe_range&lt;/code&gt; describes a configured range; it does not establish that choosing a particular hour is suitable for an account.&lt;/p&gt;

&lt;p&gt;Meaning, permission and confidence answer different questions. Knowing what an input does does not mean every customer should be able to change it individually. A description generated from a manual should not silently become author-confirmed information. Missing enum labels should remain unknown until someone supplies them.&lt;/p&gt;

&lt;p&gt;The author can review these details in the profile, including which inputs are available for individual changes. Those controls apply to requests through AlgoHand; they do not prevent manual edits inside MetaTrader.&lt;/p&gt;

&lt;h2&gt;
  
  
  Presets need to describe actual configurations
&lt;/h2&gt;

&lt;p&gt;A preset is useful when it refers to a known set of values. “Use the London session preset” can be a specific request if the author has defined that preset and explained its time basis.&lt;/p&gt;

&lt;p&gt;The word “conservative” is less useful on its own. It may refer to position size, trading frequency or several different controls. An assistant should not invent a configuration to make the phrase sound actionable.&lt;/p&gt;

&lt;p&gt;When documenting a preset, include the complete set of changes and any dependencies between inputs. A defined preset may change a parameter that is unavailable for individual editing, so the customer still needs to review the full preview. Neither an allowed range nor a preset label is a promise about trading results.&lt;/p&gt;

&lt;h2&gt;
  
  
  Review the profile when the EA changes
&lt;/h2&gt;

&lt;p&gt;An update can keep an input's name while changing its meaning. The interface cannot infer that from the name alone. After changing an EA, review its profile alongside the code and manual: types, defaults, units, enum mappings, dependencies and presets.&lt;/p&gt;

&lt;p&gt;For Market products, AlgoHand's author workflow uses the product identity, platform, a chart template and the JSON description. The template helps cross-check exposed inputs. Importing a description does not publish it or run the EA; the author reviews and submits the profile for review. MT4 and MT5 must be identified correctly.&lt;/p&gt;

&lt;p&gt;AlgoHand receives the description rather than the EA's source code in this workflow. If an author uses a cloud AI to draft that description from source, the source is being shared with that provider. The author should decide whether that is appropriate and review the output before submitting it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changing inputs reinitializes the EA. If it has open trades, check the author's guidance on changing settings while trading.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For the author, that guidance belongs in the documentation as clearly as the parameter definitions. For the customer, the benefit is practical: a request in chat can refer to the author's documented settings instead of relying on an assistant's guess.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://algohand.com/docs/esp.schema.json" rel="noopener noreferrer"&gt;EA Spec Protocol schema&lt;/a&gt; defines the full document format. The &lt;a href="https://algohand.com/docs/algohand-prompt-v1.txt" rel="noopener noreferrer"&gt;description prompt&lt;/a&gt; lists the expected metadata and provenance fields; generated output still needs review.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>documentation</category>
      <category>api</category>
      <category>programming</category>
    </item>
    <item>
      <title>From chat to MetaTrader: an API workflow for changing EA inputs</title>
      <dc:creator>AlgoHand</dc:creator>
      <pubDate>Fri, 27 Nov 2026 13:17:00 +0000</pubDate>
      <link>https://dev.to/algohand/changing-ea-inputs-remotely-the-stale-state-problem-in-mt4-and-mt5-2kjh</link>
      <guid>https://dev.to/algohand/changing-ea-inputs-remotely-the-stale-state-problem-in-mt4-and-mt5-2kjh</guid>
      <description>&lt;p&gt;AlgoHand lets a customer request changes to an MT4 or MT5 Expert Advisor's settings through chat. For a developer, the useful detail is that the chat uses an API: a dashboard, support interface or another application can submit a structured request through the same command endpoint.&lt;/p&gt;

&lt;p&gt;Consider a request such as “change MaxSpread to 25 for the EA on my EURUSD chart.” The interface has to identify the running EA, find the exact input, show the proposed change and obtain confirmation. The EA itself continues running in MetaTrader on the customer's Windows computer or VPS.&lt;/p&gt;

&lt;p&gt;Here is how that request fits together. The parameter and IDs below are fictional; a real request must use the target EA's profile and permitted values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Onboarding gives the interface a description of the EA
&lt;/h2&gt;

&lt;p&gt;An input name alone does not explain its meaning. &lt;code&gt;Risk&lt;/code&gt; might be a percentage, a fixed lot size or an enumeration. The interface needs that information before it can turn a sentence into a useful request.&lt;/p&gt;

&lt;p&gt;During onboarding, an EA author can provide a compatibility profile describing the inputs: names, types, units, permitted ranges, individually editable settings and defined presets. The author reviews that information and submits the profile for review before publication.&lt;/p&gt;

&lt;p&gt;This is where onboarding helps customers. A published, matching profile gives the interface a definition of the settings it may offer. Instead of asking every customer to work out what an ambiguous field means, the author can explain it in the profile. A named preset can describe a particular set of changes, which the customer still reviews before applying.&lt;/p&gt;

&lt;p&gt;The profile does not replace the EA or its licence. It describes how the interface may interact with its inputs; it does not establish that a configuration will be profitable or that every EA behaves identically after reinitialization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolve the target and ask for a preview
&lt;/h2&gt;

&lt;p&gt;The REST API uses Bearer authentication. Keep the key in your application backend. A client-scoped key is restricted to one customer; a tenant integration must supply the appropriate &lt;code&gt;client_id&lt;/code&gt; and enforce its own user-to-customer access mapping.&lt;/p&gt;

&lt;p&gt;These are the relevant resources:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Request&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/clients/{client_id}/state&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Find accounts and running EA instances, and inspect reported state and freshness.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/eas/{ea_id}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Read the EA's caller-visible parameter definitions and permissions.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;POST /v1/accounts/{account_id}/commands&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Preview or submit a command, depending on &lt;code&gt;dry_run&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;GET /v1/commands/{command_id}?wait=30&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Wait for an outcome, or receive the current status if it is still pending.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Use the &lt;code&gt;account_id&lt;/code&gt; and &lt;code&gt;instance_id&lt;/code&gt; returned by the API. An EA name or a symbol alone is ambiguous when several charts run the same EA. Reported inputs may also be old or partial. The &lt;code&gt;read_ea_inputs&lt;/code&gt; command requests a fresh read without changing inputs; inspect its freshness and missing-input information before using the result as a baseline.&lt;/p&gt;

&lt;p&gt;For a hypothetical profile that permits &lt;code&gt;MaxSpread=25&lt;/code&gt;, a preview request with a client-scoped key looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;v1&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;accounts&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;acc_example&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;commands&lt;/span&gt; &lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="mf"&gt;1.1&lt;/span&gt;
&lt;span class="nc"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;algohand&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;com&lt;/span&gt;
&lt;span class="nc"&gt;Authorization&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Bearer&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;CLIENT_API_KEY&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nc"&gt;Content&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;application&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"set_param"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"dry_run"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s2"&gt;"params"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"instance_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"inst_example"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"inputs"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="s2"&gt;"MaxSpread"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A successful preview returns HTTP 200, including a summary, &lt;code&gt;resolved.diff&lt;/code&gt;, warnings and a &lt;code&gt;preview_hash&lt;/code&gt;. It does not queue the change. Set &lt;code&gt;dry_run&lt;/code&gt; explicitly: the raw REST command model defaults to execution, unlike the preview-first chat tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  Confirmation belongs in the interface
&lt;/h2&gt;

&lt;p&gt;Show the target, before-and-after values and warnings to the user. Store the approved request and its &lt;code&gt;preview_hash&lt;/code&gt; in your backend. After explicit confirmation, submit the same action with &lt;code&gt;dry_run: false&lt;/code&gt; and the saved hash as &lt;code&gt;expected_preview_hash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The server checks the request again. If the supplied hash no longer matches the resolved plan, it returns HTTP 409 with &lt;code&gt;PREVIEW_STALE&lt;/code&gt; without queuing that change. Obtain a new preview and confirmation. The hash is a plan precondition, not proof of consent; the integrating application must enforce approval itself. AlgoHand's own chat provides that approval flow.&lt;/p&gt;

&lt;p&gt;For the execution request, also persist an &lt;code&gt;Idempotency-Key&lt;/code&gt; with the exact action. If delivery is uncertain, reuse that key for the same request rather than generating a new one. Within the documented replay window, the server returns the original command; reusing a key with a different action or account is a conflict.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcxbyz8ux5ppwj6c3g3pf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcxbyz8ux5ppwj6c3g3pf.png" alt="Request, validation, confirmation, application and result checking" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Conceptual workflow for an interactive settings change. Previously configured automated rules have their own authorization policy.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;HTTP 202 means the command has been accepted, not that MetaTrader has finished. Follow the returned &lt;code&gt;command_id&lt;/code&gt; and report the actual status, result and any error. Keep input readback separate from initialization evidence; an unclear result needs inspection before another attempt.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changing inputs reinitializes the EA. If it has open trades, check the author's guidance on changing settings while trading.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Profile rules and current account conditions can refuse a change. Stale observations, open positions and pending orders matter here. A controller should also avoid applying an old input snapshot over manual changes made in the terminal.&lt;/p&gt;

&lt;h2&gt;
  
  
  REST, chat tools and the Windows agent
&lt;/h2&gt;

&lt;p&gt;A custom web or desktop interface can use the REST API directly through its backend. An AI interface can expose structured tools such as &lt;code&gt;get_client_state&lt;/code&gt;, &lt;code&gt;get_ea&lt;/code&gt;, &lt;code&gt;set_param&lt;/code&gt; and &lt;code&gt;get_command&lt;/code&gt;. AlgoHand also has an MCP wrapper over the API, using stdio transport, for clients that support that protocol.&lt;/p&gt;

&lt;p&gt;MCP is an adapter, not an approval mechanism. The current wrapper exposes preview-first parameter tools but does not itself implement the REST preview-hash and idempotency workflow described above. An integration must provide the controls it needs; a model instruction to “ask first” should not be its only approval check.&lt;/p&gt;

&lt;p&gt;On the Windows side, the agent polls outbound over HTTPS, receives queued commands and communicates with the manager inside MetaTrader. MT5 normally uses a manager service; MT4 uses a manager EA. They share the public command model, but their terminal integrations are different and need separate tests. The machine, agent and terminal must be running and connected for execution.&lt;/p&gt;

&lt;p&gt;For a customer, the visible interaction can stay short: request a setting, review the change, confirm it and read the result. For an EA author, onboarding supplies the parameter definitions behind that interaction. For an interface developer, the work is to preserve those definitions, the customer's approval and the command's actual outcome across the API boundary.&lt;/p&gt;

&lt;p&gt;The endpoint reference is available in the &lt;a href="https://algohand.com/docs/" rel="noopener noreferrer"&gt;AlgoHand API documentation&lt;/a&gt;, with the request schemas in the &lt;a href="https://algohand.com/docs/openapi.yaml" rel="noopener noreferrer"&gt;OpenAPI specification&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>architecture</category>
      <category>automation</category>
      <category>api</category>
    </item>
  </channel>
</rss>
