• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.


No announcement yet.

Partner 728x90


Vertical pixel offset for indicator?

  • Filter
  • Time
  • Show
Clear All
new posts

    Vertical pixel offset for indicator?


    Can we set vertical pixel offset for separate indicator plot, of for whole indicator - like pixel offset for draw objects?

    (I need to draw 2 plots on different charts with same distance between them.)

    Last edited by fx.practic; 03-15-2017, 06:51 AM.

    Hello fx.practic, and thank you for your question. This will be possible with global scope variables. I am including a publicly available link from the MSDN C# documentation which will guide you toward putting together a global scope file in NT8.


    Once you have the ability to globally access indicator pixel data, you can then export ChartPanel.X and ChartPanel.Y to your second indicator (or any other values you choose). Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service


      Sorry, I don't understand.

      Let me ask in another way.

      Say, I want see on chart 2 plots: SMA(20) and SMA(20) 2 pixels below.

      In this purpose I going to make 2 indicators and put them on chart.
      Both calculate SMA(20) internally.
      First indicator just assign SMA values to it's plot on each bar.

      And I asking about second indicator. I can, obviously calculate SMA(20) values in it, and I can do without global variables. But how to plot these values on chart 2 pixels below?


        Let's work through this a step at a time. We have two goals we need to accomplish :

        • Two indicators on completely different charts need to talk to each other
        • You need to plot at a desired pixel value

        Let's attack that first bullet first. Once we have done this we can move on to the second one. Attached is a code sample that accomplishes this goal. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.

        Once you have incorporated code from IndicatorA and IndicatorB into your own code, we can move on.

        IndicatorC is an indicator designed to plot at IndicatorA's price plus 20 pixels in the Y direction.
        Attached Files
        Jessica P.NinjaTrader Customer Service


          Thanks a lot, Jessica!

          About bullet 1:
          Very interesting way to communicate.

          About bullet 2:
          Compiling IndicatorC produce this error:
          'NinjaTrader.NinjaScript.Indicators.PixelOffset.In dicatorA' does not contain a definition for 'MostRecentIndicatorA' (screenshot)

          But, Your examples inspired me, and I found this thread and get this working (screenshot) code:

          		protected override void OnBarUpdate()
          			Values[0][0] = Low[0];
          			ChartScale cs = ChartPanel.Scales[ChartPanel.PanelIndex];
          			Values[1][0] = cs.GetValueByY( (float)(cs.GetYByValueWpf(Values[0][0]) + 20) );
          Is the way to do same to bullet 2 in NT7?
          I tried compile this code in NT7, but, of course, "ChartPanel inaccessible..", "ChartScale not found..."
          Attached Files
          Last edited by fx.practic; 03-16-2017, 02:21 AM.


            I accidentally uploaded a version of IndicatorA that was not exporting this member, but I am glad you were able to figure out what was intended from context.

            NinjaTrader 7 does not have NinjaTrader 8's built-in support through documentation for direct rendering. ChartControl in NinjaTrader 7 will take some trial-and-error work and some research through the forums.

            One of our forums users kogonam has provided an excellent starting point for that research here,

            Jessica P.NinjaTrader Customer Service


              Thank You, Jessica.


              Latest Posts


              Topics Statistics Last Post
              Started by Steve L, Today, 10:04 PM
              0 responses
              1 view
              Last Post Steve L
              by Steve L
              Started by marianfed, Today, 09:47 PM
              0 responses
              1 view
              Last Post marianfed  
              Started by hir04068, Today, 09:29 PM
              0 responses
              1 view
              Last Post hir04068  
              Started by iq200, 03-11-2018, 07:49 PM
              24 responses
              Last Post mrlucky1x  
              Started by DavidHP, Today, 08:18 PM
              0 responses
              1 view
              Last Post DavidHP
              by DavidHP