AutoTrader Functions

AutoTrader functions are used for connecting to your Trading Platform using AutoTrader as a bridge.

AmiBroker Functions

Place Order

FunctionParametersDescription
placeOrderUsingParamsexchange, symbol, tradeType, orderType, quantity, price, triggerPrice, validatePlaces an order using parameters defined on the chart
placeOrderexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, optionType, strikePrice, expiry
Places an order
placeOrderMappedSymbolsymbol, tradeType, productType, orderType,
quantity, price, triggerPrice, disclosedQuantity
Places an order using mapped symbol
placeOrderStockexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, disclosedQuantity, strategyId, comments
Places an order for a stock
placeOrderFutureexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, expiry, strategyId, comments
Places an order for a future contract
placeOrderOptionexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, optionType, strikePrice, expiry, strategyId, comments
Places an order for a option contract
placeOrderAdvancedexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, disclosedQuantity, optionType, strikePrice, expiry,
clientId, validity, traderType, marketProtectionPct, strategyId, comments
Place an order, this function allows you to provide many parameters.
And it can be used to place any kind of order.
It will check whether symbol has a mapping in the system.
If a mapping is found, parameters from the mapping are used; otherwise default parameters are used.
placeBracketOrderexchange, symbol, tradeType, quantity, price,
target, stoploss, trailingStoploss, validate
Places a LIMIT bracket order using parameters defined on the chart
placeStoplossBracketOrderexchange, symbol, tradeType, quantity, price, triggerPrice,
target, stoploss, trailingStoploss, validate
Places a STOP_LOSS bracket order using parameters defined on the chart
placeCoverOrderexchange, symbol, tradeType, quantity, triggerPrice, validatePlaces a cover order using parameters defined on the chart.
placeOrderAdvancedNewexchange, instrument, symbol, tradeType, productType, orderType,
quantity, price, triggerPrice, disclosedQuantity, optionType, strikePrice, expiry,
clientId, validity, traderType, marketProtectionPct, strategyId, comments,
variety, target, stoploss, trailingStoploss
Places an order, this function allows you to fully customize your order

Read Order Details

FunctionParametersDescription
getOrderStatusorder_idGet order status
getOrderQtyorder_idGet order quantity
getOrderPendingQtyorder_idGet order pending quantity
getOrderFilledQtyorder_idGet order filled quantity
getOrderPriceorder_idGet order price
getOrderAveragePriceorder_idGet order average price
getOrderTimestamporder_idGet order timestamp
getOrderPlatformIdorder_idGet order platform id (UPSTOX, NEST, NOW, KITE, ODIN)
getOrderOrderTypeorder_idGet order's order type
getOrderProductTypeorder_idGet order's product type
getOrderVarietyorder_idGet order's variety
getOrderParentIdorder_idGet order's parent order id. The child orders generated by BO & CO orders will have parent id.
getOrderExchangeorder_idGet order's exchange
getOrderTradingSymbolorder_idGet order's trading symbol
getOrderStatusMessageorder_idGet order's status message or rejection reason
getOrderTradeTypeorder_idGet order's trade type
isOrderOpenorder_idChecks whether order is open or trigger pending status
isOrderCompleteorder_idChecks whether order is complete
isOrderRejectedorder_idChecks whether order is rejected
isOrderCancelledorder_idChecks whether order is cancelled

Modify, Cancel or Exit Order

FunctionParametersDescription
modifyOrderPriceorder_id, priceModify order price
modifyOrderQuantityorder_id, quantityModify order quantity
modifyOrderorder_id, orderType, quantity, price, triggerPriceModify order
If certain fields are not applicable then pass following values
orderType = NA
quantity = -1
price = -1
triggerPrice = -1
cancelOrderorder_idCancels the order
cancelOrExitOrderorder_idCancels or exits from order. This function is useful for exiting from bracket and cover order.
cancelOrderChildrenorder_idCancels the children orders. This function is useful for exiting from bracket and cover order.
cancelOrderAtTimeorder_id, hh, mm, ssIf an order is open, then AutoTrader will immediately cancel it after the time has been passed

hh - the hours between 0-23
mm - the minutes between 0-59
ss - the seconds between 0-59
cancelOrderInSecondsorder_id, cancelInSecondsIf an order is open, then AutoTrader will immediately cancel it after the given seconds have been passed starting from current time

Position

FunctionParametersDescription
squareOffPositionSquare off position as per chart parameters
squareOffPosexchange, tradingSymbol, stopTradingSquare off position for the given trading symbol
stopTrading - pass 1 to stop trading completely for the current day, otherwise pass 0
getPositionNetQtytradingSymbolGet position net quantity
getPositionBuyQtytradingSymbolGet position BUY quantity
getPositionSellQtytradingSymbolGet position SELL quantity
getPositionM2MtradingSymbolGet position M2M
getPositionPNLtradingSymbolGet position P&L
getPositionBuyPricetradingSymbolGet position buy price
getPositionSellPricetradingSymbolGet position sell price
getPositionBuyValuetradingSymbolGet position buy value
getPositionSellValuetradingSymbolGet position sell value
getPositionNetValuetradingSymbolGet position net value

