Skip to content

HistoricalTrade

Summary

Represents the historical trade interface.

Signature

1
public abstract interface HistoricalTrade

Namespace

cAlgo.API

Examples

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
 using cAlgo.API;
 using System.Linq;
 namespace cAlgo
 {
     // A sample indicator that shows how to use HistoricalTrade
     [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class HistorySample : Indicator
     {
         private Style _textBlocksStyle;
         private StackPanel _stackPanel;
         private Grid _tradesGrid;
         protected override void Initialize()
         {
             _stackPanel = new StackPanel
             {
                 Orientation = Orientation.Vertical,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 VerticalAlignment = VerticalAlignment.Center,
                 BackgroundColor = Color.Gold
             };
             _textBlocksStyle = new Style();
             _textBlocksStyle.Set(ControlProperty.Margin, 5);
             _stackPanel.AddChild(new TextBox
             {
                 Text = "Your Last 10 Trades",
                 FontWeight = FontWeight.ExtraBold,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 Style = _textBlocksStyle
             });
             Chart.AddControl(_stackPanel);
             UpdateLastTradeTextBlock();
             Positions.Closed += args => UpdateLastTradeTextBlock();
         }
         public override void Calculate(int index)
         {
         }
         private void UpdateLastTradeTextBlock()
         {
             if (_tradesGrid != null)
                 _stackPanel.RemoveChild(_tradesGrid);
             _tradesGrid = new Grid(11, 6);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Symbol",
                 Style = _textBlocksStyle
             }, 0, 0);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Direction",
                 Style = _textBlocksStyle
             }, 0, 1);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Volume",
                 Style = _textBlocksStyle
             }, 0, 2);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Open Time",
                 Style = _textBlocksStyle
             }, 0, 3);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Close Time",
                 Style = _textBlocksStyle
             }, 0, 4);
             _tradesGrid.AddChild(new TextBlock
             {
                 Text = "Net Profit",
                 Style = _textBlocksStyle
             }, 0, 5);
             var lastTenTrades = History.OrderByDescending(iTrade => iTrade.ClosingTime).Take(10).ToArray();
             for (int iRowIndex = 1; iRowIndex <= lastTenTrades.Length; iRowIndex++)
             {
                 var trade = lastTenTrades[iRowIndex - 1];
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.SymbolName,
                     Style = _textBlocksStyle
                 }, iRowIndex, 0);
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.TradeType.ToString(),
                     Style = _textBlocksStyle
                 }, iRowIndex, 1);
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.VolumeInUnits.ToString(),
                     Style = _textBlocksStyle
                 }, iRowIndex, 2);
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.EntryTime.ToString("g"),
                     Style = _textBlocksStyle
                 }, iRowIndex, 3);
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.ClosingTime.ToString("g"),
                     Style = _textBlocksStyle
                 }, iRowIndex, 4);
                 _tradesGrid.AddChild(new TextBlock
                 {
                     Text = trade.NetProfit.ToString(),
                     Style = _textBlocksStyle
                 }, iRowIndex, 5);
             }
             _stackPanel.AddChild(_tradesGrid);
         }
     }
 }

See Also

Properties

ClosingDealId

Summary

Gets the unique closing deal identifier.

Signature

1
public abstract int ClosingDealId {get;}

Return Value

int

PositionId

Summary

Gets the position unique identifier.

Signature

1
public abstract int PositionId {get;}

Return Value

int

SymbolName

Summary

Gets the symbol name.

Signature

1
public abstract string SymbolName {get;}

Return Value

string

TradeType

Summary

The TradeType of the Opening Deal.

Signature

1
public abstract TradeType TradeType {get;}

Return Value

TradeType

VolumeInUnits

Summary

The Volume that was closed by the Closing Deal.

Signature

1
public abstract double VolumeInUnits {get;}

Return Value

double

EntryTime

Summary

Time of the Opening Deal, or the time of the first Opening deal that was closed.

Signature

1
public abstract DateTime EntryTime {get;}

Return Value

DateTime

EntryPrice

Summary

The VWAP (Volume Weighted Average Price) of the Opening Deals that are closed.

Signature

1
public abstract double EntryPrice {get;}

Return Value

double

ClosingTime

Summary

Time of the Closing Deal.

Signature

1
public abstract DateTime ClosingTime {get;}

Return Value

DateTime

ClosingPrice

Summary

The execution price of the Closing Deal.

Signature

1
public abstract double ClosingPrice {get;}

Return Value

double

Label

Summary

The label.

Signature

1
public abstract string Label {get;}

Return Value

string

Comment

Summary

The comment

Signature

1
public abstract string Comment {get;}

Return Value

string

Commissions

Summary

Commission owed

Signature

1
public abstract double Commissions {get;}

Return Value

double

Swap

Summary

Swap is the overnight interest rate if any, accrued on the position.

Signature

1
public abstract double Swap {get;}

Return Value

double

NetProfit

Summary

Profit and loss including swaps and commissions

Signature

1
public abstract double NetProfit {get;}

Return Value

double

GrossProfit

Summary

Profit and loss before swaps and commission

Signature

1
public abstract double GrossProfit {get;}

Return Value

double

Balance

Summary

Account balance after the Deal was filled

Signature

1
public abstract double Balance {get;}

Return Value

double

Pips

Summary

Represents the winning or loosing pips

Signature

1
public abstract double Pips {get;}

Return Value

double

Quantity

Summary

The Quantity (in lots) that was closed by the Closing Deal

Signature

1
public abstract double Quantity {get;}

Return Value

double

Symbol

Summary

Gets the trade symbol.

Signature

1
public abstract Symbol Symbol {get;}

Return Value

Symbol

SymbolCode

Signature

1
public abstract string SymbolCode {get;}

Return Value

string

Volume

Signature

1
public abstract long Volume {get;}

Return Value

long