Please help get timer sync value of this code

Created at 03 Aug 2022, 09:05
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
MongolTrader's avatar

MongolTrader

Joined 12.02.2015

Please help get timer sync value of this code
03 Aug 2022, 09:05


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
        }
    }
}

In this code counting tick is ok. But how do i get timer sync value of second. I need monitor remaing time. Please help.


@MongolTrader
Replies

PanagiotisCharalampous
03 Aug 2022, 10:55

Hi MongolTrader,

You can do the following

  1. Set the timer to a 1 second interval
  2. Add a counter for seconds and count on each interval
  3. Reset the counters every 60 seconds.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook


@PanagiotisCharalampous

MongolTrader
03 Aug 2022, 10:58

RE:

PanagiotisCharalampous said:

Hi MongolTrader,

You can do the following

  1. Set the timer to a 1 second interval
  2. Add a counter for seconds and count on each interval
  3. Reset the counters every 60 seconds.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Please code me im not sure write this code. 


@MongolTrader