Multi-symbol robots and indicators

19 Dec 2017, 14:54Multi-symbol robots and indicators#41
Panagiotis Charalampousposts: 1818since: 13 Jan 2017

Hi gunning.ernie,

The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            var EURUSD = MarketData.GetSymbol("EURUSD");
            var GBPUSD = MarketData.GetSymbol("GBPUSD");
            var EURJPY = MarketData.GetSymbol("EURJPY");
            var USDJPY = MarketData.GetSymbol("USDJPY");
        }

        protected override void OnTick()
        {
            Print("tick");
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

In this case, OnTick() will be invoked for all four symbols.

Let me know if this helps you.

Best Regards,

Panagiotis


Head of Community Management at cTrader
21 Dec 2017, 06:46RE:#42
gunning.ernieposts: 12since: 18 Dec 2017

Panagiotis Charalampous said:

Hi gunning.ernie,

The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            var EURUSD = MarketData.GetSymbol("EURUSD");
            var GBPUSD = MarketData.GetSymbol("GBPUSD");
            var EURJPY = MarketData.GetSymbol("EURJPY");
            var USDJPY = MarketData.GetSymbol("USDJPY");
        }

        protected override void OnTick()
        {
            Print("tick");
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

In this case, OnTick() will be invoked for all four symbols.

Let me know if this helps you.

Best Regards,

Panagiotis

Thanks Panagiotis, This helps allot. This is my first stab at cALGO and i have noted on other post the same...they are old. You think certain functionality is not there then it is...

 

Thanks again for the effort.

Ernie

16 Mar 2018, 18:49#43
irmscher9posts: 141since: 22 Dec 2016

Backtesting of Multiple Symbols in on bot still not supported?

17 May 2018, 23:43Multi-symbol robots and indicators - Which Symbol Invoked OnTick?????#44
GammaQuantposts: 37since: 14 Jun 2017

Hi Panagiotis or anyone else who knows

on testing this code above the cAlgo Symbol Interface only returns symbol data for the symbol that is selected with calgo to run the robot with but will invoke on ticks from the four symbols entered in the OnStart method.

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;
using cAlgo.Indicators;
 
namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }
 
        protected override void OnStart()
        {
            var EURUSD = MarketData.GetSymbol("EURUSD");
            var GBPUSD = MarketData.GetSymbol("GBPUSD");
            var EURJPY = MarketData.GetSymbol("EURJPY");
            var USDJPY = MarketData.GetSymbol("USDJPY");
        }
 
        protected override void OnTick()
        {
            Print("Symbol -" + Symbol.Code + " |  Bid = " + Symbol.Bid );
        }
 
        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

How do i tell OnTick Method or Symbol Interface which Symbol Invoked it?

18 May 2018, 11:56#45
Panagiotis Charalampousposts: 1818since: 13 Jan 2017

Hi GammaQuant,

Unfortunately you cannot tell for which Symbol was the OnTick() called.

Best Regards,

Panagiotis


Head of Community Management at cTrader
21 May 2018, 17:16RE:#46
GammaQuantposts: 37since: 14 Jun 2017

Panagiotis Charalampous said:

Hi GammaQuant,

Unfortunately you cannot tell for which Symbol was the OnTick() called.

Best Regards,

Panagiotis

Hi Panagiotis

thank you for the last reply

Ok so i was trying to make some kind of work around property that invoke my own tick method on change but cAlgo wont build and gives me an error:

