sendOrder (SDK Trading)
sendOrder is a Fintechee API to send a pending order(limit or stop) or a market order.
sendOrder(brokerName, accountId, symbolName, orderType, price, slippage, volume, takeProfit, stopLoss, comment)
EA SDK This function sends order to market. Phase (this API's scope): onTick | deinit
Kind: global function
Param | Type | Description |
---|---|---|
brokerName | string | broker name |
accountId | string | account ID |
symbolName | string | symbol name |
orderType | number | order type(ORDER_TYPE.OP_BUY or OP_SELL or OP_BUYLIMIT or OP_SELLLIMIT or OP_BUYSTOP or OP_SELLSTOP) |
price | number | price(if the order is market order, price should be set by zero) |
slippage | number | always be 0(in this version, the trade will be opened by market price) |
volume | number | lots(100000 units per lot) |
takeProfit | number | take profit |
stopLoss | number | stop loss |
comment | string |
sendOrder (SDK Trading)
registerEA(
"test_api",
"An EA to test APIs",
[],
function (context) { // Init()
var account = getAccount(context, 0)
var brokerName = getBrokerNameOfAccount(account)
var accountId = getAccountIdOfAccount(account)
var symbolName = "EUR/USD"
getQuotes (context, brokerName, accountId, symbolName)
},
function (context) { // Deinit()
},
function (context) { // OnTick()
var account = getAccount(context, 0)
var brokerName = getBrokerNameOfAccount(account)
var accountId = getAccountIdOfAccount(account)
var symbolName = "EUR/USD"
var ask = getAsk(context, brokerName, accountId, symbolName)
var bid = getBid(context, brokerName, accountId, symbolName)
var limitPrice = 0.0003
var stopPrice = 0.0003
var volume = 0.01
// pending order(limit, go long) without take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUYLIMIT, ask-limitPrice, 0, volume, 0, 0, "")
// pending order(stop, go long) without take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUYSTOP, ask+limitPrice, 0, volume, 0, 0, "")
// pending order(limit, go long) with take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUYLIMIT, ask-limitPrice, 0, volume, ask+limitPrice, bid-3*stopPrice, "")
// pending order(stop, go long) with take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUYSTOP, ask+limitPrice, 0, volume, ask+3*limitPrice, bid-stopPrice, "")
// market order(go long) without take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUY, 0, 0, volume, 0, 0, "")
// market order(go long) with take-profit, stop-loss
sendOrder(brokerName, accountId, symbolName, ORDER_TYPE.OP_BUY, 0, 0, volume, ask+limitPrice, bid-3*stopPrice, "")
})