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

Indicator in two panels

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

    Indicator in two panels

    Is it possible to create an indicator that uses two panels, one of them being the price panel? How do I specify the target panel for each plot and drawing object (like arrows and triangles)?
    What I am trying to do is have the indicator draw on the price panel (like a MA), and have a STO like other panel. I could split it into two indicators, but they share a lot of calculation that I do not want to duplicate (for the sake of efficiency and speed).
    So, is it doable in NT7? What about NT8?

    #2
    Hello Titus,

    Thanks for writing in.

    Some users have reported that using the DrawOnPricePanel within OnBarUpdate() has allowed them to do this, but it is not the recommended solution.

    It is instead advised to create 2 separate indicators. One that plots to the Price Panel and one that draws to the indicator panel.

    It is possible to have a strategy place the indicators in a specified panel, but this is possible because the added indicators are managed by the strategy. Adding indicators to a chart would not have any reference of what other indicators exist on the chart and what panels exist.

    You may wish to reference the documentation and reference sample below:

    DrawOnPricePanel NinjaTrader 7: https://ninjatrader.com/support/help...pricepanel.htm

    DrawOnPricePanel NinjaTrader 8: https://ninjatrader.com/support/help...pricepanel.htm

    Plotting within a NinjaScript Strategy: http://ninjatrader.com/support/forum...ead.php?t=6651

    Additionally, there is a Plot() override that you may wish to use to place drawing objects where ever you may like them. This method falls outside of our documentation. As such, there is only a certain amount of support we may provide in this direction. There is a sample that outlines this provided with NinjaTrader 7 in the folder \Documents\NinjaTrader 7\bin\Custom\Indicator\CustomPlotSample.cs

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you Jim for your response.

      I think splitting the indicator is the way to go then. But that raises another question.
      Let's say I split the indicator into indicators IndA and IndB. Is there a way to guarantee that IndA is calculated first and then somehow IndB can access some of the results that IndA has already calculated (so it does not have to be done again), and use it for further calculations?

      Comment


        #4
        Hello Titus,

        Thanks for getting back to me.

        There is a reference sample that may be of use to you for creating indicators that can reference data from one another. You may try a similar approach to see how much of your code you can re-use.

        Exposing indicator values that are not plots: http://ninjatrader.com/support/forum...ead.php?t=4991

        Alternately, but not necessarily recommended, you may try to write to a global space. This falls outside the scope for NinjaScript support, but you are welcome to apply any C# techniques you have at your disposal to your indicators and strategies.

        For NinjaTrader 7, this is very easy. We provide the files (My) Documents\NinjaTrader 7\bin\Custom\Indicator\UserDefinedMethods.cs and (My) Documents\NinjaTrader 7\bin\Custom\Strategy\UserDefinedMethods.cs . You can store global variables that will be included for all Indicators in this file. Make sure they are part of the Indicator class. For example,
        Code:
            partial class Indicator
            {
                /// <summary>all the plots from all the indicators</summary>
                public static Plot[][] allThePlots;
            }
        NinjaTrader 8 will not have a similar file. 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


        Whichever way you choose, you will want to add some logic surrounding your global objects.

        Please let us know if we may be of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #5
          Thank you again, I'll dig into it and see what I can do.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Sparkyboy, Today, 10:57 AM
          0 responses
          3 views
          0 likes
          Last Post Sparkyboy  
          Started by TheMarlin801, 10-13-2020, 01:40 AM
          21 responses
          3,917 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by timmbbo, 07-05-2023, 10:21 PM
          3 responses
          152 views
          0 likes
          Last Post grayfrog  
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          30 responses
          811 views
          1 like
          Last Post grayfrog  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Erick  
          Working...
          X