Performance question about MarketData.GetSeries

Created at 24 Apr 2014, 10:15
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!
CB

cbellew

Joined 24.04.2014

Performance question about MarketData.GetSeries
24 Apr 2014, 10:15


Hello,

I am trying to implement a currency strength indicator by taking each major currency and calculating the geometric mean of the relative strength index for that currency against each other major currency and then combining all the geometric means together on one chart. This means I have to make 28 calls to MarketData.GetSeries to get a data series for each of the pairs and create a RelativeStrengthIndex indicator for each pair.

I have created a simple indicator which calculates the time taken for my cAlgo to make a single call to GetSeries, which comes out at around 6 seconds. If I make 28 calls like this, it will take almost 3 minutes. This means I will have to wait almost 3 minutes for my indicator to start, on each chart, which is not ideal.

Is there some way I can make this call take less time? Is there a different call I can make which is faster? Why does this call take so long? Is it downloading the data as well, for a large time period?

I appreciate any help on this matter. It would become prohibitively slow for me to trade using the cTrader platform if there is nothing that can be done.

Thanks in advance.

Chris

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class Slow : Indicator
    {
        protected override void Initialize()
        {
            var start = DateTime.Now;
            MarketData.GetSeries("GBPUSD", TimeFrame);
            var end = DateTime.Now;
            Print((end - start).TotalMilliseconds);
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
        }
    }
}

 


@cbellew
Replies

Spotware
24 Apr 2014, 10:40

There is no other ways to get series. Because of technical reasons GetSeries returns value when next tick comes to the platform. We plan to change this behavior in the future.

If 28 calls take 3 minutes during initialization of one indicator instance, the initialization of several indicators running in parallel supposed to take the same 3 minutes because most of the time all indicators will wait for new ticks.


@Spotware

cbellew
25 Apr 2014, 08:19

RE:

Spotware said:

There is no other ways to get series. Because of technical reasons GetSeries returns value when next tick comes to the platform. We plan to change this behavior in the future.

If 28 calls take 3 minutes during initialization of one indicator instance, the initialization of several indicators running in parallel supposed to take the same 3 minutes because most of the time all indicators will wait for new ticks.

 

That's even worse. I'm fetching on many currencies that may not have ticks for a long time, therefore my indicator could take even longer to start because of these slow ones. Is there any estimate on when this will be changed? I clearly can't use cTrader or cAlgo until this has been changed. Pretty disappointing.

 


@cbellew

Spotware
25 Apr 2014, 10:45

Unfortunately, we cannot provide any time estimate. 


@Spotware

Spotware
01 Sep 2014, 11:56

cbellew, please check cAlgo 1.24. We optimized GetSeries method.


@Spotware

bachapk
26 Aug 2015, 22:30

RE:

Same problem here .. I have a currency strength index indicator which was working good till 26th August 2015. But don't know what went wrong that with 500 history bars calculations the indicator do not loading. As the code is not changed therefore, I am sure something wrong have been done on the cAlgo/cTrader platform side.


@bachapk

ClickAlgo
26 Aug 2015, 23:04

Hi Guys,

I may be missing something, but why can you not run each GetSeries asynchronous using the Task Parallel Library (TPL)? the entire operation should take no longer than the longest call to get the data series.

But I am sure it is not that simple.

Paul.

 


@ClickAlgo

bachapk
26 Aug 2015, 23:21 ( Updated at: 21 Dec 2023, 09:20 )

RE:

Paul_Hayes said:

Hi Guys,

I may be missing something, but why can you not run each GetSeries asynchronous using the Task Parallel Library (TPL)? the entire operation should take no longer than the longest call to get the data series.

But I am sure it is not that simple.

Paul.

 

Thank you. But I don't think GetSeries can be called asynchronously. Also cTrader is not safe for custom threading and can end up with crash. For 200 history bars it is taking around 24 seconds for first time loading and I guess it is acceptable. But the mystery remains as why it stopped working since yesterday with 500 history bars calculations. I am using cAlgo v 1.30.58489


@bachapk

ClickAlgo
26 Aug 2015, 23:26

ok, thanks, but could Spotware confirm that custom threading is not safe with indicators or cBots, i will need to know this for future reference as well as calling GetSeries asynchronously.

Many Thanks,

