closeTrade (SDK Trading)

closeTrade is a Fintechee API to close the specific open trade.

closeTrade(brokerName, accountId, tradeId)

EA SDK This function closes the specific open trade. Phase (this API's scope): onTick | deinit

Kind: global function

Param Type Description
brokerName string broker name
accountId string account ID
tradeId string trade ID

closeTrade (SDK Trading)

registerEA(
"test_api",
"An EA to test APIs",
[],
function (context) { // Init()
},
function (context) { // Deinit()
},
function (context) { // OnTick()
    var account = getAccount(context, 0)
	var brokerName = getBrokerNameOfAccount(account)
	var accountId = getAccountIdOfAccount(account)

    var length = getOpenTradesListLength(context)
    for (var i = 0; i < length; i++) {
        var openTrade = getOpenTrade(context, i)
        if (openTrade != null) {
            var tradeId = getTradeId(openTrade)

            closeTrade(brokerName, accountId, tradeId)
        }
    }
})