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

Passing IntDataSeries to Indicator

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

    Passing IntDataSeries to Indicator

    I can't seem to pass a IntSeries Class from a Strategy to a Custom Indicator. Why is this. Is this a undocumented limitation?

    Code:
    myIntSeries = new IntSeries(this);
    Even better would be to pass a BoolSeries Class.

    Instead I seem to be limited to using a double with DataSeries Class. See attached files.
    Last edited by borland; 07-29-2016, 07:01 PM.

    #2
    Hello borland,

    This depends on what you are trying to do.

    The input series of an indicator can only be a dataseries. The primary data series of an indicator will always be a data series.

    But you can make a property that is an int series and pass this in.
    Code:
    In the indicator #region Variables:
    private IntSeries myIntSeries;
    
    In the indicator #region Properties:
    [Browsable(false)]
    [XmlIgnore()]
    public IntSeries IntSeriesInput
    {
    	get { return myIntSeries; }
    }
    
    In the strategy #region Variables:
    private IntSeries myIntSeries;
    
    In the strategy Initialize():
    myIntSeries = new IntSeries(this);
    
    In the Strategy where the indicator is called:
    Print(IndicatorName(Input, myIntSeries)[0].ToString());
    Last edited by NinjaTrader_ChelseaB; 07-29-2016, 07:00 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      What I want to do is to is to have the strategy evaluate a conditional statement as true or false and have the indicator plot the result for each bar. The indicator will plot a 1 value for true and -1 value for false.

      My original code that passed a DataSeries seems to work until I add another BarsArray with the Add() function...that causes the NT7 to crash.

      I tried your recommendations, but got bogged down with compile errors. It doesn't like the Add statement in the Strategy file.

      Code:
      Add(MyAlgoToolIndicator3(Input, myIntSeries));
      How would I then set my plot values. Like this?

      Code:
      if (myIntSeries[0] == 1) 
       {
        Value.Set(1);
        PlotColors[0][0] = Color.LightGreen;
      }
      else
      {
      Value.Set(-1);
      PlotColors[0][0] = Color.Red;
      }
      Last edited by borland; 07-29-2016, 07:00 PM.

      Comment


        #4
        Hello borland,

        I understand you are trying to plot from a strategy.

        You do not need to pass an int series to do this. You can set the the plot of an indicator directly.

        IndicatorName(0).Value.Set(-1);

        Below is a link to the nt reference sample that demonstrates this.
        http://ninjatrader.com/support/forum...ead.php?t=6651
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks ChelseaB,

          Yes, besides setting the plot value from the Strategy, you can also change the plot color.

          I got it working and no crashes after adding a second time series. I've attached my working NT7 files.

          I don't understand in your referenced example, why they are sending a dummy argument (variable: id). The example implies they are using it to identify which plot, but that is not what's happening. Anyway, I can't seem to eliminate the dummy variable without compile errors. Any ideas?
          Attached Files

          Comment


            #6
            Hi borland,

            The parameter for the indicator call is to keep the indicators separate. If the same indicator with the same parameters is called twice, NinjaTrader with cache this and only create one instance to save resources. (If the indicator is the same and the parameters are the same, then it should give the same values. No need to make a second instance.)

            The indicator itself has a public property. You would need to remove the public property from the indicator to not have to use the parameter when calling the indicator.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            6 responses
            28 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by gbourque, Today, 06:39 AM
            2 responses
            14 views
            0 likes
            Last Post gbourque  
            Started by rexsole, Today, 08:39 AM
            0 responses
            4 views
            0 likes
            Last Post rexsole
            by rexsole
             
            Started by trilliantrader, Yesterday, 03:01 PM
            3 responses
            31 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by Brevo, Today, 01:45 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X