PINE LIBRARY
OrderTicketBuilder

Library "OrderTicketBuilder"
Assembles broker order ticket payloads as JSON strings.
BuildTicket(licenseId, symbol, action, orderType, tradeType, size, price, tp, sl, risk, trailPrice, trailOffset)
BuildTicket assembles a JSON order ticket string for downstream execution.
Parameters:
licenseId (string): License identifier
symbol (string): Symbol to trade
action (string): "MRKT" or "PENDING"
orderType (string): "BUY" or "SELL"
tradeType (string): "SPREAD" or "SINGLE"
size (float): (Optional) Trade size
price (float): (Optional) Price for pending orders
tp (float): (Optional) Take profit
sl (float): (Optional) Stop loss
risk (float): (Optional) Percent risk if size unspecified
trailPrice (float): (Optional) Trailing-stop trigger price
trailOffset (float): (Optional) Trailing-stop offset
Returns: JSON order ticket string
Assembles broker order ticket payloads as JSON strings.
BuildTicket(licenseId, symbol, action, orderType, tradeType, size, price, tp, sl, risk, trailPrice, trailOffset)
BuildTicket assembles a JSON order ticket string for downstream execution.
Parameters:
licenseId (string): License identifier
symbol (string): Symbol to trade
action (string): "MRKT" or "PENDING"
orderType (string): "BUY" or "SELL"
tradeType (string): "SPREAD" or "SINGLE"
size (float): (Optional) Trade size
price (float): (Optional) Price for pending orders
tp (float): (Optional) Take profit
sl (float): (Optional) Stop loss
risk (float): (Optional) Percent risk if size unspecified
trailPrice (float): (Optional) Trailing-stop trigger price
trailOffset (float): (Optional) Trailing-stop offset
Returns: JSON order ticket string
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Pine library
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in publications is governed by House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.