MarketOrder (Function)

image\trumpet2.gif Disclaimer

The MarketOrder function is used to configure and send a market order using the order entry macro .PlaceOrder.  You can call this function directly from your own EasyLanguage code to simplify the formatting and generation of macro orders.

  Care should be exercised when calling this function as it is intended to send live orders.  Confirmations for macro-generated orders can be configured by using the File -> Preferences -> TradeStation Order Entry menu sequence.

Syntax

MarketOrder(Frequency,Account,Action,SymbolCategory,Symbol,Quantity)

Returns (Integer)

MarketOrder returns 1 if called on a "real-time" tick and if a trade is allowed based on the user input "Frequency".  The function returns -1 (negative one) in other cases; for example, if the function is called on an historical bar.  If there are errors in the order parameters a runtime error message will be generated and the order will not be placed.

Parameters

Name

Type

Description

Supported Values

Frequency

String

Sets the order frequency.

Once, OncePerBar, EndOfBar, Always

Account

String

Sets the TradeStation account to be used for this order.  

Account string

Action

String

Sets the order action.

Buy, Sell, SellShort, BuyToCover, BuyToOpen, BuyToClose, SellToOpen, SellToClose

SymbolCategory

String

Sets the trading category for the symbol.

Equity, Future, Forex, EquityOption, FutureOption

MySymbol

String

Sets the symbol to be used for this order.

Symbol string

Quantity

Numeric

Sets the number of shares, contracts, lots, etc. to be placed for this order.

Number

Remarks

The MarketOrder function uses the PlaceOrder function to format the order parameters and call the order entry macro.  The PlaceOrder function is only intended to be used by this and other designated TradeStation functions.

This function disables advanced order placement features (All or None, Buy on minus,Sell on plus, etc.).  

See .PlaceOrder command for more information on using the command line macro for placing orders.

Example

Places a buy order of 100 shares for MSFT at market using the order entry macro .PlaceOrder.  Value1 returns a 1 if the order is valid.  

Value1 = MarketOrder("Once","SIM15180","Sell","Equity","MSFT",100);

See Also

LimitIfTouchedOrder, LimitOrder, MarketIfTouchOrder, StopLimitOrder, StopMarketOrder, TrailingStopOrder