Unable to load assembly: "EurUsd" parameter must be an auto-property

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class MultiSymbolTest : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        public SymbolEvent EurUsd
        {
            get { return EurUsd; }
            set
            {
                var eurUsd = MarketData.GetSymbol("EURUSD");
                EurUsd = new SymbolEvent 
                {
                    Bid = eurUsd.Bid,
                    Ask = eurUsd.Ask
                };
                MyOnTick(eurUsd);
            }
        }

        protected override void OnStart()
        {
            // Put your initialization logic here
            var EURUSD = MarketData.GetSymbol("EURUSD");
            //var GBPUSD = MarketData.GetSymbol("GBPUSD");
            //var EURJPY = MarketData.GetSymbol("EURJPY");
            //var USDJPY = MarketData.GetSymbol("USDJPY");
        }

        /*protected override void OnTick()
        {
            // Put your core logic here
            Print("Symbol -" + Symbol.Code + " |  Bid = " + Symbol.Bid);
        }*/

        private void MyOnTick(Symbol symbol)
        {
            Print("Symbol -" + Symbol.Code + " |  Bid = " + Symbol.Bid);
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }

    public struct SymbolEvent
    {
        public double Ask;
        public double Bid;
    }
}

Wht is the situation with preset properties and calgo?

21 May 2018, 18:26RE: RE:#47
GammaQuantposts: 37since: 14 Jun 2017

Sorry forget the above.........

10 Jun 2018, 23:23RE:#48
ctid491211posts: 6since: 10 Jun 2018

Panagiotis Charalampous said:

Hi gunning.ernie,

The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            var EURUSD = MarketData.GetSymbol("EURUSD");
            var GBPUSD = MarketData.GetSymbol("GBPUSD");
            var EURJPY = MarketData.GetSymbol("EURJPY");
            var USDJPY = MarketData.GetSymbol("USDJPY");
        }

        protected override void OnTick()
        {
            Print("tick");
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

In this case, OnTick() will be invoked for all four symbols.

Let me know if this helps you.

Best Regards,

Panagiotis

Hi!

Nice Trading Software! I came to the point, that I need to "subscribe" to multiple Symbols in one of my strategies. Now I just found your comment on this behaviour. Sadly there is nothing about this subject in the reference documentation (the documentation is really very minimalistic!). Would be nice to have more information about the exact behaviour of GetSymbol()! Clearly it would be nice to referece the Symbol which is updated in the OnTick() Callback Attributes. But I have one more request. Is it possible to Unsubscribe from a specific Symbol while the Bot / Indicator is running.

Best regards

10 Jun 2018, 23:25RE:#49
ctid491211posts: 6since: 10 Jun 2018

Panagiotis Charalampous said:

Hi gunning.ernie,

The information in this post is a bit outdated. OnTick() method is called for all symbols retrieved using MarketData.GetSymbol(). See the following example

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

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class NewcBot : Robot
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        protected override void OnStart()
        {
            var EURUSD = MarketData.GetSymbol("EURUSD");
            var GBPUSD = MarketData.GetSymbol("GBPUSD");
            var EURJPY = MarketData.GetSymbol("EURJPY");
            var USDJPY = MarketData.GetSymbol("USDJPY");
        }

        protected override void OnTick()
        {
            Print("tick");
        }

        protected override void OnStop()
        {
            // Put your deinitialization logic here
        }
    }
}

In this case, OnTick() will be invoked for all four symbols.

Let me know if this helps you.

Best Regards,

Panagiotis

Hi!

Nice Trading Software! I came to the point, that I need to "subscribe" to multiple Symbols in one of my strategies. Now I just found your comment on this behaviour. Sadly there is nothing about this subject in the reference documentation (the documentation is really very minimalistic!). Would be nice to have more information about the exact behaviour of GetSymbol()! Clearly it would be nice to referece the Symbol which is updated in the OnTick() callback attributes. But I have one more request. Is it possible to Unsubscribe from a specific Symbol while the Bot / Indicator is running.

Best regards

16 Jun 2018, 16:53RE:#50
bendyarmposts: 7since: 24 Dec 2013

Panagiotis Charalampous said:

Hi GammaQuant,

Unfortunately you cannot tell for which Symbol was the OnTick() called.

Best Regards,

Panagiotis

Disappointing to see there is no multi-instrument support for back tests.  Can you advise whether this functionality is likely to be available in future?

Thanks,

 

Finn