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 can I get access from strategy to plot data in my indicator?

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

    How can I get access from strategy to plot data in my indicator?

    There is a simple Indicator, It simple connect highs and lows of bars. http://prntscr.com/f99j3h

    There are two plots in Indicator, which added using AddPlot() http://prntscr.com/f99kgj

    DataBox show correctly both plots http://prntscr.com/f99kpb BUT when I try to get the value of second Plot, I can not do this.

    When I call Indicator from Strategy like this: http://prntscr.com/f99of8 everything works fine, but I get only the first Plot ("testH"). Look at this http://prntscr.com/f99oq1 each plot is equals to Hight.

    The question: how can I get an access to second Indicator's plot (I mean "testL")?

    Indicator: testLowsAndHighs.cs
    Strategy: simpleHL.cs
    Attached Files
    Last edited by handlar; 05-18-2017, 07:06 AM. Reason: wrong english
    Handlar
    NinjaTrader Ecosystem Vendor - Handlar

    #2
    Hello,

    Thank you for posting.

    In this case, you just need to add some public Properties so you can differentiate the plots when calling the indicator from other scripts. The Indicators [0] value would relate to the first added plot only:

    Code:
    myIndicator[B][0][/B]
    I usually recommend reviewing the Bollinger indicator as it shows the syntax to create 3 plots and also be able to call them from another script.

    The specific syntax you would need is the following:

    Code:
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> TestH
    {
    	get { return Values[0]; }
    }
    
    [Browsable(false)]
    [XmlIgnore()]
    public Series<double> TestL
    {
    	get { return Values[1]; }
    }

    The property returns the Values[PlotIndex] for the plot it should be associated with, then from another script you can access the values like the following:

    Code:
    double h = myIndicator().TestH[0];
    double h = myIndicator().TestL[0];

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for quickly answer!

      Everhything works fine now!

      In attach everyone can see fixed exemple.
      Attached Files
      Last edited by handlar; 05-18-2017, 07:28 AM.
      Handlar
      NinjaTrader Ecosystem Vendor - Handlar

      Comment


        #4
        One more question. Can I get a color of the Plot in any way? For example: I have one plot and I change the color depends of price (from green to red and again). How can I check is the color red or green on current bar?
        Handlar
        NinjaTrader Ecosystem Vendor - Handlar

        Comment


          #5
          Hello,

          Thank you for the reply.

          Checking the Color of a plot specifically would not be a good way to try and get signals, instead, I would suggest either to use the same logic that colors the plot to start with for the other action. Alternatively, you could make a plot and set specific values as signals.

          One example would be if the indicator would be called on by another script, in that case, you would need to make a plot and then make signal values based on when the color changes in the logic.

          You could use specific values like 1,0,-1 for triggers, for example, 1 could mean green, 0 no signal and -1 red.

          The indicator in which colors the plot would add the extra plot used for signals and also would set the values, then in any other indicator you could call on it like shown in the previous post.

          Code:
          [Browsable(false)]
          [XmlIgnore()]
          public Series<double> SignalPlot
          {
          	get { return Values[2]; }
          }
          From another indicator:

          Code:
          if(myIndicator().SignalPlot[0] > 0)
          {
          }
          I look forward to being of further assistance.
          JesseNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post inanazsocial  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          22 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Started by guillembm, Yesterday, 11:25 AM
          2 responses
          9 views
          0 likes
          Last Post guillembm  
          Started by junkone, 04-21-2024, 07:17 AM
          9 responses
          70 views
          0 likes
          Last Post jeronymite  
          Working...
          X