PlaceOrder( <Broker>, <Direction>, <OrderType>, <Symbol>, <Qty>, <LimitPrice>, <TimeInForce>, <IBExchange>, <IBType>, <IBExpiration>, <AuxPrice>, <IBCurrency> );
<Broker> |
The selected Broker to fire the order to |
<Direction> |
"BUY" or "SELL" |
<OrderType> |
GAIN Order Types "MARKET" = Market Order "LIMIT" = Limit Order "STOPLOSS" = StopLoss Order
IB Market types "MKT" = Market Order "MKTCLS" = Market On Close Order "LMT" = Limit Order "LMTCLS" = Limit On Close "PEGMKT" = Pegged to Buy on Best Offer/Sell on Best Bid "STP" = Stop Order "STPLMT" = Stop Limit Order "TRAIL" = Trailing Order "REL" = Relative Order "VWAP" = Volume-Weighted Avg Price Order
see IB Docs for definitions of orders... |
<Symbol> |
The symbol you want to trade (See Special SYMBOLOGY instructions for IB) |
<Qty> |
The QUANTITY you want to trade (positive #) |
<LimitPrice> |
The selected LIMIT PRICE (for LIMIT orders only) |
<TimeInForce> |
Gain Order Options "GTC" "EOD"
IB Order Options "GTC" = Good Till Cancelled "DAY" = Day Order "FOK" = Fill or Kill
see IB Docs for definitions of orders... |
<IBExchange> |
The selected EXCHANGE to execute the trade through ** IB Only |
<IBType> |
The type of security/market being traded ** IB Only "STK" "OPT" "FUT" "IND" "FOP" "CASH" "BAG" |
<IBExpiration> |
"YYYYMM" for example "200703" or "200706" ** IB Only Notice - this should be passed a "" for all futures contract orders and the symbol should reflect the expiration
example:
EntryOrderID=mentts.call("PlaceOrder","IB","SELL","MKT","ESH7",1,0,"GTC","GLOBEX","FUT","",0); Sells 1 ES March 07 contract at Market |
<IBAuxPrice> |
The Auxilary price for the the STOPLIMIT ** IB Only |
| <IBCurrency> | The Currency type for the traded instrument ** IB Only |
This function places a new order to the selected broker with the selected parameters. Users should then use the following MTS functions..
GetBrokerStatus() to verify
MTS is connected to the selected broker
IBPlaceOrder() to place an IB Specific order
PlaceOrder() to place a Generic order
PlaceOrderAssoc() to place a new ASSOC(iated) order
ModifyOrderAssoc() to modify an ASSOC order
GetOrderStatus() to get/verify the order status
GetFillPrice() to get the fill price of the order
GetFillAmount() to get the # of filled shares/contracts of the order
Cancel() to properly cancel the order
GetCurrentPosition() to verify the current position of the trading system
Return Values
OrderID MTS returns a valid OrderID for any succesfully submitted order
< 0 MTS returns a NEGATIVE NUMBER for any REJECTED order
Gain Capital Example
var GAINMultiplier = 100000;
var DefEntryContracts = 1;
LEntryOrderID = mentts.call("PlaceOrder","GAIN","BUY","MARKET","GBP/USD",(GAINMultiplier*DefEntryContracts),0,"GTC","", "", "", 0, "");
This command places a MARKET order for 100000 GBP/USD into GAIN.
LEntryOrderID = mentts.call("PlaceOrder","GAIN","BUY","LIMIT","GBP/USD",(GAINMultiplier*DefEntryContracts),(close()-0.0005),"GTC","",
"", "", 0, "");
This command places a LIMIT order for 100000 GBP/USD
into GAIN @ the current closing price minus 5 pips.
IB Example
var DefEntryContracts = 100;
LEntryOrderID = mentts.call("PlaceOrder","IB","BUY","MKT","IBM",DefEntryContracts,0,"GTC","SMART", "STK", "", 0, "USD");
This command places a BUY MARKET order for 100 IBM into IB as at GTC order.
LEntryOrderID = mentts.call("PlaceOrder","IB","BUY","LMT","IBM",DefEntryContracts, 89.00,"GTC","SMART", "STK", "", 0, "USD");
This command places a BUY LIMIT order @ 89.00 for 100 IBM into IB as at GTC order.
LEntryOrderID = mentts.call("PlaceOrder","IB","BUY","STPLMT","IBM",DefEntryContracts, 89.00,"GTC","SMART", "STK", "", 89.25, "USD");
This command places a BUY STOP/LIMIT order @ 89.00 for 100 IBM into IB as at GTC order WHEN IBM reaches 89.25.