Skip to content

FindLast Method (5)

FindLast (1 of 5)

Summary

Find last historical trade by its label

Signature

1
public abstract HistoricalTrade FindLast(string label)

Parameters

Name Type Description
label string Label to search by

Return Value

HistoricalTrade

Declaring Type

cAlgo.API.History

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 get historical trades and use the account history data
     [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);
         }
     }
 }

FindLast (2 of 5)

Summary

Find last historical trade by its label, symbol name

Signature

1
public abstract HistoricalTrade FindLast(string label, string symbolName)

Parameters

Name Type Description
label string Label to search by
symbolName string Symbol name to search by

Return Value

HistoricalTrade

Declaring Type

cAlgo.API.History

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 get historical trades and use the account history data
     [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);
         }
     }
 }

FindLast (3 of 5)

Summary

Find last historical trade by its label, symbol name and trade type

Signature

1
public abstract HistoricalTrade FindLast(string label, string symbolName, TradeType tradeType)

Parameters

Name Type Description
label string Label to search by
symbolName string Symbol name to search by
tradeType TradeType Trade type to search by

Return Value

HistoricalTrade

Declaring Type

cAlgo.API.History

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 get historical trades and use the account history data
     [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);
         }
     }
 }

FindLast (4 of 5)

Signature

1
public abstract HistoricalTrade FindLast(string label, Symbol symbol)

Parameters

Name Type Description
label string
symbol Symbol

Return Value

HistoricalTrade

Declaring Type

cAlgo.API.History

FindLast (5 of 5)

Signature

1
public abstract HistoricalTrade FindLast(string label, Symbol symbol, TradeType tradeType)

Parameters

Name Type Description
label string
symbol Symbol
tradeType TradeType

Return Value

HistoricalTrade

Declaring Type

cAlgo.API.History


Last update: July 1, 2022

Comments