Skip to content

LoadMoreHistoryAsync Method (2)

LoadMoreHistoryAsync (1 of 2)

Summary

Loads more historical bars asynchronously.

Signature

1
public abstract void LoadMoreHistoryAsync()

Return Value

void

Declaring Type

cAlgo.API.Bars

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
 using cAlgo.API;
 using System;
 namespace cAlgo
 {
     // A sample indicator that shows how to use Bars
     [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class BarsSample : Indicator
     {
         private TextBlock _barTicksNumberTextBlock, _barsStateTextBlock;
         [Output("Range", LineColor = "RoyalBlue")]
         public IndicatorDataSeries Range { get; set; }
         [Output("Body", LineColor = "Yellow")]
         public IndicatorDataSeries Body { get; set; }
         protected override void Initialize()
         {
             // Bars events
             Bars.BarOpened += Bars_BarOpened;
             Bars.Tick += Bars_Tick;
             Bars.HistoryLoaded += Bars_HistoryLoaded;
             Bars.Reloaded += Bars_Reloaded;
             var grid = new Grid(2, 2)
             {
                 BackgroundColor = Color.DarkGoldenrod,
                 HorizontalAlignment = HorizontalAlignment.Right,
                 VerticalAlignment = VerticalAlignment.Top,
                 Opacity = 0.5
             };
             grid.AddChild(new TextBlock
             {
                 Text = "Bar Ticks #",
                 Margin = 5
             }, 0, 0);
             _barTicksNumberTextBlock = new TextBlock
             {
                 Text = "0",
                 Margin = 5
             };
             grid.AddChild(_barTicksNumberTextBlock, 0, 1);
             grid.AddChild(new TextBlock
             {
                 Text = "Bars State",
                 Margin = 5
             }, 1, 0);
             _barsStateTextBlock = new TextBlock
             {
                 Margin = 5
             };
             grid.AddChild(_barsStateTextBlock, 1, 1);
             IndicatorArea.AddControl(grid);
         }
         private void Bars_Reloaded(BarsHistoryLoadedEventArgs obj)
         {
             _barsStateTextBlock.Text = "Reloaded";
         }
         private void Bars_HistoryLoaded(BarsHistoryLoadedEventArgs obj)
         {
             _barsStateTextBlock.Text = "History Loaded";
         }
         private void Bars_Tick(BarsTickEventArgs obj)
         {
             _barTicksNumberTextBlock.Text = Bars.TickVolumes.LastValue.ToString();
         }
         private void Bars_BarOpened(BarOpenedEventArgs obj)
         {
             _barsStateTextBlock.Text = "New Bar Opened";
         }
         public override void Calculate(int index)
         {
             Range[index] = Bars.HighPrices[index] - Bars.LowPrices[index];
             Body[index] = Math.Abs(Bars.ClosePrices[index] - Bars.OpenPrices[index]);
         }
     }
 }

LoadMoreHistoryAsync (2 of 2)

Summary

Loads more historical bars asynchronously.

Signature

1
public abstract void LoadMoreHistoryAsync(Action<BarsHistoryLoadedEventArgs> callback)

Parameters

Name Type Description
callback Action The callback that will be called after history loaded

Return Value

void

Declaring Type

cAlgo.API.Bars

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
 using cAlgo.API;
 using System;
 namespace cAlgo
 {
     // A sample indicator that shows how to use Bars
     [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
     public class BarsSample : Indicator
     {
         private TextBlock _barTicksNumberTextBlock, _barsStateTextBlock;
         [Output("Range", LineColor = "RoyalBlue")]
         public IndicatorDataSeries Range { get; set; }
         [Output("Body", LineColor = "Yellow")]
         public IndicatorDataSeries Body { get; set; }
         protected override void Initialize()
         {
             // Bars events
             Bars.BarOpened += Bars_BarOpened;
             Bars.Tick += Bars_Tick;
             Bars.HistoryLoaded += Bars_HistoryLoaded;
             Bars.Reloaded += Bars_Reloaded;
             var grid = new Grid(2, 2)
             {
                 BackgroundColor = Color.DarkGoldenrod,
                 HorizontalAlignment = HorizontalAlignment.Right,
                 VerticalAlignment = VerticalAlignment.Top,
                 Opacity = 0.5
             };
             grid.AddChild(new TextBlock
             {
                 Text = "Bar Ticks #",
                 Margin = 5
             }, 0, 0);
             _barTicksNumberTextBlock = new TextBlock
             {
                 Text = "0",
                 Margin = 5
             };
             grid.AddChild(_barTicksNumberTextBlock, 0, 1);
             grid.AddChild(new TextBlock
             {
                 Text = "Bars State",
                 Margin = 5
             }, 1, 0);
             _barsStateTextBlock = new TextBlock
             {
                 Margin = 5
             };
             grid.AddChild(_barsStateTextBlock, 1, 1);
             IndicatorArea.AddControl(grid);
         }
         private void Bars_Reloaded(BarsHistoryLoadedEventArgs obj)
         {
             _barsStateTextBlock.Text = "Reloaded";
         }
         private void Bars_HistoryLoaded(BarsHistoryLoadedEventArgs obj)
         {
             _barsStateTextBlock.Text = "History Loaded";
         }
         private void Bars_Tick(BarsTickEventArgs obj)
         {
             _barTicksNumberTextBlock.Text = Bars.TickVolumes.LastValue.ToString();
         }
         private void Bars_BarOpened(BarOpenedEventArgs obj)
         {
             _barsStateTextBlock.Text = "New Bar Opened";
         }
         public override void Calculate(int index)
         {
             Range[index] = Bars.HighPrices[index] - Bars.LowPrices[index];
             Body[index] = Math.Abs(Bars.ClosePrices[index] - Bars.OpenPrices[index]);
         }
     }
 }

Last update: July 1, 2022

Comments