Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using indicator values in Multiple Timeseries (same instrument) as input for Strategy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using indicator values in Multiple Timeseries (same instrument) as input for Strategy

    Hello,

    I want to build a strategy based on indicator values of a multiple time series.

    1.) I added 3 different time series of the same instrument on a chart and added for each of them the same indicator, but each with different periods to consider.
    This seems to work fine, but trying to reflect this in a strategy, I am somehow stuck, as I cannot make the plot to work correctly (the indicators are shown, but with different, unexpected values).

    2.) For the Strategy, I added 3 Data series for the same instrument (Tick) in the Configure state.
    In the Data Loaded state, I assigned the indicator variables to the corresponding (different) Bar Series. When trying to plot the indicator (different periods) for each of the different Bar series, only one is plotted correctly (Bar series 0). The other Indicators based on the other Bar Series differ from the values shown from the chart + added indicators above, as per 1.). - > compare attached image.

    Is this an expected behavior or am I missing something?​

    Below the relevant code I used:


    else if (State == State.Configure)
    {
    AddDataSeries("FDAX 03-24", Data.BarsPeriodType.Tick, 100, Data.MarketDataType.Last);
    AddDataSeries("FDAX 03-24", Data.BarsPeriodType.Tick, 200, Data.MarketDataType.Last);
    AddDataSeries("FDAX 03-24", Data.BarsPeriodType.Tick, 400, Data.MarketDataType.Last);
    }
    else if (State == State.DataLoaded)
    {
    CCI1 = CCI(Closes[1], 44);
    CCI2 = CCI(Closes[2], 22);
    CCI3 = CCI(Closes[3], 11);​

    CCI1.Plots[0].Brush = Brushes.Lime;
    AddChartIndicator(CCI1);

    CCI2.Plots[0].Brush = Brushes.Blue;
    AddChartIndicator(CCI2);

    CCI3.Plots[0].Brush = Brushes.Red;
    AddChartIndicator(CCI3);


    //Panel
    CCI1.Panel = 3;
    CCI2.Panel = 3;
    CCI3.Panel = 3;​

    #2
    Hello Holzratte23,

    Thank you for your post.

    What you have described is expected behavior. There is a note on the help guide page for AddChartIndicator() that states the following:
    • "An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)​"
    Since you are using the CCI indicator, you could consider creating a copy of the CCI indicator that adds the additional series or you could create a separate custom indicator that adds the desired series and plots based on each series, then call AddChartIndicator() for that custom indicator with the 3 plots to your strategy:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Dear Emily,

      thank you for your answer. This explains the deviating indicator values in the plot. Above it is mentioned explicitly "when added via AddChartIndicator()". Does this mean that the indicator values for the different Bar Series would still be "correct" for calculation in the strategy if not added to the Chart? (Despite being wrongly displayed in the Chart if they are added?). Or is the only reliable method to reference those indicator values in a strategy by creating indicators containing the data series as you described above?

      Comment


        #4
        Originally posted by Holzratte23 View Post
        Dear Emily,

        thank you for your answer. This explains the deviating indicator values in the plot. Above it is mentioned explicitly "when added via AddChartIndicator()". Does this mean that the indicator values for the different Bar Series would still be "correct" for calculation in the strategy if not added to the Chart? (Despite being wrongly displayed in the Chart if they are added?). Or is the only reliable method to reference those indicator values in a strategy by creating indicators containing the data series as you described above?
        Yes, the indicator values will still be correct and be calculated based on the designated Closes series. This may be confirmed by adding Print() statements in your strategy and reviewing the printed values to determine that it is calculating as expected. For more information about using prints:


        We have a page about multi-series scripts in the help guide here:


        Please let us know if we may be of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X