Opens a position of the specified type.
Namespace:
RightEdge.CommonAssembly: Common (in Common.dll) Version: 2010.1.0.0 (2010.1.0.0)
Syntax
| C# |
|---|
public Position OpenPosition( Symbol symbol, PositionType positionType, OrderType orderType ) |
| Visual Basic (Declaration) |
|---|
Public Function OpenPosition ( _ symbol As Symbol, _ positionType As PositionType, _ orderType As OrderType _ ) As Position |
| Visual C++ |
|---|
public: Position^ OpenPosition( Symbol^ symbol, PositionType positionType, OrderType orderType ) |
Parameters
- symbol
- Type: RightEdge.Common..::.Symbol
the Symbol to open the position for.
- positionType
- Type: RightEdge.Common..::.PositionType
the PositionType. See the PositionType enumeration
- orderType
- Type: RightEdge.Common..::.OrderType
the type of order. See the OrderType enumeration
Return Value
A newly created Position object.
Remarks
This function is used for all order types.
Remarks
If the OpenPosition call succeeded, the Error property of the returned position will be null. If the call failed, then this property will contain a description of the error.
Note that success does not mean that the order was filled by the broker, just that an order was successfully sent to the broker. When this method returns successfully, the PositionState of the returned position will be Pending. If and when the order is filled, the state will change to Open.
Examples
Opening a Position on a band violation (C#)
CopyC#
// Use NewSymbolBar to detect when a new bar has come in. public override void NewSymbolBar(Symbol symbol, BarData bar) { // Retrieve the latest Widner Lower band value. IIndicator widnerLower = Indicators["WidnerLower"][symbol]; double targetPrice = widnerLower[widnerLower.Count - 1]; // Send an order to open a position when the targetPrice is reached (limit order). baseSystem.OpenPosition(symbol, PositionType.Long, OrderType.Limit, targetPrice); }