Ticks
Summary
Represents the Ticks interface - the collection of Tick objects.
Signature
| public abstract interface Ticks
|
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 | using cAlgo.API;
using cAlgo.API.Internals;
namespace cAlgo
{
// This sample indicator shows how to get a symbol ticks data and handle its tick events
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
public class TickSample : Indicator
{
private Ticks _ticks;
[Parameter("Symbol Name", DefaultValue = "EURUSD")]
public string InputSymbolName { get; set; }
protected override void Initialize()
{
// Getting a symbol ticks data
_ticks = MarketData.GetTicks(InputSymbolName);
// Subscribing to upcoming ticks
_ticks.Tick += Ticks_Tick;
_ticks.HistoryLoaded += Ticks_HistoryLoaded;
// You can also pass a callback method instead of subscribing to HistoryLoaded event
//_ticks.LoadMoreHistoryAsync(Ticks_HistoryLoaded);
_ticks.LoadMoreHistoryAsync();
_ticks.Reloaded += Ticks_Reloaded;
}
private void Ticks_Reloaded(TicksHistoryLoadedEventArgs obj)
{
Print("Ticks got reloaded");
}
private void Ticks_HistoryLoaded(TicksHistoryLoadedEventArgs obj)
{
Print("New ticks loaded: #", obj.Count);
}
private void Ticks_Tick(TicksTickEventArgs obj)
{
// Printing Last tick inside Ticks collection
Print(obj.Ticks.LastTick);
}
public override void Calculate(int index)
{
}
}
}
|
Methods
Last
Summary
Gets the last tick in the chart.
Signature
| public abstract Tick Last(int index)
|
Parameters
Name | Type | Description |
index | int | |
Return Value
Tick
LoadMoreHistory
Summary
Loads more historical ticks. Method returns the number of loaded ticks that were added to the beginning of the collection.
Signature
| public abstract int LoadMoreHistory()
|
Return Value
int
LoadMoreHistoryAsync (2)
LoadMoreHistoryAsync (1 of 2)
Summary
Loads more historical ticks asynchronously.
Signature
| public abstract void LoadMoreHistoryAsync()
|
Return Value
void
LoadMoreHistoryAsync (2 of 2)
Summary
Loads more historical ticks asynchronously.
Signature
| public abstract void LoadMoreHistoryAsync(Action<TicksHistoryLoadedEventArgs> callback)
|
Parameters
Name | Type | Description |
callback | Action | The callback that will be called after loading more history |
Return Value
void
GetServerFirstTime
Summary
Returns the first available server tick time.
Signature
| public abstract DateTime GetServerFirstTime()
|
Return Value
DateTime
Properties
Item
Signature
| public abstract Tick Item {get;}
|
Return Value
Tick
LastTick
Summary
Gets the last tick in the chart.
Signature
| public abstract Tick LastTick {get;}
|
Return Value
Tick
Count
Summary
Gets the number of objects.
Signature
| public abstract int Count {get;}
|
Return Value
int
SymbolName
Summary
Gets the symbol name.
Signature
| public abstract string SymbolName {get;}
|
Return Value
string
Events
HistoryLoaded
Summary
Occurs when more history is loaded due to chart scroll to the left or due to API call.
Signature
| public abstract event Action<TicksHistoryLoadedEventArgs> HistoryLoaded;
|
Reloaded
Summary
Occurs when ticks are refreshed due to reconnect.
Signature
| public abstract event Action<TicksHistoryLoadedEventArgs> Reloaded;
|
Tick
Summary
Occurs when a new tick appears.
Signature
| public abstract event Action<TicksTickEventArgs> Tick;
|