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-09-2012, 06:24 AM   #1
DaFish
Junior Member
 
Join Date: Jan 2012
Posts: 28
Thanks: 11
Thanked 2 times in 1 post
Default How do I pass in CCI(14) to a method

Hi, I want to write a method that will take an indicator parameter and then check swings on it. I want to pass various indicators to this function... I don't know how to do that.

Here is what I want to do from an indicator or strategy:

CCI(14) is the indicator I want to pass to the method

then call

MFSwing (CCI(14))
or
MFSwing (ROC(14))

publicbool MFSwing ("somehow pass in CCI(14)")
{
bool retval = false;
// Swing
if (Swing("somehow use CCI(14) here ",1).SwingLowBar(1, 1, 4))
{
retval=true;

}


return (retval);
}

I don't know how or if I can do that.
DaFish is offline  
Reply With Quote
Old 03-09-2012, 06:45 AM   #2
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Thanks for the note.

You would use this syntax:

Code:
private void Method(IDataSeries dataSeries)
{
 
 }
NinjaTrader_Brett is offline  
Reply With Quote
Old 03-09-2012, 07:16 AM   #3
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Just to make sure I had to make an edit to the below post.

Please recheck the below if you have already read my post.

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
Old 03-09-2012, 09:17 AM   #4
DaFish
Junior Member
 
Join Date: Jan 2012
Posts: 28
Thanks: 11
Thanked 2 times in 1 post
Default

Quote:
Originally Posted by NinjaTrader_Brett View Post
Hello,

Thanks for the note.

You would use this syntax:

Code:
private void Method(IDataSeries dataSeries)
{
 
 }
Hi Brett, thanks for responding so quickly. I am not sure if I understand. I don't want to pass in the VALUE of the CCI(14), I want to pass in to the method to USE the indicator CCI(14) in that method.

MFSwing (CCI(14)) - not the value, but tell the method to start using the indicator passed in.
or

MFSwing (ROC(14))

publicbool MFSwing ("passed in indicator and parameter - IE: CCI(14)")
{

private int indicatorvalue;
indicatorvalue = "passed in indicator and parameter - IE: CCI(14)"

I want this to look like:
indicatorvalue = CCI(14);
or
indicatorvalue = ROC(14);

this is so I can reuse all the code for doing some custom swing stuff and keep it all together in 1 method and just pass in different indicators

}


DaFish is offline  
Reply With Quote
Old 03-09-2012, 11:02 AM   #5
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Default

We are on the same page as you. I think the following code example will better illustrate the concept.

Code:
protected override void OnBarUpdate()
{
   DoSomething(CCI(14));
}
 
private void DoSomething(IDataSeries dataSeries)
{
   double indicatorValue = 0;
   indicatorValue = dataSeries[0];
   Print(indicatorValue);
}
NinjaTrader_Ray is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Ray for this post:
Old 03-09-2012, 11:20 AM   #6
NinjaTrader_Brett
NinjaTrader Customer Service
 
NinjaTrader_Brett's Avatar
 
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
Default

Hello,

Please see this information as well on this to further round out your understanding and let me know if you have further questions.

http://www.ninjatrader.com/support/h...dataseries.htm

-Brett
NinjaTrader_Brett is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Brett for this post:
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
How to pass Instrument traded to another chart? Taddypole General Programming 1 11-13-2011 11:30 AM
Two Pass Scanning of Data - Possible? tazatek Indicator Development 16 11-18-2009 08:57 PM
CCI Ninja Versus CCI Tradestation bamill11 Indicator Development 4 12-01-2008 07:48 PM
Which symbol should I pass to NTCommand()? clearpicks Automated Trading 5 05-27-2008 11:00 PM
New Pass in MB now I can't login to NT eudamonia Connecting 3 03-07-2007 06:18 AM


All times are GMT -6. The time now is 12:32 PM.