Bars.BarOpened In 3.7

Created at 05 Dec 2019, 18:03
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!
EO

eofe

Joined 18.06.2019

Bars.BarOpened In 3.7
05 Dec 2019, 18:03


Hi cTrader team,

Firstly, great work on the new 3.7! I’m sure many users can’t wait for it to go live.

Currently, I run a cBot for each symbol I trade on the same time frame as I noticed the bar open and close timing (OnBar) on different symbols may differ by a few seconds.

I plan to consolidate all the symbols into a single cBot using bars.BarOpen to monitor and act whenever the symbol I’m trading opens a new bar.

I have studied the symbol.tick sample you have shared.

Could you also share a sample code for bars.BarOpen to monitor BarOpen events for multiple symbols please? Thanks.


@eofe
Replies

PanagiotisCharalampous
06 Dec 2019, 08:38

Hi eofe,

The bar's open time is taken from the first new tick that will arrive for that bar. This is why you get different opening times.

Regarding sample, I am not sure what do you need exactly but below you can see a very simple example of listening to the BarOpened event

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BarOpenedExample : Robot
    {
        protected override void OnStart()
        {
            var bars = MarketData.GetBars(TimeFrame.Minute, "GBPUSD");
            bars.BarOpened += Bars_BarOpened;
        }

        private void Bars_BarOpened(BarOpenedEventArgs obj)
        {
            Print("New bar created for " + obj.Bars.SymbolName + " at " + obj.Bars.Last(0).OpenTime);
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

 


@PanagiotisCharalampous

eofe
06 Dec 2019, 09:20

RE:

PanagiotisCharalampous said:

Hi eofe,

The bar's open time is taken from the first new tick that will arrive for that bar. This is why you get different opening times.

Regarding sample, I am not sure what do you need exactly but below you can see a very simple example of listening to the BarOpened event

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;

namespace cAlgo.Robots
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BarOpenedExample : Robot
    {
        protected override void OnStart()
        {
            var bars = MarketData.GetBars(TimeFrame.Minute, "GBPUSD");
            bars.BarOpened += Bars_BarOpened;
        }

        private void Bars_BarOpened(BarOpenedEventArgs obj)
        {
            Print("New bar created for " + obj.Bars.SymbolName + " at " + obj.Bars.Last(0).OpenTime);
        }
    }
}

Best Regards,

Panagiotis 

Join us on Telegram

 


that will do fine, Panagiotis. Many thanks.

can we expect 3.7 to be pushed out to brokers by Xmas as you have mentioned in your earlier posts?


@eofe

PanagiotisCharalampous
06 Dec 2019, 09:25

Hi eofe,

Christmas was the target for the Beta :) We cannot give an ETA for release to brokers, it depends on how the Beta testing will go. We will release to brokers as soon as we are confident that 3.7 is stable enough for production environments.

Best Regards,

Panagiotis


@PanagiotisCharalampous

eofe
06 Dec 2019, 09:34

RE:

PanagiotisCharalampous said:

Hi eofe,

Christmas was the target for the Beta :) We cannot give an ETA for release to brokers, it depends on how the Beta testing will go. We will release to brokers as soon as we are confident that 3.7 is stable enough for production environments.

Best Regards,

Panagiotis


Noted Panagiotis. Please don’t make the cTrader fans wait too long!


@eofe