Ticks


Summary

Represents the Ticks interface - the collection of Tick objects.

Syntax

public interface Ticks : IEnumerable

Members

NameTypeSummary
Count PropertyGets the number of objects.
HistoryLoaded EventOccurs when more history is loaded due to chart scroll to the left or due to API call.
Last MethodGets the tick from the end of the list.
LastTick PropertyGets the last tick in the chart.
LoadMoreHistory MethodLoads more historical ticks. Method returns the number of loaded ticks that were added to the beginning of the collection.
LoadMoreHistoryAsync MethodLoads more historical ticks asynchronously.
Reloaded EventOccurs when ticks are refreshed due to reconnect.
SymbolName PropertyGets the symbol name.
this[int index] PropertyGets the specific tick data.
Tick EventOccurs when a new tick appears.

Example 1

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)
        {
        }
    }
}
Reference