Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get plot value through reflection

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

    Get plot value through reflection

    I am able to get the value of middle band of Bollinger with the below code.

    Code:
    double value = Bollinger(2,14).Values[1][0];
    How can I do it with Reflection? Below is the code I have tried so far.

    Code:
    Type[] dataTypes = null;
    MethodInfo methodInfo = null;
    object[] params = new object[2];
    
    // Some code to get data types of method to "dataTypes" (System.Double,System.Int32)
    // Some code to get parameters for the method to "params" (2,14)
    // Some code to get information to "methodInfo" (Bollinger(2,14))
    
    IDataSeries dataSeries = (IDataSeries)methodInfo.Invoke(this, params);
    double value = dataSeries[0];
    When I execute the above statement , I could get the value(for example,1650.00) in the variable "value". The issue is, I could not specify the band ie, Upper or Middle or Lower. I tried the below code.

    Code:
    double value = dataSeries.Values[1][0];
    but didn't work and throwing error. Is there a way out?

    Thanks in advance,
    SagarAliasJacky
    Last edited by SagarAliasJacky; 03-03-2015, 06:10 AM.

    #2
    Hello SagarAliasJacky,

    Thank you for your post.

    Why do you want to use reflection to get the values of the Middle DataSeries?

    This DataSeries is public and available to call in the indicator you are writing -
    Code:
    Bollinger(2, 14).Middle[0]
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hello SagarAliasJacky,

      Thank you for your post.

      Why do you want to use reflection to get the values of the Middle DataSeries?

      This DataSeries is public and available to call in the indicator you are writing -
      Code:
      Bollinger(2, 14).Middle[0]
      No i cannot hardcode

      Code:
      Bollinger(2, 14).Middle[0]
      Because the indicator names will be dynamic and I am getting the instance from indicator name through Reflection. Using Reflection I store the indicators in a IDataseries variable.

      Code:
      IDataSeries dataSeries = (IDataSeries)methodInfo.Invoke(this, params);
      I could get the value by applying lookback period on each bar update from dataSeries variable by

      Code:
      double value = dataSeries[0];
      But, how can I get the plot from dataSeries variable? I tried the below code but didn't work

      Code:
      double value = dataSeries.Values[1][0];
      How can I get the Plot of each Indicator dynamically?
      Last edited by SagarAliasJacky; 03-03-2015, 10:20 PM.

      Comment


        #4
        SagarAliasJacky,

        Instead of using an IDataSeries you may want to try using Indicator.
        Code:
        IndicatordataSeries = (Indicator)methodInfo.Invoke(this, params);
        Additionally, what makes you think that you need to use Reflection for this route?
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          SagarAliasJacky,

          Instead of using an IDataSeries you may want to try using Indicator.
          Code:
          IndicatordataSeries = (Indicator)methodInfo.Invoke(this, params);
          Additionally, what makes you think that you need to use Reflection for this route?
          Thank you Carl. That worked.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          603 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          349 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          104 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          560 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          560 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X