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

Values.Set error

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

    Values.Set error

    Hello,

    I have a DataSeries named "tradeSignal" that I'm having trouble plotting/exposing.

    Code:
    double tempVar = tradeSignal[0];
    Values[0].Set(tempVar);
    Code:
    Values[1] = tradeSignal;
    The first block of code --- Values[0].Set(tempVar) --- produces the correct result.

    The second does not. Exposing tradeSignal through the following code produces the same incorrect result as Values[1] = tradeSignal :

    Code:
    [Browsable(false)]    
    [XmlIgnore()]        
    public DataSeries TradeSignal
    {
         get { return tradeSignal; }
    }
    Do you have any idea what may be wrong?

    Thanks in advance.

    -Nick

    #2
    Hi Nick,

    If you want to expose a plot value from another indicator, set it up as a plot, and set the plot using the public name you've created. There's not much of an advantage working with Values collection directly except as a shorthand technique, or if you wanted to do some looping through it. If you aren't sure how to setup plots, the Tools > New NinjaScript > indicator wizard does this for you automatically. Then access the named plot from another indicator.

    If you want to maintain it as a data series only (no visualization), see this sample for how to structure. You'll follow the same structure used in the boolseries here but for your data series.
    Last edited by NinjaTrader_RyanM1; 03-05-2012, 01:31 PM.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      I did expose the tradeSignal DataSeries through:

      Code:
      [Browsable(false)]     
      [XmlIgnore()]         
      public DataSeries TradeSignal 
      {      
           get { return tradeSignal; }
      }
      My problem is that it is exposing the wrong value.

      However, if I first assign the DataSeries to a variable:

      Code:
      double tempVar;
      tempVar = tradeSignal[0];
      and then expose tempVar, the exposed values are correct.

      Code:
      [Browsable(false)]     
      [XmlIgnore()]         
      public double TradeSignal2 
      {      
           get { return tempVar; }
      }
      I'm trying to understand why that is the case.

      Thanks again.

      -Nick

      Comment


        #4
        Sorry, I'm not sure. You can either set up the value as plot, or follow the conventions in the exposing non-plot value sample. The sample has different techniques for exposing *Series values compared to non-series values.

        If you are following all that and it's still not working the way you expect I'm happy to take a look from here. Please post the complete NS .zip file and let me know how to identify the discrepancy.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Thanks for the prompt reply.

          Hmm, I'm thinking of just assigning tradeSignal[0] to a double variable, and exposing it that way, as per my example above, since it works. The indicator is about 3000 lines long, and I think it'll be a major pain in the *** to figure out the problem.

          Is there a performance hit of any sort by doing it this way? Or any unforeseen issues I might run into in the future?

          Comment


            #6
            One quick thing to check is that you're not assigning CalculateOnBarClose in the hosted indicator at all.

            There should not be much of a performance hit with that approach. If you expose a double value, you need to ensure you're using Update() in the get accessor (properties region) to ensure up-to-date values. This is handled already when using *Series but needs to be added for doubles.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by wuannetraam, Today, 02:40 AM
            0 responses
            7 views
            0 likes
            Last Post wuannetraam  
            Started by cyberpete76, 03-27-2023, 12:29 AM
            7 responses
            268 views
            1 like
            Last Post slightly  
            Started by renewsaltwater, Today, 01:15 AM
            0 responses
            2 views
            0 likes
            Last Post renewsaltwater  
            Started by slightly, Today, 12:49 AM
            0 responses
            4 views
            0 likes
            Last Post slightly  
            Started by sdauteuil, 09-23-2021, 10:16 AM
            4 responses
            1,211 views
            0 likes
            Last Post jacobpescaia44  
            Working...
            X