// fire new order to MTS
NewEntryOrder = mentts.call("PlaceOrder","GAIN","BUY","MARKET",tempsymbol,(GAINMultiplier*DefEntryContracts),0,"GTC","","","",0);
TradePending = true;
TradeDirection = 1; //long
if ((NewEntryOrder > 0) && (TradePending)) {
// new order placed successfully.
var OrderStatus = mentts.call("GetOrderStatus","GAIN",NewEntryOrder);
if (OrderStatus == "FILLED") {
if (TradeDirection > 0) { // long
StrategyisInTrade = true;
StrategyisLong = true;
StrategyisShort = false;
TradeAmount = mentts.call("GetFillAmount","GAIN",NewEntryOrder);
EntryPrice = mentts.call("GetFillPrice","GAIN",NewEntryOrder);
TradePending = false;
TradeDirection = 0;
}
if (TradeDirection < 0) { // Short
StrategyisInTrade = true;
StrategyisLong = false;
StrategyisShort = true;
TradeAmount = mentts.call("GetFillAmount","GAIN",NewEntryOrder);
EntryPrice = mentts.call("GetFillPrice","GAIN",NewEntryOrder);
TradePending = false;
TradeDirection = 0;
}
}
if (OrderStatus == "CANCELLED") {
TradePending = false;
TradeDirection = 0;
NewEntryOrder = 0;
}
}