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

How to get 2 indicators plotted in sync in price and indicator panel (share data betw

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

    How to get 2 indicators plotted in sync in price and indicator panel (share data betw

    In need to program an indicator that plot a line in the price panel and other lines in an added indicator panel. It seems this is still impossible in NT8. If I need to split this in 2 indicators indic1 for the plot in price panel and indic2 for the plot in added indicator panel can you tell me:
    how can indic2 know indic1 is loaded, where to do the check(s),
    how to access to the actual value of indic1 parameters
    How to get DataSeries computed in indic1 accessible to Indic2?

    To fix the idea let’s suppose indic1 has SMA(High, Indic1Prd)
    IsOverlay = true; //Plot in price panel
    Indic1DataS1 = SMA(High, Indic1Prd); //Indic1 dataSerie to share
    Plot SMA in price panel

    Indic2: must have access to Indic1Prd & Indic1DataS1
    IsOverlay = false; //Plot in separate panel
    EMA(Low, Indic1Prd); //Uses the same Indic1Prd
    Print(“Indic1DataS1”+ Indic1DataS1[10]); //Access Indic1 DataSerie
    Plot EMA in an indicator panel

    Could you give a sample of code that solves this problem?
    This seems incredibly complicated to only add another curve placed in an indicator panel.

    Best regards.



    #2
    Hello jpraema,

    Thanks for opening the thread.

    It is currently not possible to have an indicator plot to separate panels, but it is possible to have a strategy plot to separate panels and use plot values from other indicators. The attached sample demonstrates how you can use indicators as a place holder where you can modify their plot and have one plot to a new indicator panel and one to the price panel.

    This approach essentially treats the strategy as the indicator and uses indicators simply to make a plot.

    Another approach may be to split the indicator and then to add an instance for displaying the indicator in one panel and another instance then for calculating within the indicator the requires that data and plots to another panel.

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

    Comment


      #3
      Jim
      I have a question on this technique. If I create two subpanels with place holder indicators like you have shown. Can I add two other instances of each sub panel indicator in my Main indicator on the price panel and have access to the Plot which is calculated in the strategy such that I am not recalculating this indicator in more than one place as it is a heavy load.
      Essentially creating two instances of what is just a place holder indicator to read the plot value. Is an indicator.Update() required in my main indicator to update the plot value to the latest value?

      Comment


        #4
        Hello JerryWar,

        Thanks for the additional question.

        Referencing a plot made by a strategy in an indicator would not be possible as you would need to add an object reference of that NinjaScript in order to access an exposed variable or plot. You can't add a strategy to an indicator so this object reference cannot exist.

        Additionally, I would not recommend working around this using an AddOn to store the values of the plots to static variables. You would not be able to create a Series<T> that would be properly in sync, and I cannot think of a way where you could use static variables to satisfy all of the plot values.

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

        Comment


          #5
          So If I understand your response , if I wanted to add arrows in the placeholder indicator based on the value of the SPlot public series I could not do that ? AM I overlooking something here. From a Strategy as I understand it you cannot draw text or lines etc. Is that also true from an AddChartIndicator inserted in a strategy. in other words, any arrows, drawtext , or lines would also be suppressed from the addChartIndicator. The question really is, is there a way to replicate the attached by plotting from within an Strategy. Note diamonds and triangles.
          Attached Files
          Last edited by JerryWar; 08-10-2017, 10:07 AM.

          Comment


            #6
            Hello JerryWar,

            An indicator cannot read plots from a strategy. You can't add a strategy to an indicator, so you can't reference the plots of a strategy in an indicator.

            A strategy can use drawing tools. You should also be able to see drawing objects from within AddChartIndicator(). However, I am seeing some issues with AddChartIndicator() right now and I am checking with some other colleagues on the matter.

            Were you having any difficulties drawing from a strategy?

            I'll update this post when I learn more from the AddChartIndicator() behavior.
            JimNinjaTrader Customer Service

            Comment


              #7
              Yes, I tried using drawing tools directly ( not from Addchartindicator )
              and they did not work. I will give it another go. That would solve my issues and I could
              probably stop bugging you guys with all my out of the box kind of Questions.

              Thanks

              Comment


                #8
                Jim
                I got this work but it acted a little flakey. I did not use the placholder technique because I could not figure out how to get the arrows in the subpanels.
                I added one copy(AddChartIndicator) of my sub-panel indicator to a blank strategy. It plotted and drew the arrows. I added a second copy and it did not plot. I reversed the order in the code and found it always plotted the first occurrence but not the second. I then added a Price Panel Indicator. If it was the first indicator in the code it inhibited either of the plots to the sub-panel. Then as a Last shot I moved the Price-panel indicator to last in the code and to my surprise I had all three on the chart.
                Price panel, Sub-panel 2 and Sub-panel 3.
                See attached.
                Attached Files

                Comment


                  #9
                  Thanks JerryWar,

                  I'm glad you have gotten something working.

                  Could you share with me a few versions of this script that can demonstrate how the order effects the results displayed? I would greatly appreciate being able to reproduce and look into this on my end.

                  EDIT: The AddChartIndicator() drawing issue reported has been accepted as a bug and is being tracked with ticket ID NTEIGHT-12031. This ID can be found in the Release Notes section of the help guide for the release of NinjaTrader 8 that includes the fix.

                  I look forward to being of further help.
                  Last edited by NinjaTrader_Jim; 08-14-2017, 02:37 PM.
                  JimNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Sparkyboy, Today, 10:57 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post Sparkyboy  
                  Started by TheMarlin801, 10-13-2020, 01:40 AM
                  21 responses
                  3,916 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
                  809 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