NinjaTrader Support Forum  

Go Back   NinjaTrader Support Forum > NinjaScript Development Support > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 03-15-2010, 03:42 AM   #1
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default How do I access methods in an indicator for

a strategy? For example, in this custom indicator, there are numbers values that have been calculated which I need to build a strategy, how would I be able to access those values?
kaywai is offline  
Reply With Quote
Old 03-15-2010, 04:45 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Kay, if those are indicator plots they can be directly accessed as they are exposed by default already...if you want to access internal variables and unplotted data, you would need to with the concept presented here -

http://www.ninjatrader-support2.com/...ead.php?t=4991
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-15-2010, 05:11 AM   #3
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

Bertrand, I thought I followed the example you provided by Adding the indicator like this:-
Code:

protectedoverridevoid Initialize()
{
Add(TDSetup);
Add(draftMA1);
CalculateOnBarClose = true;
}
First error: The name TDSetup doesnot exist in the current context.
Second error: The best overloaded method match for 'NinjaTrader.Strategy.StrategyBase.Add(NinjaTrader .Indicator.IndicatorBase)' has some invalid arguments.
Third error: cannot convert from 'method group' to 'NinjaTrader.Indicator.IndicatorBase'

Please advise what is wrong. Thx!
kaywai is offline  
Reply With Quote
Old 03-15-2010, 06:00 AM   #4
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

HI Bertrand, Just an update...I think I've solved most of the errors except the 1st one - First error: The name TDSetup doesnot exist in the current context.

Can't access it from the strategy.
kaywai is offline  
Reply With Quote
Old 03-15-2010, 06:02 AM   #5
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Is the TDSetup a plot from an indicator (shown in datseries when you apply in on the chart) or an internal value of an indicator?
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-15-2010, 06:17 AM   #6
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

It is actually a series of 9 consecutive counts where each count's close is lower than the respective close 4 bars ago. it is a non-conventional indicator i suppose, which is why i asked how do you access methods from within an indicator for use in a strategy...
kaywai is offline  
Reply With Quote
Old 03-15-2010, 06:26 AM   #7
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Kay, ok but is this a plot in the indicator or not? A plotted value could be directly accessed...

MyIndicator(Parameter1, Parameter2).MyFirstPlot[0] ...

If this is a not plotted value, you would need to expose it's values first to open it up for access via the calling strategy.
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-15-2010, 06:32 AM   #8
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

I don't think it is a plotted value. They are just arithmetically-derived text on the chart.

I guess what you are saying is the simplest way is to cut and paste the indicator to the strategy and build the strategy from there, no?
kaywai is offline  
Reply With Quote
Old 03-15-2010, 06:37 AM   #9
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

just an example of what i am trying to do (please see attached chart).

Everytime there is a descending '9' count, a "true" condition is triggered. And within 4 bars after the '9' count, if the close is greater than the purple line to enter a long position.
Attached Images
File Type: jpg ESA 03-10 2_6_2010 (3 Min).jpg (66.7 KB, 14 views)
kaywai is offline  
Reply With Quote
Old 03-15-2010, 06:37 AM   #10
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Yes, that would be an option too - the other is to expose needed values as per this reference sample -

http://www.ninjatrader-support2.com/...ead.php?t=4991
NinjaTrader_Bertrand is offline  
Reply With Quote
Old 03-15-2010, 07:13 AM   #11
kaywai
Senior Member
 
Join Date: Sep 2009
Posts: 562
Thanks: 40
Thanked 4 times in 4 posts
Default

Bertrand, I cut and pasted the indicator code to the strategy...2 errors

The name 'Overlay' doesnot exist in the current context.
The name 'PriceTypeSupported' does not exist in the current context.

Would removing these 2 lines from Initialize() affect the strategy? That would mean I will get no display on the chart, right? But everything is being worked in the background, right?
kaywai is offline  
Reply With Quote
Old 03-15-2010, 08:16 AM   #12
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,377
Thanks: 252
Thanked 966 times in 949 posts
Default

Kay, correct both those properties do not exist for NinjaScript strategies, so you would need to remove those to be able to compile it.

Not being familiar with your custom code, if you Draw it should be drawing in the strategy as well, but there would be no plots from the strategy excpect with workarounds...
NinjaTrader_Bertrand is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to .dll indicator ct Indicator Development 16 07-15-2010 11:31 AM
IDataSeries Usage In Indicator Methods borland General Programming 6 02-08-2010 07:44 AM
Access attributes of another indicator taotree Indicator Development 7 08-07-2009 04:29 AM
Access to same indicator with different periods snaphook General Programming 1 09-08-2008 06:54 AM
DOM access within indicator RedDuke Indicator Development 6 09-25-2007 10:24 AM


All times are GMT -6. The time now is 08:48 PM.