Paul.


@ClickAlgo

bachapk
26 Aug 2015, 23:33

RE:

Paul_Hayes said:

ok, thanks, but could Spotware confirm that custom threading is not safe with indicators or cBots, i will need to know this for future reference as well as calling GetSeries asynchronously.

Many Thanks,

Paul.

Paul : /forum/calgo-support/2347#2


@bachapk

ClickAlgo
27 Aug 2015, 07:11

Thank you Bachapk, I hope you get your problem sorted now. :-)


@ClickAlgo

ClickAlgo
27 Aug 2015, 08:57

RE:

Paul_Hayes said:

Thank you Bachapk, I hope you get your problem sorted now. :-)

I took a look at Spotware Connect, its pretty limited on functionality, if they extend it to include live market data then I am sure you could create a thread-pool to call the RESTful API.

Bachapk, do you have much experience with Spotware Connect API? 


@ClickAlgo

Spotware
08 Sep 2015, 17:44

RE: RE:

bachapk said:

Same problem here .. I have a currency strength index indicator which was working good till 26th August 2015. But don't know what went wrong that with 500 history bars calculations the indicator do not loading. As the code is not changed therefore, I am sure something wrong have been done on the cAlgo/cTrader platform side.

Dear bachapk,

We apologize for our late response. We would like to ask you if you still have this issue.


@Spotware

bachapk
09 Sep 2015, 21:00

RE: RE: RE:

Spotware said:

bachapk said:

Same problem here .. I have a currency strength index indicator which was working good till 26th August 2015. But don't know what went wrong that with 500 history bars calculations the indicator do not loading. As the code is not changed therefore, I am sure something wrong have been done on the cAlgo/cTrader platform side.

Dear bachapk,

We apologize for our late response. We would like to ask you if you still have this issue.

Hi,

With initializing all series for currency pairs involved (around 36 pairs) on OnInit() function and reducing the first time calculations to 200 bars, the problem is solved. But The original version which was working with 500 History bars is still not loading any data. Although it was working perfectly before 25th August 2015. Before 25th Aug it was taking around 40 seconds to first load and calculate data for last 500 history bars but after it the indicator was not loading even after 5 minutes.


@bachapk

Spotware
10 Sep 2015, 17:32

Dear bachapk,

Could you please send us the following information at troubleshooting@spotware.com

  • Symbol names in which the indicator doesn’t load.
  • Name of your Broker.

  • If you are on a live or demo environment.

Thanks in advance.


@Spotware

kontodospamu5
03 Nov 2018, 14:09

Hello,

I would like to refresh the thread as I encountered the same problem with retrieving timeseries of Symbols applying MarketData.GetSeries a number of times (28 or so).

Dear Spotware tell us please if you solved issue with calling GetSeries asynchronously.

Many Thanks,

kontdospamu5


@kontodospamu5

PanagiotisCharalampous
05 Nov 2018, 10:07

Hi kontdospamu5,

Since there are more than one issues discussed in this thread could you please explicitely state which problem are you referring to? At the moment, cTrader Automate API is not thread safe.

Best Regards,

Panagiotis


@PanagiotisCharalampous

kontodospamu5
06 Nov 2018, 22:51

Hello,

 

yes, I was referring to the last issue raised by bachapk on 2015-09-09

The problem faced was how to speed up loading full history of a number of Symbols through calling GetSeries asynchronously.

Many Thanks,

kontdospamu5


@kontodospamu5

PanagiotisCharalampous
07 Nov 2018, 09:41

Hi kontodospamu5,

Thanks for the clarification. Is it possible to share some code with us (cBot/Indicator) so that we can reproduce the problem?

Best Regards,

Panagiotis


@PanagiotisCharalampous

kontodospamu5
08 Nov 2018, 02:01

Hello,

sorry, what I meant is not GetSeries asynchronously.

In my INDICATOR I have the code as follows:

// USD
MarketSeries AUDUSD_D1 = MarketData.GetSeries(MarketData.GetSymbol("AUDUSD"), TF_chart);      
MarketSeries USDCAD_D1 = MarketData.GetSeries(MarketData.GetSymbol("USDCAD"), TF_chart);      
MarketSeries USDCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("USDCHF"), TF_chart);      
MarketSeries EURUSD_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURUSD"), TF_chart);      
MarketSeries GBPUSD_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPUSD"), TF_chart);      
MarketSeries USDJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("USDJPY"), TF_chart);      
MarketSeries NZDUSD_D1 = MarketData.GetSeries(MarketData.GetSymbol("NZDUSD"), TF_chart);      

