• 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.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Vertical pixel offset for indicator?

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

    Vertical pixel offset for indicator?

    Hello.

    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.)

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

    #2
    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.

    https://msdn.microsoft.com/en-us/library/c3ay4x3d.aspx

    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

    Comment


      #3
      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?

      Comment


        #4
        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

        Comment


          #5
          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:

          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.

          Comment


            #6
            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,

            http://ninjatrader.com/support/forum...d.php?p=274814
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Thank You, Jessica.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by mohdhm, Today, 04:09 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ShawnB  
              Started by BGWTEX, Today, 03:30 PM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by marekflys, Today, 03:07 PM
              0 responses
              5 views
              0 likes
              Last Post marekflys  
              Started by GregoryBaskin, Today, 02:51 PM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_Tyler  
              Started by swcooke, Today, 12:33 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Working...
              X