Multi-symbol robots and indicators

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 19 Dec 2017, 14:54
Multi-symbol robots and indicators

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
gunning.ernie since: 18 Dec 2017; 
 21 Dec 2017, 06:46
RE:

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

irmscher9's avatar
irmscher9 since: 22 Dec 2016; 
 16 Mar 2018, 18:49

Backtesting of Multiple Symbols in on bot still not supported?

GammaQuant since: 14 Jun 2017; 
 17 May 2018, 23:43
Multi-symbol robots and indicators - Which Symbol Invoked OnTick?????

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?

Panagiotis Charalampous's avatar
Panagiotis Charalampous since: 13 Jan 2017; 
 18 May 2018, 11:56

Hi GammaQuant,

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

Best Regards,

Panagiotis

Head of Community Management at cTrader
GammaQuant since: 14 Jun 2017; 
 21 May 2018, 17:16
RE:

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?

GammaQuant since: 14 Jun 2017; 
 21 May 2018, 18:26
RE: RE:

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

ctid491211 since: 10 Jun 2018; 
 10 Jun 2018, 23:23
RE:

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

ctid491211 since: 10 Jun 2018; 
 10 Jun 2018, 23:25
RE:

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

bendyarm's avatar
bendyarm since: 24 Dec 2013; 
 16 Jun 2018, 16:53
RE:

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