How to count ticks every minute and show on chart
How to count ticks every minute and show on chart
02 Aug 2022, 09:06
How to count ticks every minute and show on chart. Tick must be reset every minute and show on chart
Replies
MongolTrader
02 Aug 2022, 09:45
RE:
PanagiotisCharalampous said:
Hi MongolTrader,
You can create a counter that counts how many times OnTick() has been invoked and reset it every minute. You can use the Timer for this.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
please help me sample code for tick counter
@MongolTrader
PanagiotisCharalampous
02 Aug 2022, 10:07
Hi MongolTrader,
Here is a starting point
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class NewcBot2 : Robot
{
private int _tickCounter;
protected override void OnStart()
{
// To learn more about cTrader Automate visit our Help Center:
// https://help.ctrader.com/ctrader-automate
Timer.TimerTick += Timer_TimerTick;
Timer.Start(60);
}
private void Timer_TimerTick()
{
_tickCounter = 0;
}
protected override void OnTick()
{
// Handle price updates here
_tickCounter++;
Print(_tickCounter);
}
protected override void OnStop()
{
// Handle cBot stop here
}
}
}
Best Regards,
Panagiotis
Join us onTelegram andFacebook
@PanagiotisCharalampous
MongolTrader
02 Aug 2022, 10:31
RE:
PanagiotisCharalampous said:
Hi MongolTrader,
Here is a starting point
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; namespace cAlgo.Robots { [Robot(AccessRights = AccessRights.None)] public class NewcBot2 : Robot { private int _tickCounter; protected override void OnStart() { // To learn more about cTrader Automate visit our Help Center: // https://help.ctrader.com/ctrader-automate Timer.TimerTick += Timer_TimerTick; Timer.Start(60); } private void Timer_TimerTick() { _tickCounter = 0; } protected override void OnTick() { // Handle price updates here _tickCounter++; Print(_tickCounter); } protected override void OnStop() { // Handle cBot stop here } } }
Best Regards,
Panagiotis
Thank you very much. Could you tell me more how to sync with bar timer with this timer. Timer not accord bar timer.
@MongolTrader
PanagiotisCharalampous
02 Aug 2022, 09:20
Hi MongolTrader,
You can create a counter that counts how many times OnTick() has been invoked and reset it every minute. You can use the Timer for this.
Best Regards,
Panagiotis
Join us on Telegram and Facebook
@PanagiotisCharalampous