NexusFi: Find Your Edge


Home Menu

 





Get plot value through reflection


Discussion in NinjaTrader

Updated
    1. trending_up 1,360 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 6 posts
    2. attach_file 0 attachments




 
Search this Thread

Get plot value through reflection

  #1 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0

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 throws error. Is there a way out?

Thanks in advance,
thesarath

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
How to apply profiles
Traders Hideout
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
48 thanks
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
24 thanks
GFIs1 1 DAX trade per day journal
22 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


What do you need it for, I mean what is the purpose of the whole exercise?

Reply With Quote
  #4 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0


Fat Tails View Post
What do you need it for, I mean what is the purpose of the whole exercise?

I can select a set of indicators from a list, can select the plot for each indicator and need to get each indicator's plot value at runtime.

Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


thesarath View Post
I can select a set of indicators from a list, can select the plot for each indicator and need to get each indicator's plot value at runtime.

I have used an enum for the list of indicators and then attributed the selected indicators to an IDataSeries object in OnStartUp. An example would be the SuperTrendU11, which works with 29 different moving averages. It can be downloaded here:



Is that the solution you look for, or do you try to instantiate indicators dynamically?


PS: I just saw that you cannot download files, as you are not an elite member. Please send me a private message with your e-mail and I will send you the indicator, so that you can check it.

Reply With Quote
  #6 (permalink)
thesarath
Cochin
 
Posts: 8 since Dec 2014
Thanks Given: 1
Thanks Received: 0


Fat Tails View Post
I have used an enum for the list of indicators and then attributed the selected indicators to an IDataSeries object in OnStartUp. An example would be the SuperTrendU11, which works with 29 different moving averages. It can be downloaded here:



Is that the solution you look for, or do you try to instantiate indicators dynamically?


PS: I just saw that you cannot download files, as you are not an elite member. Please send me a private message with your e-mail and I will send you the indicator, so that you can check it.

Yes. I instantiate the indicators dynamically at runtime in a loop and store them in a List<IDataSeries>.

Reply With Quote
  #7 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


thesarath View Post
Yes. I instantiate the indicators dynamically at runtime in a loop and store them in a List<IDataSeries>.

But do you want to select the indicators from a dropdown list, or would you prefer instantiating them by using a string?

I have sent you the SuperTrendU11, so you can check whether that solution would work for you.

Reply With Quote




Last Updated on March 3, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts