Each section below gives the Lipi construct first, then the construct in each language, with a note wherever behaviour differs. The language name links to the documentation the row was checked against.
Enter a position
Opening or adding to a simulated long or short position. In Lipi:strategy.entry. direction is strategy.long or strategy.short. No trail_points, qty_percent or alert_message. A market order fills at the next bar’s open.
Place an order
Placing a simulated order that does not reverse an existing position. In Lipi:strategy.order. A raw net order with no pyramiding check: it can open, add, reduce, close or reverse.
Exit with stop or target
Closing a simulated position with a stop-loss, take-profit or trailing stop. In Lipi:strategy.exit. No trailing-stop arguments. profit and loss are distances in ticks of syminfo.minmove. With no limit, stop, profit or loss the call is ignored.
Close a position
Closing a simulated position, or all of them, at market. In Lipi:strategy.close, strategy.close_all. strategy.close(id) does nothing when that entry is not open. close_all closes the position.
Cancel pending orders
Cancelling simulated orders that have not filled. In Lipi:strategy.cancel, strategy.cancel_all. cancel(id) removes every queued order with that id and does nothing when none exists; cancel_all removes all.
Current position
The size and average price of the open simulated position. In Lipi:strategy.position_size, strategy.position_avg_price. position_size is signed: negative for a short.
Strategy results
Running totals of the simulation: equity, net profit, drawdown, and counts of trades. In Lipi:strategy.equity, strategy.netprofit, strategy.max_drawdown, strategy.closedtrades, strategy.wintrades. equity = initial_capital + netprofit + openprofit. netprofit is realized and net of commission; unrealized profit is openprofit.
Details of each trade
The entry, exit, size and profit of each closed or open simulated trade. In Lipi:strategy.closedtrades_profit, strategy.closedtrades_entry_price, strategy.opentrades_profit. Accessors are flat functions with zero-based trade numbers, such as strategy.closedtrades_profit(0). closedtrades_exit_bar_index always returns 0.
Simulation settings
Starting capital, order size, commission, pyramiding and when orders fill. In Lipi:strategy. Percent commission is notional x value / 100, charged on open and on close. Entries beyond pyramiding are ignored silently.
Raise an alert from code
Sending a notification with a message the script builds, when the script decides. In Lipi:alert. Fires only on realtime bars, only in alert mode, at most once per bar. One string argument; no frequency argument.
Declare an alert condition
Declaring a condition the chart user can turn into an alert. In Lipi:alertcondition. Top level only. title and message must be const strings; the condition must be a boolean series.
Send to a webhook
Delivering an alert’s message to an outside address. In Lipi:alert. The script only builds the message string (write JSON in single quotes); no argument sets a webhook address.