Countdown for next Bar

Created at 22 Oct 2012, 15:56
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!
adaled's avatar

adaled

Joined 17.09.2012

Countdown for next Bar
22 Oct 2012, 15:56


Hi,

Is it possible to code the countdown for the next Bar? If so how?

Thanks


@adaled
Replies

admin
23 Oct 2012, 09:54

When we introduce multitime frames it will be possible to code the countdown for the next Bar.

Multitime frames are comming soon, so stay tuned!

 


@admin

lec0456
22 Feb 2019, 02:47

Is it now  possible to get the bar countdown programatically?


@lec0456

PanagiotisCharalampous
22 Feb 2019, 10:45

Hi lec0456.

This is not available via the API but I think you can easily code this.

Best Regards,

Panagiotis


@PanagiotisCharalampous

lec0456
22 Feb 2019, 17:42

I did last night!! it opens a form that displays the countdown in a large font.

using System;
using cAlgo.API;
using System.Threading;
using System.Windows.Forms;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class myCandleCountDown : Robot
    {
        [Parameter("Alert On", DefaultValue = true)]
        public bool paramAlertOn { get; set; }

        private Thread _thread;
        private frmCandleCountdown _counter;

        protected override void OnStart()
        {
            Timer.Start(1);
            _counter = new frmCandleCountdown();
            //_thread = new Thread(() =>{ _counter.ShowDialog(); });
            _thread = new Thread(() => { Application.Run(_counter); });
            _thread.SetApartmentState(ApartmentState.STA);
            _thread.Start();    
        }

        protected override void OnTimer()
        {
            int cdMinutes = 14 - Time.Minute % 15;
            int cdSeconds = 59 - Time.Second;
            _thread = new Thread(() => _counter.UpdateCounter(cdMinutes.ToString("00")+":"+cdSeconds.ToString("00")));
            _thread.SetApartmentState(ApartmentState.STA);
            _thread.Start();
            if(cdMinutes==0 && cdSeconds==0 && paramAlertOn)
            Notifications.PlaySound(@"C:\Users\user\Documents\cAlgo\Sources\Robots\CountdownTimer.wav");
        }
    }
} 

I added a simple form with a label and one function.

        public void UpdateCounter(string _text)
        {
            lblCounter.Text = _text;
        }

 


@lec0456