Robot with m ultiple data series

Created at 29 Sep 2017, 04: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!
PE

petra41@bigpond.com

Joined 14.12.2016

Robot with m ultiple data series
29 Sep 2017, 04:56


I cant for the life of me figure out why this is not working, I can't seem to load information from other series into the robot. I found numerous other post explaining how to do it but it just errors to the log. It's like I can't access the information from another pair.

Here is an example.

/forum/whats-new/1531

 

using System;
using System.Linq;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Requests;
using cAlgo.API.Internals;
using cAlgo.Indicators;
using System.IO;
using System.Collections.Generic;

namespace cAlgo
{
    [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class MultiBot : Robot
    {
        private const string MyLabel = "MultiBot";

        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Parameter("Timeframe", DefaultValue = "Minute20")]
        public TimeFrame Timeframe { get; set; }

        private List<RelativeStrengthIndex> ind_rsi_arr = new List<RelativeStrengthIndex>();
        private List<MarketSeries> myPairs_arr = new List<MarketSeries>();
        private List<Symbol> mySymbol_arr = new List<Symbol>();

        public StreamWriter _fileWriter;

        //Manual multi tf instead
        private readonly RelativeStrengthIndex _rsi1, _rsi2, _rsi3, _rsi4, _rsi5;
        private readonly Symbol _sy1, _sy2, _sy3, _sy4, _sy5;
        private readonly MarketSeries _s1, _s2, _s3, _s4, _s5;

        protected override void OnStart()
        {
            // File creation
            #region CreatFile

            int c = 0;
            var desktopFolder = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            var filePath = "";
            do
            {
                string filename = Symbol.Code + c + ".log";
                filePath = Path.Combine(desktopFolder + "\\cAlgo\\EG", filename);
                c++;
            } while (File.Exists(filePath) == true);
            _fileWriter = File.AppendText(filePath);
            _fileWriter.AutoFlush = true;

            #endregion

            try
            {
                Log("Creating all 5 manually");
                var _sy1 = MarketData.GetSymbol("AUDUSD");
                var _sy2 = MarketData.GetSymbol("EURUSD");
                var _sy3 = MarketData.GetSymbol("AUDNZD");
                var _sy4 = MarketData.GetSymbol("AUDCHF");
                var _sy5 = MarketData.GetSymbol("EURGBP");
                Log("Symbols done");

                var _s1 = MarketData.GetSeries("AUDUSD", TimeFrame);
                var _s2 = MarketData.GetSeries("EURUSD", TimeFrame);
                var _s3 = MarketData.GetSeries("AUDNZD", TimeFrame);
                var _s4 = MarketData.GetSeries("AUDCHF", TimeFrame);
                var _s5 = MarketData.GetSeries("EURGBP", TimeFrame);
                Log("Series done");

                var _rsi1 = Indicators.RelativeStrengthIndex(_s1.Close, Periods);
                var _rsi2 = Indicators.RelativeStrengthIndex(_s2.Close, Periods);
                var _rsi3 = Indicators.RelativeStrengthIndex(_s3.Close, Periods);
                var _rsi4 = Indicators.RelativeStrengthIndex(_s4.Close, Periods);
                var _rsi5 = Indicators.RelativeStrengthIndex(_s5.Close, Periods);
                Log("RSI done");

            } catch
            {
                Log("Error occured");
            }

            try
            {
                Log("Attempting to add to List");
                ind_rsi_arr.Add(_rsi1);
                ind_rsi_arr.Add(_rsi2);
                ind_rsi_arr.Add(_rsi3);
                ind_rsi_arr.Add(_rsi4);
                ind_rsi_arr.Add(_rsi5);
                Log("RSI done arry");
                   
                myPairs_arr.Add(_s1);
                myPairs_arr.Add(_s2);
                myPairs_arr.Add(_s3);
                myPairs_arr.Add(_s4);
                myPairs_arr.Add(_s5);
                Log("pairs done arry");
                
                mySymbol_arr.Add(_sy1);
                mySymbol_arr.Add(_sy2);
                mySymbol_arr.Add(_sy3);
                mySymbol_arr.Add(_sy4);
                mySymbol_arr.Add(_sy5);
                Log("symbol done arry");
            } catch
            {
                Log("Error occured");
            }

            Log("Starting robot finished symbol,data,rsi array builds");
        }

        protected override void OnTick()
        {
            //Put your tick logic here
        }

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

Is or has anyone managed to load data from another pair in a robot, I've sene heaps of Indicators that are using the Initialize function but not any robot examples. I want to be able to run backtesting agaisnt multiple currencies so I can see if running the bot overloads the $5,000 accounts.


@petra41@bigpond.com
Replies

PanagiotisCharalampous
29 Sep 2017, 10:13

Hi petra41@bigpond.com,

Thanks for posting in our forum. To make it easier for the community to help you please provide the following

1) A cBot that builds successfully. The one you provided has build errors. Log function is not defined anywhere.

2) Point us exactly to where the problem is. Tell us how do you expect the robot to behave and how it does actually behave.

