Indiscriminately closes all open positions
Namespace:
RightEdge.CommonAssembly: Common (in Common.dll) Version: 2010.1.0.0 (2010.1.0.0)
Syntax
| C# |
|---|
public ReturnCode CloseAllPositions() |
| Visual Basic (Declaration) |
|---|
Public Function CloseAllPositions As ReturnCode |
| Visual C++ |
|---|
public: ReturnCode^ CloseAllPositions() |
Return Value
A ReturnCode indicating whether the positions could be closed.
Remarks
This will close all positions regardless of any factor. Use this with caution.
Examples
This example closes all positions regardless of symbol when a condition is triggered.
CopyC#
CopyVisual Basic.Net
public override void NewSymbolBar(Symbol symbol, BarData bar) { // Get all open positions regardless of symbol IList<Position> openPositions = PositionManager.GetOpenPositions(); // Check to see if we have more than 10 positions open if (openPositions.Count > 10) { // Close all positions, we have too much exposure. PositionManager.CloseAllPositions(); } }
Public Overloads Overrides Sub NewSymbolBar(ByVal symbol As Symbol, ByVal bar As BarData) ' Get all open positions regardless of symbol Dim openPositions As IList(Of Position) = PositionManager.GetOpenPositions() ' Check to see if we have more than 10 positions open. If openPositions.Count > 10 Then ' Close all positions, we have too much exposure. CloseAllPositions() End If End Sub