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

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.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

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

    The C# namespace alias qualifier `::` is used to access a member of an aliased namespace. The `::` operator is often used with the `global` alias, an alias for the global namespace


    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?
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      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.
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          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,

            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Thank You, Jessica.
              fx.practic
              NinjaTrader Ecosystem Vendor - fx.practic

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by algospoke, Yesterday, 06:40 PM
              2 responses
              19 views
              0 likes
              Last Post algospoke  
              Started by ghoul, Today, 06:02 PM
              3 responses
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              44 views
              0 likes
              Last Post jeronymite  
              Started by Barry Milan, Yesterday, 10:35 PM
              7 responses
              20 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by AttiM, 02-14-2024, 05:20 PM
              10 responses
              180 views
              0 likes
              Last Post jeronymite  
              Working...
              X