This information will help us to assist you.

Best Regards,

Panagiotis


@PanagiotisCharalampous

petra41@bigpond.com
29 Sep 2017, 10:44

RE:

Panagiotis Charalampous said:

Hi petra41@bigpond.com,

Thanks for posting in our forum. To make it easier for the community to help you please provide the following

1) A cBot that builds successfully. The one you provided has build errors. Log function is not defined anywhere.

2) Point us exactly to where the problem is. Tell us how do you expect the robot to behave and how it does actually behave.

This information will help us to assist you.

Best Regards,

Panagiotis

Hey mate, I found an atricle that explains that you can't test multpole currencies at the same time in backtesting. Which is exactly what I am trying to do...

/forum/calgo-support/11882

If I can't draw on MarketSeries from other pairs while Im runnign  back tests it would explain why I''m seeing the errrors im seeeing. I can add the Log function in but if the cause is that you have no *access* to other pairs while running backtests then there isn't much point.

I need to be able to test if running this bot across 3-6 pairs with an account size of $5,000 is enough given the exspected draw down. I was trying to do that by reading in the other market data information but not sure it works.....

Given that with my post I've found 6-7 post requesting the same thing is there any idea when this might be working?


@petra41@bigpond.com

petra41@bigpond.com
29 Sep 2017, 10:46

//Log info
        private void Log(string text)
        {
            _fileWriter.WriteLine("Server Time: " + Server.Time);
            _fileWriter.WriteLine("Update: " + text);
        }

This is the log function if anyone wants to add logging to their code.


@petra41@bigpond.com

petra41@bigpond.com
29 Sep 2017, 10:47

Output of the log when I try and run a backtest.

Server Time: 6/27/2017 12:00:00 AM
Update: Creating all 5 manually
Server Time: 6/27/2017 12:00:00 AM
Update: Error occured
Server Time: 6/27/2017 12:00:00 AM
Update: Attempting to add to List
Server Time: 6/27/2017 12:00:00 AM
Update: Starting robot finished symbol,data,rsi array builds

 


@petra41@bigpond.com

PanagiotisCharalampous
29 Sep 2017, 10:48

Hi petra41@bigpond.com,

We still do not have an ETA but it is in our backlog. I will keep you posted.

Best Regards,

Panagiotis


@PanagiotisCharalampous

petra41@bigpond.com
29 Sep 2017, 11:04

RE:

Panagiotis Charalampous said:

Hi petra41@bigpond.com,

We still do not have an ETA but it is in our backlog. I will keep you posted.

Best Regards,

Panagiotis

Thanks is it an issue accessing the data? Can I work around it for now ie, export data to a CSV and use that information instead?


@petra41@bigpond.com

petra41@bigpond.com
29 Sep 2017, 11:17

Thakns again, to add for your Devs it seems to be access to any data outside the data in the backtesting selection.

 

Adding a 1 liner to the OnStart() function can cause the error. Select a pair that is not the pair listed below and run it it will error on OnStart. THis isn't even grabbing market data just the code associated to the data and it doesn't work....

string c_sy1 = MarketData.GetSymbol("EURUSD").Code.ToString();

 

 


@petra41@bigpond.com

petra41@bigpond.com
29 Sep 2017, 11:33

private readonly Symbol _sy1

try
{
          var _sy1 = MarketData.GetSymbol("AUDUSD");
} catch (Exception e)
{
          Log("Error occured " + e.Message);
}

The exception message seems to be an internal message setup to prevent access to other Symbols or MarketData while backtesting?

Update: Error occured GetSymbol is temporarily not supported in backtesting

I'm now aware why it's not working the question is why is it disabled? If you want someone for beta testing enabling this sort of thing and testing the data being downloaded and used within the backtesting toolset, like equity result, sharepee all that stuff let me know I'll gladly stick up my hand and help.


@petra41@bigpond.com

PanagiotisCharalampous
29 Sep 2017, 11:44

Hi petra41@bigpond.com,

It is disabled to prevent other problems that might occur due to not supporting backtesting on multiple symbols. Hopefully, with multiple symbols backtesting this restriction will be removed. 

Best Regards,

Panagiotis


@PanagiotisCharalampous