Portfolio

FunctionDescription
getPortfolioM2MGet portfolio M2M
getPortfolioPositionCountGet count of total positions in portfolio
getPortfolioOrderCountGet count of total orders in portfolio
getPortfolioOpenOrderCountGet count of total open orders in portfolio
getPortfolioCompletedOrderCountGet count of total completed orders in portfolio
getPortfolioCancelledOrderCountGet count of total cancelled orders in portfolio
getPortfolioRejectedOrderCountGet count of total rejected orders in portfolio

Funds/Margin

FunctionDescription
getFundsGet total funds (equities)
getMarginUtilizedGet margin utilized (equities)
getMarginAvailableGet margin available (equities)
getFundsCommodityGet total funds (commodity)
getMarginUtilizedCommodityGet margin utilized (commodity)
getMarginAvailableCommodityGet margin available (commodity)

Parameter Default Value

FunctionDescription
defaultTraderTypeDefault Trader Type
defaultValidityDefault validity
defaultOptionTypeDefault Option Type
defaultExpiryDefault Expiry
defaultClientIdDefault Client Id
defaultExchangeDefault Exchange
defaultInstrumentDefault Instrument
defaultStrikePriceDefault Strike Price
defaultDisclosedQuantityDefault Disclosed Quantity
defaultTriggerPriceDefault Trigger Price
defaultMarketProtectionPctDefault Market Protection Percentage
defaultStrategyIdDefault Strategy Id

Miscellaneous

FunctionParametersDescription
atStaticVarSetKey, ValueStores numeric value in static variable by preparing a unique chart specific key
atStaticVarGetKeyRetrieves numeric data stored in static variable using a unique chart specific key
atStaticVarSetTextKey, ValueStores text value in static variables by preparing a unique chart specific key
atStaticVarGetTextKeyRetrieves numeric data stored in static variable using a unique chart specific key
calculateProfitTargetentryTradeType, entryPrice, profitPctCalculates profit price
calculateStoplossTargetentryTradeType, entryPrice, stoplossPctCalculates stoploss price
readQuantityFromFilefilePath, symbol, defaultQtyUseful in amibroker scanner to read quantity per symbol
Searches for the symbol in the file passed & returns quantity if symbol found, otherwise default quantity

Function Variables

FunctionParametersDescription
symbolTEXTIt could be a stock symbol or a key which can be
mapped to a stock/future/option contract in
Mapping menu on AutoTrader
tradeTypeTEXTBUY, SELL, SHORT, COVER
productTypeTEXTINTRADAY, DELIVERY, NORMAL
orderTypeTEXTLIMIT, MARKET, STOP_LOSS, SL_MARKET
quantityNUMBERquantity
disclosedQuantityNUMBERdisclosed quantity, pass zero 0 if not applicable
priceDECIMALorder price
triggerPriceDECIMALtrigger price
(used for stop loss order, in other cases pass zero 0)
exchangeTEXTNSE, NFO, BSE, BFO, MCX, NCDEX, CDS
(maps to exchange column on NEST terminal)
instrumentTEXTEQ, FUTIDX, FUTSTK, OPTIDX,
OPTSTK, FUTCUR, OPTCUR, FUTCOM
(maps to instrument column on NEST terminal)
optionTypeTEXTCE, PE (Option type, pass NA if not applicable)
strikePriceDECIMALstrike price, pass zero 0 if not applicable
expiryTEXTexpiry date (Example: 28-DEC-2017), pass NA if not applicable
clientIdTEXTNEST/NOW client id, pass NA if not applicable
validityTEXTDAY, GTD, GTC, IOC (pass DAY if not applicable)
traderTypeTEXTPRO, CLI (pass CLI if not applicable)
marketProtectionPctDECIMALMarket protection percentage
(Only applicable for Market orders, example 3.0
(which means 3% protection)), pass 0 if not applicable
strategyIdNUMBERId of the strategy which should manage this order,
pass -1 if not applicable
commentsTEXTComments for this order, pass NA if not applicable
validateNUMBERPass 1 to validate the order, pass 0 to skip validation
varietyTEXTOrder variety (Regular Order, Bracket Order, Cover Order).
Valid values: (regular,bo,co,amo)
targetDECIMALTarget for bracket order (pass 0 if not applicable)
stoplossDECIMALStoploss for bracket order (pass 0 if not applicable)
trailingStoplossDECIMALTrailing Stoploss for bracket order (pass 0 if not applicable)