Multi-symbol robots and indicators

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?

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

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