Closes all open positions for the specified symbol.
Namespace:
RightEdge.CommonAssembly: Common (in Common.dll) Version: 2010.1.0.0 (2010.1.0.0)
Syntax
| C# |
|---|
public ReturnCode CloseAllPositions( Symbol symbol ) |
| Visual Basic (Declaration) |
|---|
Public Function CloseAllPositions ( _ symbol As Symbol _ ) As ReturnCode |
| Visual C++ |
|---|
public: ReturnCode^ CloseAllPositions( Symbol^ symbol ) |
Parameters
- symbol
- Type: RightEdge.Common..::.Symbol
Symbol instance.
Return Value
A ReturnCode indicating whether the positions could be closed.
Examples
The following code example demonstrates how to close all open positions if the number of open positions exceeds 2.
CopyC#
CopyVisual Basic.Net
public override void NewSymbolBar(Symbol symbol, BarData bar) { // Get all open positions for this symbol IList<Position> openPositions = PositionManager.GetOpenPositions(symbol); // Check to see if we have more than 2 open positions. If so, that's too // much exposure and we'd like to close them all. if (openPositions.Count > 2) { // Exit out of all positions for this symbol. CloseAllPositions(symbol); } }
Public Overloads Overrides Sub NewSymbolBar(ByVal symbol As Symbol, ByVal bar As BarData) ' Get all open positions for this symbol Dim openPositions As IList(Of Position) = PositionManager.GetOpenPositions(symbol) ' Check to see if we have more than 2 open positions. If so, that's too ' much exposure and we'd like to close them all. If openPositions.Count > 2 Then ' Exit out of all positions for this symbol. CloseAllPositions(symbol) End If End Sub