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 04-01-2012, 03:26 AM   #1
rabcnesbit
Member
 
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
Default Accessing values from another indicator.

Hello NT Support (or anyone else please).

I have an indicator, in this case named KayButtons. I have "private IntSeries buttonCode;" in variables, have "buttonCode = new IntSeries(this);" in protected override void Initialize(), and in protected override void OnBarUpdate(), have "buttonCode.Set(1) or buttonCode.Set(2) or buttonCode.Set(3), depending on certain conditions. I also have the code below in properties:
[Browsable(false)]
[XmlIgnore()]
public IntSeries ButtonCode
{
get { return buttonCode; }
}



By the way, I am still a novice in NTScripts / C#. I just make do by nicking and amending snippets of codes here and there. What I wanted to do was access the value of buttonCode.Set from another of my indicators, in this case named KayStopLines3. So in KayStopLines3, I have the following code in protected override void OnStartUp(), if (KayButtons.ButtonCode == 1)

Unfortunately, I get the following error when I try to compile it:
'NinjaTrader.Indicator.Indicator.KayButtons()' is a 'method' which is not valid in this given context

Could I please request your assistance in resolving this error please?

Many thanks
Dan

rabcnesbit is offline  
Reply With Quote
Old 04-01-2012, 09:07 AM   #2
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,224 times in 995 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by rabcnesbit View Post
Hello NT Support (or anyone else please).

I have an indicator, in this case named KayButtons. I have "private IntSeries buttonCode;" in variables, have "buttonCode = new IntSeries(this);" in protected override void Initialize(), and in protected override void OnBarUpdate(), have "buttonCode.Set(1) or buttonCode.Set(2) or buttonCode.Set(3), depending on certain conditions. I also have the code below in properties:
[Browsable(false)]
[XmlIgnore()]
public IntSeries ButtonCode
{
get { return buttonCode; }
}


By the way, I am still a novice in NTScripts / C#. I just make do by nicking and amending snippets of codes here and there. What I wanted to do was access the value of buttonCode.Set from another of my indicators, in this case named KayStopLines3. So in KayStopLines3, I have the following code in protected override void OnStartUp(), if (KayButtons.ButtonCode[0] == 1)

Unfortunately, I get the following error when I try to compile it:
'NinjaTrader.Indicator.Indicator.KayButtons()' is a 'method' which is not valid in this given context

Could I please request your assistance in resolving this error please?

Many thanks
Dan
ButtonCode is an IntSeries, so should be properly referenced with an index (CurrentValue == index zero). Correction is in the code.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 04-01-2012, 03:36 PM   #3
rabcnesbit
Member
 
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by koganam View Post
ButtonCode is an IntSeries, so should be properly referenced with an index (CurrentValue == index zero). Correction is in the code.
Hello koganam,

Thanks for your reply. I tried your suggestion above - if (KayButtons.ButtonCode[0] == 1), but I still get the same error message when I tried to compile it.

Thanks
Dan
rabcnesbit is offline  
Reply With Quote
Old 04-01-2012, 04:28 PM   #4
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,224 times in 995 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by rabcnesbit View Post
Hello koganam,

Thanks for your reply. I tried your suggestion above - if (KayButtons.ButtonCode[0] == 1), but I still get the same error message when I tried to compile it.

Thanks
Dan
My mistake. You have to reference the indicator with its calling parameters.

if (KayButtons(string[] Parameters).ButtonCode[0] == 1)

i.e, the calling convention is always

Class(parameter list).TypeOfSeries[int index]
Last edited by koganam; 04-01-2012 at 04:31 PM.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 04-01-2012, 05:20 PM   #5
rabcnesbit
Member
 
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by koganam View Post
My mistake. You have to reference the indicator with its calling parameters.

if (KayButtons(string[] Parameters).ButtonCode[0] == 1)

i.e, the calling convention is always

Class(parameter list).TypeOfSeries[int index]
Thanks koganmam.

What will be the calling parameters, i.e. what should I put inside (string[] Parameters) ?

Thanks
Dan
rabcnesbit is offline  
Reply With Quote
Old 04-01-2012, 06:19 PM   #6
koganam
Senior Member
 
Join Date: Feb 2008
Location: Durham, North Carolina, USA
Posts: 3,199
Thanks: 24
Thanked 1,224 times in 995 posts
Send a message via Skype™ to koganam
Default

Quote:
Originally Posted by rabcnesbit View Post
Thanks koganmam.

What will be the calling parameters, i.e. what should I put inside (string[] Parameters) ?

Thanks
Dan
The calling parameters are the inputs that you have specified in the public properties for the indicator, when you coded the indicator. (i.e., any property that has a setter). Intellisense should be able to help you, if you cannot determine the correct order.
koganam is offline  
Reply With Quote
The following user says thank you to koganam for this post:
Old 04-02-2012, 09:32 AM   #7
rabcnesbit
Member
 
Join Date: Aug 2011
Posts: 45
Thanks: 11
Thanked 0 times in 0 posts
Default

Quote:
Originally Posted by koganam View Post
The calling parameters are the inputs that you have specified in the public properties for the indicator, when you coded the indicator. (i.e., any property that has a setter). Intellisense should be able to help you, if you cannot determine the correct order.
Many thanks.
rabcnesbit 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
Accessing other indicator boolean values tacticaltrader General Programming 3 09-26-2011 04:28 AM
Accessing indicator values without plots suprsnipes Indicator Development 1 08-25-2010 05:23 AM
Accessing Personal Indicator Values (How To) rhbishop5 Indicator Development 2 04-12-2010 05:06 AM
Accessing Custom Indicator Values murfinp Indicator Development 2 08-25-2009 02:11 PM
Accessing Multi Timeframe Indicator Values TAJTrades Indicator Development 11 03-02-2009 07:11 AM


All times are GMT -6. The time now is 05:23 PM.