// EUR
MarketSeries EURAUD_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURAUD"), TF_chart);      
MarketSeries EURCAD_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURCAD"), TF_chart);      
MarketSeries EURCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURCHF"), TF_chart);      
MarketSeries EURGBP_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURGBP"), TF_chart);      
MarketSeries EURJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURJPY"), TF_chart);      
MarketSeries EURNZD_D1 = MarketData.GetSeries(MarketData.GetSymbol("EURNZD"), TF_chart);      


// AUD
MarketSeries AUDCAD_D1 = MarketData.GetSeries(MarketData.GetSymbol("AUDCAD"), TF_chart);      
MarketSeries AUDCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("AUDCHF"), TF_chart);      
MarketSeries AUDJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("AUDJPY"), TF_chart);      
MarketSeries GBPAUD_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPAUD"), TF_chart);      
MarketSeries AUDNZD_D1 = MarketData.GetSeries(MarketData.GetSymbol("AUDNZD"), TF_chart);      

// CAD
MarketSeries CADCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("CADCHF"), TF_chart);      
MarketSeries GBPCAD_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPCAD"), TF_chart);      
MarketSeries CADJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("CADJPY"), TF_chart);      
MarketSeries CADNZD_D1 = MarketData.GetSeries(MarketData.GetSymbol("CADNZD"), TF_chart);      

// CHF
MarketSeries GBPCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPCHF"), TF_chart);      
MarketSeries CHFJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("CHFJPY"), TF_chart);      
MarketSeries NZDCHF_D1 = MarketData.GetSeries(MarketData.GetSymbol("NZDCHF"), TF_chart);      

// GBP
MarketSeries GBPJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPJPY"), TF_chart);      
MarketSeries GBPNZD_D1 = MarketData.GetSeries(MarketData.GetSymbol("GBPNZD"), TF_chart);      

// NZD
MarketSeries NZDJPY_D1 = MarketData.GetSeries(MarketData.GetSymbol("NZDJPY"), TF_chart);  

The problem is that the calculation comsumes so much time to retrieve TimeSeries of above crosses when the every "index" is triggered to populate the INDICATOR.

Perhaps there is more sophisticated way to retrieve timeseries faster: e.g split on seperate threads or similar.

Regards,

kontodospamu5

 


@kontodospamu5

PanagiotisCharalampous
09 Nov 2018, 10:17

Hi Piotr,

Thank you. It would be better to have the complete indicator code so that we can reproduce the issue the same way as you do. If you do not want to share it publicly, please send it to me at community@spotware.com

Best Regards,

Panagiotis


@PanagiotisCharalampous

kontodospamu5
14 Nov 2018, 02:37 ( Updated at: 21 Dec 2023, 09:20 )

Hello Panagiotis,

 

Thank you for your patience.

Let me show you the code that perfectly illustrates two issues I faced.

  1. When you attach the indicator to the chart, it takes 30secs to draw the indicator, for the first time. As far as refreshing of already drawn indicator is concerned, it luckily does not last so long as the first one. But here arises the second problem…
  2. When you attach the indicator it starts to consume more and more Memory. It becomes a real problem if you try to attach the indicator to more than 3 charts. It may even come to closing up the instance of cTrader in uncontrolled way at all.

Now let me present you the body of the Indicator.

The aim of the indicator is to show a mean prices of several currencies:

 

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


