All APIs medvedtrader.com support

MT Paste API Doc

The Paste API lets another program drive Medved Trader's trading windows. It works by handing a trading window a block of JSON, either on the Windows clipboard or in a WM_COPYDATA message.

The JSON is the same language that Medved Trader's Hotkeys are written in. Anything a hotkey can do on a Chart, Level II, DOM, Trade Ticket or Account window, a Paste API payload can do on that window. That includes placing, dropping, changing and cancelling orders, flattening positions, and changing the window's symbol, account or quantity.

The simplest way to write a payload is to build the hotkey in Medved Trader's Hotkey editor first. Then right-click it in the hotkey list, choose Copy for Paste API, and add your password (Pwd).

Please contact us at support@medvedtrader.com if you're having any problems with the API.

The Paste API is separate from the WebSocket streaming API, but the two work together:

Clipboard · WM_COPYDATA JSON Requires MT Running Windows only

Enabling the Paste API

The Paste API is off by default. Two conditions must both be true, or pasted JSON is silently ignored (see Results and errors):

Once it is enabled, the Copy for Paste API item appears on the hotkey list's right-click menu.

How a payload is processed

  1. Delivery. The text arrives at one trading window, by clipboard paste or WM_COPYDATA. After leading and trailing whitespace is trimmed, it must start with { or [. Anything else is treated as an ordinary paste, e.g. a symbol.
  2. Gate. The window must be a trading window: Chart, Level II, DOM, Trade Ticket or Account. The Paste API must also be enabled. If either condition fails, the JSON is dropped without any message.
  3. Password. Every statement must carry a valid Pwd.
  4. Echo. If the statement asks for it, the window's current state is sent back to you. This happens before any command runs (see EchoTo).
  5. Split. The payload is split into statements and commands. Disabled commands are removed. Orders for a different account or symbol are separated out, so each can be sent to its own account (see Order).
  6. Evaluate and run. Vars are evaluated against the window's current state. Then each command's expressions are evaluated, and the commands run in order.

Commands run asynchronously on a background hotkey thread. Nothing is returned to the caller except the WM_COPYDATA accept/reject result and any echo you asked for. Errors are shown to the user in the target window.


Clipboard paste

Put the JSON on the clipboard as text (CF_UNICODETEXT / CF_TEXT). Then make MT paste it into a trading window by doing either of the following:

The paste goes to the window that has focus. On Trade Ticket and Level II windows, if the cursor is in a text box of the ticket (quantity, price…), the paste goes into that box as ordinary text. It is not treated as a Paste API payload.

Clipboard delivery is the easiest route for scripting tools such as AutoHotkey. Its drawback is that it depends on window focus and overwrites the user's clipboard. Use WM_COPYDATA if you can.

WM_COPYDATA

Send a WM_COPYDATA (0x004A) message straight to the trading window's handle. The window does not need focus.

COPYDATASTRUCT
FieldContent
dwDataignored (any value)
cbDatabyte length of lpData, including the terminating NUL
lpDatathe JSON as a NUL-terminated string. UTF-16 (wide) is preferred. MT reads the data as UTF-16 first, and falls back to ANSI if that does not yield text starting with { or [. The JSON must be at least 10 characters long.
Return value of SendMessage
ValueMeaning
1The JSON was parsed and queued for the window. This does not mean the password was accepted or that the commands succeeded. Both are checked afterwards.
0Rejected. Possible reasons: not JSON, not a trading window, the Paste API is disabled or not permitted, or the JSON could not be parsed.
Finding the window handle

Use the normal Win32 enumeration functions (EnumWindows, FindWindow, matching on the window caption). Once you have talked to a window, the handle field of any echo gives you its handle. A handle stays valid until the window is closed; it is not preserved across layout reloads or restarts.

C# SENDER
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
struct COPYDATASTRUCT { public IntPtr dwData; public int cbData; public string lpData; }

[DllImport("user32.dll", CharSet = CharSet.Unicode)]
static extern IntPtr SendMessage(IntPtr hWnd, int msg, IntPtr wParam, ref COPYDATASTRUCT cds);
const int WM_COPYDATA = 0x004A;

static bool SendPaste(IntPtr mtWindow, string json)
{
    var cds = new COPYDATASTRUCT { dwData = (IntPtr)1, cbData = (json.Length + 1) * 2, lpData = json };
    return SendMessage(mtWindow, WM_COPYDATA, IntPtr.Zero, ref cds) == (IntPtr)1;
}

Password (Pwd)

Every pasted payload must authenticate:

The value is the password you use to log into Medved Trader. If you log in with a social login, which has no application password, it is your PIN instead.

The password travels in plain text, through the clipboard or a window message. Any program running on the same desktop can read the clipboard. Prefer WM_COPYDATA, and do not leave a payload containing Pwd sitting on the clipboard.

Results and errors

The Paste API has no response channel. Here is what you can observe:

If EchoTo is set, the echo tells you the payload got past the password check. That is the only confirmation you get back.


Statements

A payload is one statement object, a JSON array of statements, or several statement objects placed one after another. A statement is exactly what the Hotkey editor saves for one hotkey.

Statement keys
NameReqTypeContent
PwdYstringsee Password
CommandYobject | arrayone command object, or an array of them, run in order
VarsNobjectvariable declarations, evaluated before the commands (see Vars and If)
JSONNobject | arrayif present, the payload is replaced by this member. This lets you paste a whole exported hotkey record (with Pwd added at the top level).
EchoTo, EchoClientMsg, hwnd, ChangeNsee EchoTo

Separate, SeparateSym and ALREADYAUTH are reserved for internal use. Do not send them.

MINIMAL PAYLOAD — buy 100 at the ask, sent immediately
{
  "Pwd": "mypassword",
  "Command": {
    "Disabled": false,
    "Order": {
      "Send": "true",
      "Legs": [ { "Action": "Buy", "OrderType": "Limit", "Quantity": "100", "LimitPrice": "Ask" } ]
    }
  }
}

Command objects

Each command object holds one action key (Order, Cancel, TradeQty, …), plus these optional envelope keys:

NameTypeContent
Disabledbool true skips the action. The Hotkey editor writes "Disabled": false in every action.
SetIntervar, ShareTrade, SharePos, PlaySound and Locate run only when "Disabled": false is present.
Delaystring {"Delay": "0.5"} as a command on its own pauses that many seconds before the following commands run.
It only takes effect as the first command of a statement, which is how the editor writes it.
ActiveSectionexpression If it evaluates to false, the action is skipped. It can sit beside the action key or inside the action object.
Inside ChangeOrder it is evaluated separately for each order the change applies to.
reqIDstringcorrelation tag. When a payload arrives through the WebSocket API, result notifications carry it. Put it on the first command.

Value types

Almost every value is a string, even numbers and booleans ("Quantity": "100", "Drop": "true"). Nearly every string value is an expression that MT evaluates against the window's current state. So "Ask+0.05", "round(PosAbs/2)" and "100" are all valid quantities or prices.

Send and Drop accept either a string ("true", "false", "CancelThenSend"…, in any letter case) or a JSON boolean (true / false).

Key names are case-sensitive, e.g. LimitPrice, not limitprice. Write enumeration values in order legs (Action, OrderType, TIF, ConditionalType) exactly as they are listed under Enumerations. Variable and function names inside expressions are not case-sensitive.


Order

Builds an order and drops it into the window, sends it to the broker, or both.

NameReqContent
SendN "false" (default) or "true". Or one of the cancel-first variants, which cancel the matching open orders for the symbol and then send:
CancelThenSend, CancelBuysThenSend, CancelSellsThenSend, CancelStopsThenSend, CancelBuyStopsThenSend, CancelSellStopsThenSend.
Any value other than "false" sends.
DropN"true" puts the order into the window without sending it: into the ticket (Trade Ticket, Level II), or as an order capsule (Chart, DOM). Default "false". Only possible for the window's own account and symbol.
AccountN"Default" or omitted = the window's account. Otherwise an account key ("SCHWAB:12345678"), account ID or display name. Another account's order is sent to that account directly and cannot be dropped.
SymbolN "Default" or omitted = the window's symbol.
"group:Blue" = the symbol currently in that link group.
Any other value is a literal symbol; the order is sent for it separately. Real-time prices for another symbol are only available if MT already has an L1 subscription for it.
ConditionalTypeNNone (default, 1 leg), OCA (2), OTA (2), OTT (3), OTOCA (3), OTOTA (3). The broker must support the type.
ConfirmToWindowNbool, default true: show an "order sent" confirmation on the window for orders sent to another account or symbol
LegsYarray of legs

Order Legs

NameContent
Action Buy, Sell, or another OrderAction (Short, Cover, option open/close actions).
None means the order is not placed. This is useful with an if … then … else 'None' expression.
=CurrentAction takes the window's current Buy/Sell side (Trade Ticket, Level II, DOM only).
OrderTypeMarket, Limit, StopMarket, StopLimit, TStopDLR (trailing, $), TStopPT (trailing, %), TStopTick, TStopLimit, MOO, MOC, LOO, LOC, Bracket, … TStop is treated as TStopDLR.
Quantitynumber expression. If the first leg has none, the window's default quantity is used. Later legs inherit the first leg's quantity. A result of 0 cancels the order with "Order quantity of 0".
LimitPriceprice expression, offset ("+0.05", "-1%") or peg
StopPrice same forms as LimitPrice.
For trailing types, a plain number is the trail amount.
For StopLimit, a limit offset is taken relative to the stop price.
TIF Time in force.
If omitted, the window's current TIF is used. For orders sent to another account or symbol, and on the global hotkey window, the default is Day.
TIFDatefor GTD: M/d/yyyy or yyyy-MM-dd
Routingroute name (first leg only). Default = the window's current route.
SpInstructionsspace- or comma-separated: AON, FOK, DNR, Hidden, PostOnly, Anon. Default = the window's setting.
DisplaySizenumber (reserve/iceberg display size, where supported)
XOnChart0–100: horizontal position of a dropped capsule on a chart

Conditional orders. In a conditional order (OTA, OTOCA…), a secondary leg's price can be an offset from the main leg's limit or stop price. For a main leg with no price (Market…), the base is the last trade.

Leave a field out rather than writing "Default"; the Hotkey editor never writes "Default" into a leg.

Cancel

NameContent
Open which open (working) orders to cancel. One value, a CSV string or an array:
None, All, Buys, Sells, LastOpen, BuyStops, SellStops, AllStops, UnderMouse (Chart/DOM: the order under the mouse)
Unsentwhich unsent (dropped) capsules to remove. Same values except LastOpen. Chart and DOM only.
Symbol Default = the window's symbol.
Other values: a list of symbols, group:<color>, or AllSymbols.
Accountdefault = the window's account
ConfirmToWindowbool, default true
CANCEL ALL OPEN ORDERS FOR THE WINDOW'S SYMBOL
{ "Pwd": "mypassword", "Command": { "Disabled": false, "Cancel": { "Open": "All", "Unsent": "None" } } }

Flatten

Cancels the working orders and closes the position with a market order.

NameContent
PositionRequired. Both, Long or Short. Only positions on that side are flattened. With no Position, nothing happens.
Symbol Default = the window's symbol.
Other values: a list, group:<color>, or AllSymbols (every symbol with a position or open order in the account).
Accountdefault = the window's account

ChangeOrder

Modifies existing orders or dropped capsules in the window. Its expressions are evaluated once for each order the change applies to. While they are evaluated, these variables are set from that order: OrderQty, OrderPrice, OrderType, OrderIsBuy, OrderIsSell, OrderIsUnsent, CurrentTIF.

NameContent
AppliesTo Selected (default), All, SelectedSymbol, TradeTicket.
On Chart, DOM and Level II, SelectedSymbol behaves as All.
NewPricean absolute price (25.10), an offset (+0.05, -1%) or an expression. A leading + or - makes it an offset from the order's current price; anything else is an absolute price. With AllLegs: true it must be an offset. Default +0.
NewQtythe new total quantity: an absolute quantity (200), an offset (+100, -50) or an expression. Same rule as NewPrice — a leading + or - makes it an offset, anything else is absolute. Any partial fill is kept out of the new remaining quantity. Default +0.
NewTIF / NewTIFDatenew time in force / GTD date
NewSpInstnew special instructions
AllLegs"true" applies a price offset to every leg of a multi-leg order
Send "true" sends the change to the broker; for unsent capsules and the ticket, this places the order.
On the Account window's Positions tab, Send must be true.
MOVE ALL WORKING ORDERS UP 2 CENTS
{ "Pwd": "mypassword", "Command": { "Disabled": false,
  "ChangeOrder": { "AppliesTo": "All", "NewPrice": "+0.02", "Send": "true" } } }

TradeQty / Account / Symbol

These change the window itself. Each takes a single string value, directly on the command object:

CommandContent
{"TradeQty": "<expr>"}sets the window's trade quantity (ribbon or ticket)
{"Account": "<key|id|name>"}selects the window's trading account
{"Symbol": "<symbol>"}changes the window's symbol

A symbol or account change can itself trigger an echo.

Other actions

ActionFieldsContent
HotkeyEnabled, Hotkeyruns another saved hotkey, identified by its unique ID, when Enabled is "true"
SymbolLinkSymbol, Groupputs a symbol (or the window's, with Default) into a link group
SetIntervarType (Symbol|Global), Name, Valuesets an Intervar. Numeric values are stored as numbers.
ShareTradeEmails, Account, Which (LastExecuted|All|Selected)shares trades with other Medved Trader users
SharePosEmails, Account, Which (All|Selected)shares positions
PlaySoundSoundplays a sound by name or file path (beeps if the file is missing)
LocateReserve, MaxPricePerShare, Prompt, Symbol, Accountrequests a short locate (multiple of 100), with brokers that support locates
RouteCycleRouteListmoves the window's route to the next one in the list
SetFocusFieldfocuses a ticket field: OrderType, Quantity, LimitPrice, StopPrice, TimeInForce, SpecialInstructions (Trade Ticket, and Level II with the compact ticket)

Chart-only actions

ActionContent
ChartParameterchanges ChartType, ColorSet, Draw, Period or Frequency
Axisabsolute, dynamic, dynamicpadded, window, optionally with Centered
DrawTypestarts a drawing tool: line, linealert, box, channel, fib, fibexp, fibfan, fibtime, riskreward, text, circle, oval, triangle, arc, curve, spiral, pitch, scroll
SetChartVar{Name, Value}: sets a chart variable readable by chartvar(). It must be the only action in its command object.
ShowFillsChart and DOM. Shows or hides the window's filled orders, the same as the Chart's Show Filled Orders toggle or the DOM's Fills Shown As combo. Saved with the window's layout.
true or false; "toggle" flips it; on a DOM, "None", "Arrow", "Circle" or "Diamond" pick the shape (true keeps a shape already shown, or uses Arrow).
On a Chart a shape name just turns fills on; the chart's fill shape is the global Charts setting.
TOGGLE FILLED ORDERS (CHART OR DOM)
{ "Pwd": "mypassword", "Command": { "ShowFills": "toggle" } }

Account-only actions

These work only on an Account window. Sent anywhere else, including the global hotkey window, they are refused with "TransFilter only works on the Account window."

ActionFieldsContent
TransFilterStatus sets the Status filter of the Transactions tab, the same as choosing it in the ribbon's Status box. If the window is on another tab, it switches to Transactions first.
Status is one of ALL (no filter), AllOpen, AllOpenFilled, AllFilled, AllBuyFills, AllSellFills, AllOther. Letter case does not matter, and the text shown in the Status box ("All Open") is accepted too.
The choice is saved with the window's layout. The symbol and days filters are left as they are.
SHOW ONLY WORKING ORDERS
{ "Pwd": "mypassword", "Command": { "TransFilter": { "Status": "AllOpen" } } }

Syntax

String values are evaluated as C#-style expressions (+ - * / %, comparisons, && || !, ? :). The syntax is relaxed:

Numbers are decimals. A condition is true when it is non-zero.

Offsets and pegs

FormMeaning
"+0.05" / "-0.05"offset in points from the base price. The base is the last trade, or for secondary conditional legs, the main leg's price.
"+1%" / "-0.5%"offset in percent
offset(x)turns a computed number into a points offset
peg(base, x)pegged price base + x, where base is bid, ask, price or mid. It must be the whole field. Dropped into a Trade Ticket or Level II, it sets the ticket's peg mode.
pegpct(base, x)pegged price base × (1 + x/100)

A price expression without a sign is an absolute price: "Bid-0.01" is a price, while "-0.01" is an offset.

Functions

FunctionContent
abs, min, maxas usual
round(x), round_dig(x,n), round_inc(x,inc)round to an integer, to n decimals, or to a multiple of inc
floor…, ceil…same three forms: floor, floor_dig, floor_inc, ceil, ceil_dig, ceil_inc
symbolprice(s), symbolbid(s), symbolask(s), symbolticksize(s)quotes for another symbol (it must already be streaming in MT)
symbolrecent(s, secs)recent price of symbol s over the given number of seconds
intervar('name'), intervarg('name')symbol / global Intervar value
chartvar('name')chart variable (Chart)
bead(n)price of chart bead n, 1–20 (Chart)
l2bid(n), l2ask(n), l2bidsize(n), l2asksize(n)Level II book row n, 0–99: price or size (Level II)
randint(a,b), randfloat(a,b)random number

Variables

Variables come from the target window's current symbol, account and state. Mouse and capsule variables only make sense on a Chart or DOM with the mouse over it; outside that they are 0, and an order that uses them is refused.

GroupVariables
QuotePrice (last), Bid, Ask, Mid, TickSize, CostMult, PrevClose, TodayOpen, TodayHigh, TodayLow
QuantityDefaultQty: the quantity in the window's trading ribbon or ticket
PositionPos (negative if short), PosAbs, PosPaid (base price), CurrencyPos (crypto pairs)
FillsLastFillPrice, LastFillQty, FirstFillPrice, FirstFillQty, each also with a …Bought / …Sold suffix (e.g. LastFillPriceSold)
Account Account, Broker, Cash, AccountValue, DaytradeBP, OvernightBP, IsHTB, LocateReserved, LocateAvailable
Window stateCurrentAction (Buy/Sell; Trade Ticket, Level II, DOM), CurrentSpInst, TradeTicketVisible, TicketLimitPrice, TicketStopPrice (Trade Ticket, Level II)
Mouse / capsule (Chart, DOM)PriceAtMouse; for the capsule under the mouse: CapPrice, CapQty, CapAction, CapOrderType
Candles (Chart)BarOpen, BarHigh, BarLow (current candle); BarOpen1..3, BarHigh1..3, BarLow1..3, BarClose1..3 (1–3 candles back); NumBeads
Risk/Reward (Chart)RiskRewardQty, RiskRewardEntry, RiskRewardTarget, RiskRewardStop, taken from the risk/reward annotation (the one under the mouse, or the only one)
Time / sessionNow, DayStart, DayEnd, SessionStart, SessionEnd (all UTC); PreMarket, RegSession, AfterMarket (true/false); MinIntoSession
ChangeOrder onlyOrderQty, OrderPrice, OrderType, OrderIsBuy, OrderIsSell, OrderIsUnsent, CurrentTIF

Vars and If

Vars declares your own variables, which the commands can then use by name. They are evaluated in order, so a later variable can use an earlier one. Global Vars defined in the Hotkey editor are evaluated first. An optional If member (one object or an array) sets variables conditionally:

VARS
"Vars": {
  "Half": "round(PosAbs/2)",
  "Side": "if Pos > 0 then 'Sell' else 'Buy'",
  "If": [
    { "Condition": "PreMarket or AfterMarket", "Then": { "Tif": "'Day_ext'" }, "Else": { "Tif": "'Day'" } }
  ]
}

Inside Then / Else, values must be strings: "5", not 5. Numeric JSON values there are ignored.


EchoTo

A statement can ask the target window to report its current state back to you. That report is the echo. It is produced when the statement has passed the password check, and before its commands run.

NameReqContent
EchoClientMsgYany JSON object; it is returned to you unchanged. No echo is produced without it. {} is enough.
EchoToN where the echo goes:
"api" (default): as an APIKeyPressUpdate to every connected WebSocket API session.
"hwnd": a WM_COPYDATA to the window in hwnd.
"clipboard": the clipboard.
hwndNfor "hwnd": your window's handle, as a decimal integer
ChangeNsubscribe to window changes; see Change notifications

For "hwnd", MT sends (not posts) WM_COPYDATA with dwData = 1 and lpData = the echo JSON as a NUL-terminated UTF-16 string. Handle it promptly, because MT's window waits while you process it.

A payload that MT splits into several statements (for example, orders for several accounts) can produce more than one echo.

JUST ASK THE WINDOW FOR ITS STATE
{ "Pwd": "mypassword", "EchoTo": "hwnd", "hwnd": 3148874, "EchoClientMsg": { "id": "q1" },
  "Command": { "Disabled": false, "TradeQty": "DefaultQty" } }

A statement needs at least one command that is not disabled, or it is dropped before any echo is made. Setting TradeQty to DefaultQty changes nothing, so it works as a harmless placeholder command.

Change notifications

Add a Change list to a statement that has EchoTo and EchoClientMsg. It can contain any of Symbol, Account, TradeQty, or All, e.g. "Change": "Symbol,TradeQty". From then on, whenever a trading window's symbol, account or trade quantity changes, it sends an echo to the same destination, with "Change" set to "symbol", "account" or "tradeqty".

Echo payload

NameTypeContent
windowstringwindow class: ChartWindow, LevelIIWindow, DOMWindow, TradeTicketWindow, TradeAccountView
handlestringthe window's HWND (decimal); use it as a WM_COPYDATA target
symbolstringthe window's symbol
dataobjectthe symbol's snapshot: sym, companyName, bid, ask, last, volume, prevClose, open, high, low, … (same fields as the WebSocket API's getSymbolSnapshot)
tradeAccountobjecttradingSite, accountID, accountName, accountKey; present if the window has an account
priceAtMouse, timeAtMousenumber, stringChart only
positionobjectChart only: qty, paid
TradeQtynumberthe window's trade quantity (Chart, DOM: ribbon; Trade Ticket, Level II: ticket)
Changestringsymbol, account or tradeqty, only in change notifications
ClientMsg / clientMsgobjectyour EchoClientMsg. It is ClientMsg for hwnd and clipboard echoes, and clientMsg in an APIKeyPressUpdate.
EXAMPLE ECHO (hwnd)
{
  "window": "LevelIIWindow", "handle": "2951610", "symbol": "BAC",
  "data": { "sym": "BAC", "companyName": "Bank of America Corp", "bid": "46.12", "ask": "46.13", "last": "46.12", "…": "…" },
  "tradeAccount": { "tradingSite": "SCHWAB", "accountID": "12345678", "accountName": "Main", "accountKey": "SCHWAB:12345678" },
  "TradeQty": 100,
  "Change": "symbol",
  "ClientMsg": { "id": "q1" }
}

Per-window behaviour

WindowBehaviour
Trade Ticket Trading must be enabled.
Supports Order (Drop fills the ticket), Cancel (Open only), ChangeOrder (edits the ticket; Send submits it), TradeQty, RouteCycle and SetFocus.
Level II Supports the same actions as Trade Ticket.
Orders are always for the window's symbol.
ChangeOrder with Send "true" modifies the working order on the book: the only one on that side, the one under the mouse, or the locked one.
Chart Drop creates a capsule on the chart; Cancel supports Unsent, UnderMouse and LastOpen; ChangeOrder works on capsules.
Adds the chart-only actions, mouse and candle variables, bead() and chartvar().
DOM Drop creates a capsule; Cancel supports Unsent and UnderMouse.
PriceAtMouse comes from the price row under the mouse.
Also supports ShowFills.
Account Only ChangeOrder and Cancel, on the Transactions or Positions tab, plus TransFilter (any tab; it switches to Transactions).
Variables come from the highlighted row's symbol.
Cancel Open "All" cancels across every symbol with open orders.

Examples

SELL HALF THE POSITION 1 CENT UNDER THE ASK, AND SEND
{
  "Pwd": "mypassword",
  "Vars": { "Half": "round(PosAbs/2)" },
  "Command": { "Disabled": false, "Order": { "Send": "true",
    "Legs": [ { "Action": "Sell", "OrderType": "Limit", "Quantity": "Half", "LimitPrice": "Ask-0.01", "TIF": "Day" } ] } }
}
CANCEL, THEN SEND AN OTOCA BRACKET (ENTRY + TARGET + STOP)
{
  "Pwd": "mypassword",
  "Command": { "Disabled": false, "Order": { "Send": "CancelThenSend", "ConditionalType": "OTOCA",
    "Legs": [
      { "Action": "Buy",  "OrderType": "Limit",      "Quantity": "DefaultQty", "LimitPrice": "Ask" },
      { "Action": "Sell", "OrderType": "Limit",      "LimitPrice": "+0.50" },
      { "Action": "Sell", "OrderType": "StopMarket", "StopPrice": "-0.25" }
    ] } }
}
SWITCH THE WINDOW TO A SYMBOL, SET QTY, DROP A LIMIT ORDER (NOT SENT)
{
  "Pwd": "mypassword",
  "Command": [
    { "Disabled": false, "Symbol": "AAPL" },
    { "Disabled": false, "TradeQty": "50" },
    { "Disabled": false, "Order": { "Drop": "true", "Send": "false",
      "Legs": [ { "Action": "Buy", "OrderType": "Limit", "LimitPrice": "Bid" } ] } }
  ]
}
FLATTEN EVERYTHING IN A SPECIFIC ACCOUNT
{ "Pwd": "mypassword", "Command": { "Disabled": false,
  "Flatten": { "Account": "SCHWAB:12345678", "Symbol": "AllSymbols", "Position": "Both" } } }

Enumerations

NameValues
OrderActionBuy, Sell, Short, Cover, BuyOpen, BuyClose, SellOpen, SellClose, None (= do not place)
OrderTypeMarket, Limit, StopMarket, StopLimit, TStopDLR, TStopPT, TStopTick, TStopLimit, MOO, MOC, LOO, LOC, Bracket, NetDebit, NetCredit, NetZero
TIFDay, GTC, Day_ext, GTC_ext, GTD, GTD_ext, MOC, AM, PM, IOC, Day_During, Overnight (availability depends on the broker)
ConditionalTypeNone, OCA, OTA, OTT, OTOCA, OTOTA
SpInstructionsAON, FOK, DNR, Hidden, PostOnly, Anon
Link group colorsBlue, Green, Red, Cyan, Brown, Black, Gray, Pink, Purple, LawnGreen, Maroon, Yellow, Olive, Iris, Tan, Apricot, Beige, Mint, Lime, Salmon, NeonPink, Crimson, Khaki, Teal, Chocolate, Active