AutoTrader functions are used for connecting to your Trading Platform using AutoTrader as a bridge.
AmiBroker Functions
Place Order
Function | Parameters | Description |
---|---|---|
placeOrderUsingParams | exchange, symbol, tradeType, orderType, quantity, price, triggerPrice, validate | Places an order using parameters defined on the chart |
placeOrder | exchange, instrument, symbol, tradeType, productType, orderType, quantity, price, triggerPrice, optionType, strikePrice, expiry | Places an order |
placeOrderMappedSymbol | symbol, tradeType, productType, orderType, quantity, price, triggerPrice, disclosedQuantity | Places an order using mapped symbol |
placeOrderStock | exchange, instrument, symbol, tradeType, productType, orderType, quantity, price, triggerPrice, disclosedQuantity, strategyId, comments | Places an order for a stock |
placeOrderFuture | exchange, instrument, symbol, tradeType, productType, orderType, quantity, price, triggerPrice, expiry, strategyId, comments | Places an order for a future contract |
placeOrderOption | exchange, instrument, symbol, tradeType, productType, orderType, quantity, price, triggerPrice, optionType, strikePrice, expiry, strategyId, comments | Places an order for a option contract |
placeOrderAdvanced | exchange, 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. |
placeBracketOrder | exchange, symbol, tradeType, quantity, price, target, stoploss, trailingStoploss, validate | Places a LIMIT bracket order using parameters defined on the chart |
placeStoplossBracketOrder | exchange, symbol, tradeType, quantity, price, triggerPrice, target, stoploss, trailingStoploss, validate | Places a STOP_LOSS bracket order using parameters defined on the chart |
placeCoverOrder | exchange, symbol, tradeType, quantity, triggerPrice, validate | Places a cover order using parameters defined on the chart. |
placeOrderAdvancedNew | exchange, 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
Function | Parameters | Description |
---|---|---|
getOrderStatus | order_id | Get order status |
getOrderQty | order_id | Get order quantity |
getOrderPendingQty | order_id | Get order pending quantity |
getOrderFilledQty | order_id | Get order filled quantity |
getOrderPrice | order_id | Get order price |
getOrderAveragePrice | order_id | Get order average price |
getOrderTimestamp | order_id | Get order timestamp |
getOrderPlatformId | order_id | Get order platform id (UPSTOX, NEST, NOW, KITE, ODIN) |
getOrderOrderType | order_id | Get order's order type |
getOrderProductType | order_id | Get order's product type |
getOrderVariety | order_id | Get order's variety |
getOrderParentId | order_id | Get order's parent order id. The child orders generated by BO & CO orders will have parent id. |
getOrderExchange | order_id | Get order's exchange |
getOrderTradingSymbol | order_id | Get order's trading symbol |
getOrderStatusMessage | order_id | Get order's status message or rejection reason |
getOrderTradeType | order_id | Get order's trade type |
isOrderOpen | order_id | Checks whether order is open or trigger pending status |
isOrderComplete | order_id | Checks whether order is complete |
isOrderRejected | order_id | Checks whether order is rejected |
isOrderCancelled | order_id | Checks whether order is cancelled |
Modify, Cancel or Exit Order
Function | Parameters | Description |
---|---|---|
modifyOrderPrice | order_id, price | Modify order price |
modifyOrderQuantity | order_id, quantity | Modify order quantity |
modifyOrder | order_id, orderType, quantity, price, triggerPrice | Modify order If certain fields are not applicable then pass following values orderType = NA quantity = -1 price = -1 triggerPrice = -1 |
cancelOrder | order_id | Cancels the order |
cancelOrExitOrder | order_id | Cancels or exits from order. This function is useful for exiting from bracket and cover order. |
cancelOrderChildren | order_id | Cancels the children orders. This function is useful for exiting from bracket and cover order. |
cancelOrderAtTime | order_id, hh, mm, ss | If 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 |
cancelOrderInSeconds | order_id, cancelInSeconds | If an order is open, then AutoTrader will immediately cancel it after the given seconds have been passed starting from current time |
Position
Function | Parameters | Description |
---|---|---|
squareOffPosition | Square off position as per chart parameters | |
squareOffPos | exchange, tradingSymbol, stopTrading | Square off position for the given trading symbol stopTrading - pass 1 to stop trading completely for the current day, otherwise pass 0 |
getPositionNetQty | tradingSymbol | Get position net quantity |
getPositionBuyQty | tradingSymbol | Get position BUY quantity |
getPositionSellQty | tradingSymbol | Get position SELL quantity |
getPositionM2M | tradingSymbol | Get position M2M |
getPositionPNL | tradingSymbol | Get position P&L |
getPositionBuyPrice | tradingSymbol | Get position buy price |
getPositionSellPrice | tradingSymbol | Get position sell price |
getPositionBuyValue | tradingSymbol | Get position buy value |
getPositionSellValue | tradingSymbol | Get position sell value |
getPositionNetValue | tradingSymbol | Get position net value |
Portfolio
Function | Description |
---|---|
getPortfolioM2M | Get portfolio M2M |
getPortfolioPositionCount | Get count of total positions in portfolio |
getPortfolioOrderCount | Get count of total orders in portfolio |
getPortfolioOpenOrderCount | Get count of total open orders in portfolio |
getPortfolioCompletedOrderCount | Get count of total completed orders in portfolio |
getPortfolioCancelledOrderCount | Get count of total cancelled orders in portfolio |
getPortfolioRejectedOrderCount | Get count of total rejected orders in portfolio |
Funds/Margin
Function | Description |
---|---|
getFunds | Get total funds (equities) |
getMarginUtilized | Get margin utilized (equities) |
getMarginAvailable | Get margin available (equities) |
getFundsCommodity | Get total funds (commodity) |
getMarginUtilizedCommodity | Get margin utilized (commodity) |
getMarginAvailableCommodity | Get margin available (commodity) |
Parameter Default Value
Function | Description |
---|---|
defaultTraderType | Default Trader Type |
defaultValidity | Default validity |
defaultOptionType | Default Option Type |
defaultExpiry | Default Expiry |
defaultClientId | Default Client Id |
defaultExchange | Default Exchange |
defaultInstrument | Default Instrument |
defaultStrikePrice | Default Strike Price |
defaultDisclosedQuantity | Default Disclosed Quantity |
defaultTriggerPrice | Default Trigger Price |
defaultMarketProtectionPct | Default Market Protection Percentage |
defaultStrategyId | Default Strategy Id |
Miscellaneous
Function | Parameters | Description |
---|---|---|
atStaticVarSet | Key, Value | Stores numeric value in static variable by preparing a unique chart specific key |
atStaticVarGet | Key | Retrieves numeric data stored in static variable using a unique chart specific key |
atStaticVarSetText | Key, Value | Stores text value in static variables by preparing a unique chart specific key |
atStaticVarGetText | Key | Retrieves numeric data stored in static variable using a unique chart specific key |
calculateProfitTarget | entryTradeType, entryPrice, profitPct | Calculates profit price |
calculateStoplossTarget | entryTradeType, entryPrice, stoplossPct | Calculates stoploss price |
readQuantityFromFile | filePath, symbol, defaultQty | Useful 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
Function | Parameters | Description |
---|---|---|
symbol | TEXT | It could be a stock symbol or a key which can be mapped to a stock/future/option contract in Mapping menu on AutoTrader |
tradeType | TEXT | BUY, SELL, SHORT, COVER |
productType | TEXT | INTRADAY, DELIVERY, NORMAL |
orderType | TEXT | LIMIT, MARKET, STOP_LOSS, SL_MARKET |
quantity | NUMBER | quantity |
disclosedQuantity | NUMBER | disclosed quantity, pass zero 0 if not applicable |
price | DECIMAL | order price |
triggerPrice | DECIMAL | trigger price (used for stop loss order, in other cases pass zero 0) |
exchange | TEXT | NSE, NFO, BSE, BFO, MCX, NCDEX, CDS (maps to exchange column on NEST terminal) |
instrument | TEXT | EQ, FUTIDX, FUTSTK, OPTIDX, OPTSTK, FUTCUR, OPTCUR, FUTCOM (maps to instrument column on NEST terminal) |
optionType | TEXT | CE, PE (Option type, pass NA if not applicable) |
strikePrice | DECIMAL | strike price, pass zero 0 if not applicable |
expiry | TEXT | expiry date (Example: 28-DEC-2017), pass NA if not applicable |
clientId | TEXT | NEST/NOW client id, pass NA if not applicable |
validity | TEXT | DAY, GTD, GTC, IOC (pass DAY if not applicable) |
traderType | TEXT | PRO, CLI (pass CLI if not applicable) |
marketProtectionPct | DECIMAL | Market protection percentage (Only applicable for Market orders, example 3.0 (which means 3% protection)), pass 0 if not applicable |
strategyId | NUMBER | Id of the strategy which should manage this order, pass -1 if not applicable |
comments | TEXT | Comments for this order, pass NA if not applicable |
validate | NUMBER | Pass 1 to validate the order, pass 0 to skip validation |
variety | TEXT | Order variety (Regular Order, Bracket Order, Cover Order). Valid values: (regular,bo,co,amo) |
target | DECIMAL | Target for bracket order (pass 0 if not applicable) |
stoploss | DECIMAL | Stoploss for bracket order (pass 0 if not applicable) |
trailingStoploss | DECIMAL | Trailing Stoploss for bracket order (pass 0 if not applicable) |