Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Multiple Data Series with different Indicator Input series

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

    Multiple Data Series with different Indicator Input series

    Hello advance programer, Josh!

    I’d like to ask a little help from you. I’d like create a multiple data series within a single chart window in NinjaSript, as I can make it manually. (it can probably make using NinjaScript). In help I can’t find the convenient method and properties to create a new chart with different Data Series object, and to place indicators, which Input series are belong to the secondary instrument data series but they are shown on different, on the main Data Series. I can create in script a new DataSeries, and I can reach the value, but I can’t able to made it on the chart represent. What I think about:
    I want to reach this state:



    I’ve tried this way, but doesen’t want to work for nuts:
    Code:
      
    [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot]override[/FONT][/COLOR][COLOR=blue][FONT=&quot]void[/FONT][/COLOR][COLOR=black][FONT=&quot] Initialize()[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(PeriodType.Minute, [/FONT][/COLOR][COLOR=purple][FONT=&quot]30[/FONT][/COLOR][COLOR=black][FONT=&quot]); [/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(Bollinger([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]));          [/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]));[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]).PanelUI = [/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];  [/FONT][/COLOR]
      [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
    Second way, it shows something, but not correct. I've tried using insteed of Bollinger Band the _ADXVMA_Alerts_v01_5 indicator, but it is confused for me. it can be seen in attached picture.

    Code:
     [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot]override[/FONT][/COLOR][COLOR=blue][FONT=&quot]void[/FONT][/COLOR][COLOR=black][FONT=&quot] Initialize()[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]{[/FONT][/COLOR]
                                [COLOR=black][FONT=&quot]Add(PeriodType.Minute, [/FONT][/COLOR][COLOR=purple][FONT=&quot]30[/FONT][/COLOR][COLOR=black][FONT=&quot]); [/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]));[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]));[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   Add(StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot]));[/FONT][/COLOR]
      
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]).Plots[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]].Pen.Color = Color.Blue;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]).Plots[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]].Pen.Color = Color.Green;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot]).Plots[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]].Pen.Color = Color.Red;[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]).PanelUI = [/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]).PanelUI = [/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot]).PanelUI = [/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]CalculateOnBarClose = [/FONT][/COLOR][COLOR=blue][FONT=&quot]true[/FONT][/COLOR][COLOR=black][FONT=&quot];[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
      [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot]override[/FONT][/COLOR][COLOR=blue][FONT=&quot]void[/FONT][/COLOR][COLOR=black][FONT=&quot] OnBarUpdate()[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]        {[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]).Value.Set( Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot],[/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]).Upper[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]]);[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]).Value.Set( Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot],[/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]).Middle[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]]);[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]                                   StrategyPlot([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot]).Value.Set(Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot],[/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]).Lower[[/FONT][/COLOR][COLOR=purple][FONT=&quot]0[/FONT][/COLOR][COLOR=black][FONT=&quot]]);[/FONT][/COLOR]
      [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
    It can be seen:


    The question would be in NinjaScript.
    -How can make visible the additional data series in Multiple Data Series chart window?
    - how can I correctly place an 30 min Input series Indicator on other, e.g. 10 min chart?
    I'd appreciate it.

    Many Thanks for help!
    Tom
    Attached Files

    #2
    Hello,

    This is Brett Assisting here for Josh.

    Unfortunately it is unsupported to make price data from a secondary series visible on the chart. It must be added manually via the user.

    Secondly, on your other question is is possible with your current method. However you would need to add some BarsInProgress checks. So that you only set values that matter to the current series.

    For example only set the 30 minute indicator value when it is running the 30 minute bars, or only set the 10 minute indicator value when it is running the 10 minute bars.
    I.E. For every 30 minute bar you will get 3 calls to the OnBarUpdate to the 10 minute bars.

    You can check this with BarsInProgress which is detailed here:



    Let me know if I can be of further assistance.

    Comment


      #3
      Hello Brett,

      thanks for help. I've made it followed your suggestion. I used BarsInProgress == 1 to set the 30 min DataSeries. but I don't have an idea where is the mistake since it doesen't want to work. when I change the progress 0, it give me the right indicator on 10 min chart.

      could you correct, how will work correctly, please? it would be important to solve it.

      Code:
      #region Using declarations
      using System;
      using System.ComponentModel;
      using System.Diagnostics;
      using System.Drawing;
      using System.Drawing.Drawing2D;
      using System.Xml.Serialization;
      using NinjaTrader.Cbi;
      using NinjaTrader.Data;
      using NinjaTrader.Indicator;
      using NinjaTrader.Gui.Chart;
      using NinjaTrader.Strategy;
      #endregion
      
      // This namespace holds all strategies and is required. Do not change it.
      namespace NinjaTrader.Strategy
      {
          /// <summary>
          /// Enter the description of your strategy here
          /// </summary>
          [Description("Enter the description of your strategy here")]
          public class ProbMulti : Strategy
          {
              #region Variables
              // Wizard generated variables
              private int myInput0 = 1; // Default setting for MyInput0
              // User defined variables (add any user defined variables below)
              #endregion
      
              /// <summary>
              /// This method is used to configure the strategy and is called once before any strategy method is called.
              /// </summary>
              protected override void Initialize()
              {
                  CalculateOnBarClose = true;
                  ClearOutputWindow();
                  Add(PeriodType.Minute, 30);  //BarsArray[1]
                  
                  Add(StrategyPlot(0));
                  Add(StrategyPlot(1));
                  Add(StrategyPlot(2));
                  
                  StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
                  StrategyPlot(1).Plots[0].Pen.Color = Color.Green;
                  StrategyPlot(2).Plots[0].Pen.Color = Color.Red;
                  
                  StrategyPlot(0).PanelUI = 1;
                  StrategyPlot(1).PanelUI = 1;
                  StrategyPlot(2).PanelUI = 1;
              }
      
              /// <summary>
              /// Called on each bar update event (incoming tick)
              /// </summary>
              protected override void OnBarUpdate()
              {
                  if (CurrentBar < 20) return;
                      
                  if (BarsInProgress == 1) 
                 { 
                  StrategyPlot(0).Value.Set( Bollinger(BarsArray[1], 2,14).Upper[0]);
                  StrategyPlot(1).Value.Set( Bollinger(BarsArray[1], 2,14).Middle[0]);
                  StrategyPlot(2).Value.Set(Bollinger(BarsArray[1], 2,14).Lower[0]);        
                  
                  }
                  
              }
      
              #region Properties
              [Description("")]
              [GridCategory("Parameters")]
              public int MyInput0
              {
                  get { return myInput0; }
                  set { myInput0 = Math.Max(1, value); }
              }
              #endregion
          }
      }
      is it impossible to call the indicator similar this way?

      Code:
        
      [COLOR=blue][FONT=&quot]protected[/FONT][/COLOR][COLOR=blue][FONT=&quot]override[/FONT][/COLOR][COLOR=blue][FONT=&quot]void[/FONT][/COLOR][COLOR=black][FONT=&quot] Initialize()[/FONT][/COLOR]
        [COLOR=black][FONT=&quot]        {[/FONT][/COLOR]
        [COLOR=black][FONT=&quot]                                   Add(PeriodType.Minute, [/FONT][/COLOR][COLOR=purple][FONT=&quot]30[/FONT][/COLOR][COLOR=black][FONT=&quot]); [/FONT][/COLOR]
        [COLOR=black][FONT=&quot]                                   Add(Bollinger([/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]));          [/FONT][/COLOR]
        [COLOR=black][FONT=&quot]                                   Add(Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]));[/FONT][/COLOR]
        [COLOR=black][FONT=&quot]                                   Bollinger(BarsArray[[/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot]], [/FONT][/COLOR][COLOR=purple][FONT=&quot]2[/FONT][/COLOR][COLOR=black][FONT=&quot], [/FONT][/COLOR][COLOR=purple][FONT=&quot]14[/FONT][/COLOR][COLOR=black][FONT=&quot]).PanelUI = [/FONT][/COLOR][COLOR=purple][FONT=&quot]1[/FONT][/COLOR][COLOR=black][FONT=&quot];  [/FONT][/COLOR]
        [COLOR=black][FONT=&quot]}[/FONT][/COLOR]
      Thanks for help!
      Tom
      Last edited by marotom; 01-06-2011, 11:28 AM.

      Comment


        #4
        Hello,

        I misread your question. Thought you were asking about the original chart plotting a secondary period.

        Make the following change to do what your looking for.

        StrategyPlot(0).Panel = 1;
        StrategyPlot(
        1).Panel = 1;
        StrategyPlot(
        2).Panel = 1;

        Take UI in the above calls out in your Init() then your g2g.

        Let me know if I can be of further assistance.

        Comment


          #5
          Hello,
          yes, I'm going to plot the secondary chart(30 min) indicator on the primary chart (10 min).
          I've rewrote this, but there isn't effect on the script. the indicator still can be seen on the secondary chart, if I use the primary BarsInProgress with value 0. but I want to see on the primary chart the secondary period's indicator. As we better keep this short, do you have/write a working sript in brief, how works it, please?

          thanks

          Originally posted by NinjaTrader_Brett View Post
          Hello,

          I misread your question. Thought you were asking about the original chart plotting a secondary period.

          Make the following change to do what your looking for.

          StrategyPlot(0).Panel = 1;
          StrategyPlot(
          1).Panel = 1;
          StrategyPlot(
          2).Panel = 1;

          Take UI in the above calls out in your Init() then your g2g.

          Let me know if I can be of further assistance.

          Comment


            #6
            Hello,

            I guess I'm still not sure what your looking for here then.

            Take out the

            StrategyPlot(0).Panel = 1;
            StrategyPlot(
            1).Panel = 1;
            StrategyPlot(
            2).Panel = 1;


            and delete them and then the StrategyPlot's will plot on your same chart that you started the strategy on.

            Use the above if you want it added to panel 1 which is below panel 0.

            I will need further explination of what your trying to do if the above is not what you need.

            Let me know if I can be of further assistance.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            43 views
            0 likes
            Last Post jeronymite  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            10 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by yertle, Today, 08:38 AM
            5 responses
            15 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by adeelshahzad, Today, 03:54 AM
            3 responses
            18 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by bill2023, Yesterday, 08:51 AM
            6 responses
            27 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X