-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathcopy_trading_for_oanda.js
40 lines (37 loc) · 1.74 KB
/
copy_trading_for_oanda.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
registerEA(
"copy_trading_for_oanda",
"An EA to copy trading for Oanda(v1.02)",
[],
function (context) { // Init()
},
function (context) { // Deinit()
},
function (context) { // OnTick()
},
function (context) { // OnTransaction()
if (typeof window.pluginForOanda != "undefined") {
var transType = getLatestTransType(context)
if (transType == "Open Trade") {
var trade = getLatestTrans(context)
var tradeSymbolName = getSymbolName(trade)
var tradeOrderType = getOrderType(trade)
var tradeLots = getOpenLots(trade)
if (tradeOrderType == ORDER_TYPE.OP_BUY || tradeOrderType == ORDER_TYPE.OP_BUYLIMIT || tradeOrderType == ORDER_TYPE.OP_BUYSTOP) {
window.pluginForOanda.sendOrder(tradeSymbolName, ORDER_TYPE.OP_BUY, tradeLots)
} else if (tradeOrderType == ORDER_TYPE.OP_SELL || tradeOrderType == ORDER_TYPE.OP_SELLLIMIT || tradeOrderType == ORDER_TYPE.OP_SELLSTOP) {
window.pluginForOanda.sendOrder(tradeSymbolName, ORDER_TYPE.OP_SELL, tradeLots)
}
} else if (transType == "Trade Closed") {
var trade = getLatestTrans(context)
var tradeSymbolName = getSymbolName(trade)
var tradeOrderType = getOrderType(trade)
var tradeLots = getOpenLots(trade)
if (tradeOrderType == ORDER_TYPE.OP_BUY || tradeOrderType == ORDER_TYPE.OP_BUYLIMIT || tradeOrderType == ORDER_TYPE.OP_BUYSTOP) {
window.pluginForOanda.sendOrder(tradeSymbolName, ORDER_TYPE.OP_SELL, tradeLots)
} else if (tradeOrderType == ORDER_TYPE.OP_SELL || tradeOrderType == ORDER_TYPE.OP_SELLLIMIT || tradeOrderType == ORDER_TYPE.OP_SELLSTOP) {
window.pluginForOanda.sendOrder(tradeSymbolName, ORDER_TYPE.OP_BUY, tradeLots)
}
}
}
}
)