namespace cAlgo
{    
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class IndicatorName : Indicator
    {
        [Output("AUD", Color = Colors.Yellow)]
        public IndicatorDataSeries AUD { get; set; }

        [Output("CAD", Color = Colors.Orange)]
        public IndicatorDataSeries CAD { get; set; }

        [Output("CHF", Color = Colors.Violet)]
        public IndicatorDataSeries CHF { get; set; }

        [Output("EUR", Color = Colors.Blue)]
        public IndicatorDataSeries EUR { get; set; }

        [Output("GBP", Color = Colors.Red)]
        public IndicatorDataSeries GBP { get; set; }

        [Output("JPY", Color = Colors.White)]
        public IndicatorDataSeries JPY { get; set; }

        [Output("NZD", Color = Colors.Pink)]
        public IndicatorDataSeries NZD { get; set; }

        [Output("USD", Color = Colors.Green)]
        public IndicatorDataSeries USD { get; set; }


        protected override void Initialize()
        {
        }

        public override void Calculate(int index)
        {
            TimeFrame TF_chart = MarketSeries.TimeFrame;                                            // bieżący wykres na jakim jest TimeFrame'ie?

            // USD
            //MarketSeries AUDUSD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDUSD"), TimeFrame.Daily);                
            MarketSeries AUDUSD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDUSD"), TF_chart);                  
            MarketSeries USDCAD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("USDCAD"), TF_chart);                  
            MarketSeries USDCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("USDCHF"), TF_chart);                  
            MarketSeries EURUSD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURUSD"), TF_chart);                  
            MarketSeries GBPUSD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPUSD"), TF_chart);                  
            MarketSeries USDJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("USDJPY"), TF_chart);                  
            MarketSeries NZDUSD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("NZDUSD"), TF_chart);                  

            // EUR            
            MarketSeries EURAUD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURAUD"), TF_chart);                  
            MarketSeries EURCAD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURCAD"), TF_chart);                  
            MarketSeries EURCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURCHF"), TF_chart);                  
            MarketSeries EURGBP_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURGBP"), TF_chart);                  
            MarketSeries EURJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURJPY"), TF_chart);                  
            MarketSeries EURNZD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("EURNZD"), TF_chart);                  


            // AUD
            MarketSeries AUDCAD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDCAD"), TF_chart);                  
            MarketSeries AUDCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDCHF"), TF_chart);                  
            MarketSeries AUDJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDJPY"), TF_chart);                  
            MarketSeries GBPAUD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPAUD"), TF_chart);                  
            MarketSeries AUDNZD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("AUDNZD"), TF_chart);                  

            // CAD
            MarketSeries CADCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("CADCHF"), TF_chart);                  
            MarketSeries GBPCAD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPCAD"), TF_chart);                  
            MarketSeries CADJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("CADJPY"), TF_chart);                       

            // CHF
            MarketSeries GBPCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPCHF"), TF_chart);                  
            MarketSeries CHFJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("CHFJPY"), TF_chart);                  
            MarketSeries NZDCHF_ohlc = MarketData.GetSeries(MarketData.GetSymbol("NZDCHF"), TF_chart);                  

            // GBP
            MarketSeries GBPJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPJPY"), TF_chart);                  
            MarketSeries GBPNZD_ohlc = MarketData.GetSeries(MarketData.GetSymbol("GBPNZD"), TF_chart);                  

            // NZD
            MarketSeries NZDJPY_ohlc = MarketData.GetSeries(MarketData.GetSymbol("NZDJPY"), TF_chart);                  
            


            // USD
            // EURUSD
            double USD_from_EURUSD = 1 / EURUSD_ohlc.Close.LastValue;
            
            // AUDUSD
            double USD_from_AUDUSD = 1 / AUDUSD_ohlc.Close.LastValue / EURAUD_ohlc.Close.LastValue;
            
            // USDCAD
            double USD_from_USDCAD = USDCAD_ohlc.Close.LastValue / EURCAD_ohlc.Close.LastValue;
            
            // USDCHF
            double USD_from_USDCHF = USDCHF_ohlc.Close.LastValue / EURCHF_ohlc.Close.LastValue;
            
            // GBPUSD
            double USD_from_GBPUSD = 1 / GBPUSD_ohlc.Close.LastValue / EURGBP_ohlc.Close.LastValue;
            
            // USDJPY
            double USD_from_USDJPY = USDJPY_ohlc.Close.LastValue / EURJPY_ohlc.Close.LastValue;
            
            // NZDUSD
            double USD_from_NZDUSD = 1 / NZDUSD_ohlc.Close.LastValue / EURNZD_ohlc.Close.LastValue;
            

            double[] USD_tdy = { USD_from_EURUSD, USD_from_AUDUSD, USD_from_USDCAD, USD_from_USDCHF, USD_from_GBPUSD, USD_from_USDJPY, USD_from_NZDUSD };
            
            USD[index] = USD_tdy.Average();


            // AUD:
            // AUDUSD                
            double AUD_from_AUDUSD = AUDUSD_ohlc.Close.LastValue;
            
            // AUDCAD
            double AUD_from_AUDCAD = AUDCAD_ohlc.Close.LastValue / USDCAD_ohlc.Close.LastValue;
            
            // AUDCHF
            double AUD_from_AUDCHF = AUDCHF_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // EURAUD
            double AUD_from_EURAUD = 1 / EURAUD_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPAUD
            double AUD_from_GBPAUD = 1 / GBPAUD_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // AUDJPY
            double AUD_from_AUDJPY = AUDJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            // AUDNZD
            double AUD_from_AUDNZD = AUDNZD_ohlc.Close.LastValue * NZDUSD_ohlc.Close.LastValue;
            
            double[] AUD_tdy = { AUD_from_AUDUSD, AUD_from_AUDCAD, AUD_from_AUDCHF, AUD_from_EURAUD, AUD_from_GBPAUD, AUD_from_AUDJPY, AUD_from_AUDNZD };
            
            AUD[index] = AUD_tdy.Average();



            // CAD:
            // USDCAD                
            double CAD_from_USDCAD = 1 / USDCAD_ohlc.Close.LastValue;
            
            // AUDCAD
            double CAD_from_AUDCAD = 1 / AUDCAD_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            // CADCHF
            double CAD_from_CADCHF = CADCHF_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // EURCAD
            double CAD_from_EURCAD = 1 / EURCAD_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPCAD
            double CAD_from_GBPCAD = 1 / GBPCAD_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // CADJPY
            double CAD_from_CADJPY = CADJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            double[] CAD_tdy = { CAD_from_USDCAD, CAD_from_AUDCAD, CAD_from_CADCHF, CAD_from_EURCAD, CAD_from_GBPCAD, CAD_from_CADJPY };
            CAD[index] = CAD_tdy.Average();



            // CHF:
            // CHFUSD                
            double CHF_from_USDCHF = 1 / USDCHF_ohlc.Close.LastValue;
            
            // AUDCHF
            double CHF_from_AUDCHF = 1 / AUDCHF_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            // CADCHF
            double CHF_from_CADCHF = 1 / CADCHF_ohlc.Close.LastValue / USDCAD_ohlc.Close.LastValue;
            
            // EURCHF
            double CHF_from_EURCHF = 1 / EURCHF_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPCHF
            double CHF_from_GBPCHF = 1 / GBPCHF_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // CHFJPY
            double CHF_from_CHFJPY = CHFJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            // NZDCHF
            double CHF_from_NZDCHF = 1 / NZDCHF_ohlc.Close.LastValue * NZDUSD_ohlc.Close.LastValue;
            
            double[] CHF_tdy = { CHF_from_USDCHF, CHF_from_AUDCHF, CHF_from_CADCHF, CHF_from_EURCHF, CHF_from_GBPCHF, CHF_from_CHFJPY, CHF_from_NZDCHF };
            CHF[index] = CHF_tdy.Average();


            // EUR:
            // EURUSD                
            double EUR_from_EURUSD = EURUSD_ohlc.Close.LastValue;
            
            // EURAUD
            double EUR_from_EURAUD = EURAUD_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            // EURCAD
            double EUR_from_EURCAD = EURCAD_ohlc.Close.LastValue / USDCAD_ohlc.Close.LastValue;
            
            // EURCHF
            double EUR_from_EURCHF = EURCHF_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // EURGBP
            double EUR_from_EURGBP = EURGBP_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // EURJPY
            double EUR_from_EURJPY = EURJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            // EURNZD
            double EUR_from_EURNZD = EURNZD_ohlc.Close.LastValue * NZDUSD_ohlc.Close.LastValue;
            


            double[] EUR_tdy = { EUR_from_EURUSD, EUR_from_EURAUD, EUR_from_EURCAD, EUR_from_EURCHF, EUR_from_EURGBP, EUR_from_EURJPY, EUR_from_EURNZD };
            EUR[index] = EUR_tdy.Average();



            // JPY:
            // USDJPY                
            double JPY_from_USDJPY = 1 / USDJPY_ohlc.Close.LastValue;
            
            // AUDJPY
            double JPY_from_AUDJPY = 1 / AUDJPY_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            // CADJPY
            double JPY_from_CADJPY = 1 / CADJPY_ohlc.Close.LastValue / USDCAD_ohlc.Close.LastValue;
            
            // EURJPY
            double JPY_from_EURJPY = 1 / EURJPY_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPJPY
            double JPY_from_GBPJPY = 1 / GBPJPY_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // CHFJPY
            double JPY_from_CHFJPY = 1 / CHFJPY_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // NZDJPY
            double JPY_from_NZDJPY = 1 / NZDJPY_ohlc.Close.LastValue * NZDUSD_ohlc.Close.LastValue;
            
            double[] JPY_tdy = { JPY_from_USDJPY, JPY_from_AUDJPY, JPY_from_CADJPY, JPY_from_CHFJPY, JPY_from_EURJPY, JPY_from_GBPJPY, JPY_from_NZDJPY };

            JPY[index] = JPY_tdy.Average();


            // NZD:
            // NZDUSD                
            double NZD_from_NZDUSD = NZDUSD_ohlc.Close.LastValue;
            
            // NZDCHF
            double NZD_from_NZDCHF = NZDCHF_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // EURNZD
            double NZD_from_EURNZD = 1 / EURNZD_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPNZD
            double NZD_from_GBPNZD = 1 / GBPNZD_ohlc.Close.LastValue * GBPUSD_ohlc.Close.LastValue;
            
            // NZDJPY
            double NZD_from_NZDJPY = NZDJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            // AUDNZD
            double NZD_from_AUDNZD = 1 / AUDNZD_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            double[] NZD_tdy = { NZD_from_NZDUSD, NZD_from_NZDJPY, NZD_from_GBPNZD, NZD_from_AUDNZD, NZD_from_NZDCHF, NZD_from_EURNZD };
            NZD[index] = NZD_tdy.Average();


            // GBP:
            // GBPUSD                
            double GBP_from_GBPUSD = GBPUSD_ohlc.Close.LastValue;
            
            // GBPAUD
            double GBP_from_GBPAUD = GBPAUD_ohlc.Close.LastValue * AUDUSD_ohlc.Close.LastValue;
            
            // GBPCAD
            double GBP_from_GBPCAD = GBPCAD_ohlc.Close.LastValue / USDCAD_ohlc.Close.LastValue;
            
            // GBPCHF
            double GBP_from_GBPCHF = GBPCHF_ohlc.Close.LastValue / USDCHF_ohlc.Close.LastValue;
            
            // EURGBP
            double GBP_from_EURGBP = 1 / EURGBP_ohlc.Close.LastValue * EURUSD_ohlc.Close.LastValue;
            
            // GBPJPY
            double GBP_from_GBPJPY = GBPJPY_ohlc.Close.LastValue / USDJPY_ohlc.Close.LastValue;
            
            // GBPNZD
            double GBP_from_GBPNZD = GBPNZD_ohlc.Close.LastValue * NZDUSD_ohlc.Close.LastValue;
            
            double[] GBP_tdy = { GBP_from_GBPUSD, GBP_from_GBPJPY, GBP_from_GBPAUD, GBP_from_GBPNZD, GBP_from_GBPCAD, GBP_from_GBPCHF, GBP_from_EURGBP };
            GBP[index] = GBP_tdy.Average();


        }




    }
}

 

I wonder if there is a more “subtle” ie cleverer way to retrieve time-series as opposed to the brutal series of rows of:

MarketData.GetSeries(MarketData.GetSymbol("cur1cur2"), TimeSeries.Daily);  

 

Perhaps multi threading approach would be more efficient or something else.

Please share your view on the matter.

Regards,

PiotrW

PS. Please do not assess the motivation/reasoning behind the Indicator;)


@kontodospamu5

PanagiotisCharalampous
14 Nov 2018, 10:44

Hi Piotr,

Time to load the data and high memory consuption is somehow expected with such a high amount of requested data. However we have plans to work on Asynchronous methods and further improvements on retrieving market data in the near future. 

Best Regards,

Panagiotis


@PanagiotisCharalampous