Buy and Sell#
PowerLanguage provides Buy, Sell, SellShort and BuyToCover order instructions. The syntax of order instructions is composed of Action + Entry/Exit Name and TradeSize + OrderCommandType.
| Action | Entry/Exit Name and TradeSize | OrderCommandType |
|---|---|---|
Buy | [("EntryLabel")] [TradeSize] | OrderCommandType |
Sell | [("ExitLabel")] [From Entry("EntryLabel")] [TradeSize [Total]] | OrderCommandType |
SellShort | [("EntryLabel")] [TradeSize] | OrderCommandType |
BuyToCover | [("ExitLabel")] [From Entry("EntryLabel")] [TradeSize [Total]] | OrderCommandType |
OrderCommandType#
OrderCommandType determines the timing and price of placing an order. There are 4 types:
| OrderCommandType | Description |
|---|---|
This Bar On Close | Sends a market order on the last tick of the current bar. The chart arrow is displayed at the current bar’s closing price. On is a skip word |
Next Bar At Market | Sends a market order on the first tick of the next bar. The chart arrow is displayed at the next bar’s opening price. Market and Open are interchangeable, i.e., Next Bar At Open. At is a skip word |
Next Bar At <Price> Limit | Sends a limit order at price <Price> on the next bar. If the order is not filled by the end of the bar, it is cancelled. The chart arrow is displayed at the fill price that satisfies the limit condition. At is a skip word |
Next Bar At <Price> Stop | Sends a stop order at price <Price> on the next bar. If the order is not filled by the end of the bar, it is cancelled. The chart arrow is displayed at the fill price that satisfies the stop condition. At is a skip word |
In practice, it is not recommended to use
This Bar On Close, as it may cause inconsistencies between live trading and backtesting signals. In live market data, MultiCharts needs to receive the first tick of the next bar to determine that the previous bar has completed; whereas in backtesting, historical data allows the last tick of the bar to be known in advance without waiting for the next bar. See Completed Bars.
Buy Instruction#
Buy instruction places a buy order. If there is a short position when the buy order is filled, the short position will be closed.
Syntax#
| |
| Syntax Element | Description |
|---|---|
EntryLabel | Names the entry, displayed on the chart. Can be omitted; default names are "Buy", "Buy#2", "Buy#3" in order. When selling (Sell), this name can be used to specify which entry to sell |
TradeSize | Number of shares (contracts) to buy, followed by Share/Shares/Contract/Contracts. Can be omitted; defaults to the value in Settings -> Strategy Properties -> Properties -> Fixed Order Shares (Contracts) |
OrderCommandType | Specifies the order type, timing, and price. See OrderCommandType |
Example#
On the next bar, place a market order to buy 1 contract, naming the entry "Entry".
| |
On the next bar, place a limit order at 100 to buy 2 shares.
| |
On the next bar, place a stop order at 50 to buy 10 contracts.
| |
Sell Instruction#
Sell instruction sells long positions.
Syntax#
| |
| Syntax Element | Description |
|---|---|
ExitLabel | Names the exit, displayed on the chart. Can be omitted; default names are "Sell", "Sell#2", "Sell#3" in order |
EntryLabel | Specifies the entry name to sell from. From is a skip word and can be omitted. Can be omitted; defaults to all entry positions |
TradeSize | Specifies the number of shares (contracts) to sell from each long entry position, followed by Share/Shares/Contract/Contracts. If followed by Total, sells on a First In, First Out (FIFO) basis, selling from the earliest entries first, for a total of TradeSize shares (contracts). Can be omitted; defaults to selling all shares (contracts) |
OrderCommandType | Specifies the order type, timing, and price. See OrderCommandType |
Example#
On the next bar, place a market order to sell 10 shares from the entry named "Original Entry".
| |
On the next bar, place a market order to sell 5 contracts from each entry position.
| |
On the next bar, place a limit order at 100 to sell a total of 1 share from all entry positions.
| |
On the next bar, place a stop order at 50 to sell all shares (contracts), equivalent to closing all positions.
| |
SellShort Instruction#
SellShort instruction places a short sell order. If there is a long position when the short sell order is filled, the long position will be closed.
SellShort can also be written as Sell Short (with a space in between).
Syntax#
| |
| Syntax Element | Description |
|---|---|
EntryLabel | Names the entry, displayed on the chart. Can be omitted; default names are "Short", "Short#2", "Short#3" in order. When covering (BuyToCover), this name can be used to specify which entry to cover |
TradeSize | Number of shares (contracts) to short sell, followed by Share/Shares/Contract/Contracts. Can be omitted; defaults to the value in Settings -> Strategy Properties -> Properties -> Fixed Order Shares (Contracts) |
OrderCommandType | Specifies the order type, timing, and price. See OrderCommandType |
Example#
On the next bar, place a market order to short sell 1 contract, naming the entry "Entry".
| |
On the next bar, place a limit order at 100 to short sell 2 shares.
| |
On the next bar, place a stop order at 50 to short sell 10 contracts.
| |
BuyToCover Instruction#
BuyToCover instruction buys to cover short positions.
BuyToCover can also be written as Buy To Cover (with spaces in between).
Syntax#
| |
| Syntax Element | Description |
|---|---|
ExitLabel | Names the exit, displayed on the chart. Can be omitted; default names are "Cover", "Cover#2", "Cover#3" in order |
EntryLabel | Specifies the short entry name to cover. From is a skip word and can be omitted. Can be omitted; defaults to all entry positions |
TradeSize | Specifies the number of shares (contracts) to cover from each short entry position, followed by Share/Shares/Contract/Contracts. If followed by Total, covers on a First In, First Out (FIFO) basis, covering the earliest short entries first, for a total of TradeSize shares (contracts). Can be omitted; defaults to covering all shares (contracts) |
OrderCommandType | Specifies the order type, timing, and price. See OrderCommandType |
Example#
On the next bar, place a market order to cover 10 shares from the entry named "Original Entry".
| |
On the next bar, place a market order to cover 5 contracts from each entry position.
| |
On the next bar, place a limit order at 100 to cover a total of 1 share from all entry positions.
| |
On the next bar, place a stop order at 50 to cover all shares (contracts), equivalent to closing all positions.
| |
Reference#
https://www.multicharts.com/trading-software/index.php?title=Category:Strategy_Orders
https://www.multicharts.com/trading-software/index.php?title=Buy
https://www.multicharts.com/trading-software/index.php?title=Sell
https://www.multicharts.com/trading-software/index.php?title=SellShort
https://www.multicharts.com/trading-software/index.php?title=BuyToCover