Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Load individual additional Dataseries in merged back adjusted Futures

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

    Load individual additional Dataseries in merged back adjusted Futures

    Hi guys,

    im trying to make an indicator that showes me other Future Contracts on the chart.
    For example in this case i want to show the two other Gold Futures.

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.Indicators;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Strategies in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Strategies
    {
    public class AnotherIndicator: Indicator
    {
    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"Enter the description for your new custom Strategy here.";
    Name = "AnotherIndicator";
    Calculate = Calculate.OnEachTick;
    
    IsOverlay = false;
    DisplayInDataBox = true;
    Calculate = Calculate.OnEachTick;
    MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    DrawOnPricePanel = true;
    DrawHorizontalGridLines = true;
    DrawVerticalGridLines = true;
    PaintPriceMarkers = true;
    ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
    IsSuspendedWhileInactive = true;
    
    
    AddPlot(Brushes.White, "Curve1");
    AddPlot(Brushes.DodgerBlue, "Curve2");
    }
    else if (State == State.Configure)
    {
    AddDataSeries("GC 12-21", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    AddDataSeries("GC 04-22", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);
    }
    }
    
    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0 )
    return;
    
    
    Curve1[0] = Closes[1][0];
    Curve2[0] = Closes[2][0];
    }
    
    [Browsable(false)]
    public Series<double> Curve1
    {
    get { return Values[0]; }
    }
    public Series<double> Curve2
    {
    get { return Values[1]; }
    }
    }
    }
    Sadly it doesnt show me the correct Values of the specific Contracts of the Day it only Plots me the value of Close[0] from my originally loaded contract.

    See here in my Screenshots:

    Click image for larger version

Name:	gc1.JPG
Views:	283
Size:	91.4 KB
ID:	1158880
    Here are the actual Values which should be shown:

    Click image for larger version

Name:	gc3.JPG
Views:	277
Size:	180.8 KB
ID:	1158882Click image for larger version

Name:	gc2.JPG
Views:	280
Size:	126.2 KB
ID:	1158884

    Can you help me with that problem?
    Thanks in advance
    Attached Files

    #2
    Hello Branpo,

    Thank you for the post.

    What is the primary series that you are using?

    I tried this on an ES daily primary and see the plot represents the secondary values. The two contract values are very close so it looks like a single plot but they are both being plotted.

    I look forward to being of further assistance.

    Comment


      #3
      Hi Jesse,
      thanks for your quick reply.
      i used it on GC 08-21.
      yes thats correct they are both being plotted with the same value but the values aren’t correct.
      todays Values should be the both yellow marked values ok the screenshots but it plots me the the Value of the current active contract from the merge back adjusted rule which is gc 08-21.

      Comment


        #4
        Hello Branpo,

        I see the plot matching the secondary contract on my end, I did have to use the data box due to the other secondary plot being a different value it made it difficult to make the comparison of GC

        Have you tried to reload all the historical data and restart the platform/reconnect?

        If you are finding the merge policy is affecting the script you can also set the platform to do not merge in the tools -> options -> market data menu.


        I look forward to being of further assistance.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        63 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        90 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        48 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        105 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X