Indiscriminately closes all open positions

Namespace: RightEdge.Common
Assembly: Common (in Common.dll) Version: 2010.1.0.0 (2010.1.0.0)

Syntax

C#
public ReturnCode CloseAllPositions()
Visual Basic
Public Function CloseAllPositions As ReturnCode
Visual C++
public:
ReturnCode^ CloseAllPositions()
F#
member CloseAllPositions : unit -> ReturnCode 

Return Value

Type: ReturnCode
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.
C# Copy imageCopy
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();
    }
}
Visual Basic.Net Copy imageCopy
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

See Also