NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


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

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 12-19-2008, 05:10 PM   #1
SteveB
Senior Member
 
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default Shared class

I'm sure there is a simple solution...(VB.NET guy)...

I want to create a class I can call from all other strategies.

namespace NinjaTrader.Strategy
{
partial class Strategy
{
}
public class clsAccount
{
public void Check_OpenOrders()
{

}
}
}

In my Strategy I have:

clsAccount Acct = new clsAccount();

Acct.Check_OpenOrders;

NT is flagging the semi-colon at the end of Acct.Check_OpenOrders;

The error I'm getting is:
Class member declaration expected.
Invalid token ";" in class, struct, or interface member declaration.

It makes no difference if my class is within the "partial class Strategy" brackets or not...

Thanks!
Last edited by SteveB; 12-20-2008 at 08:39 AM.
SteveB is offline  
Reply With Quote
Old 12-19-2008, 06:29 PM   #2
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

just after a quick look.

dont you need a () at the end since Check_OpenOrders() is a function?
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 12-19-2008, 06:49 PM   #3
SteveB
Senior Member
 
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default

Sorry, I did try that before...the error message with "()" is:

Invalid token "(" in class, struct, or interface member declaration.
SteveB is offline  
Reply With Quote
Old 12-20-2008, 01:42 AM   #4
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

I do count 7 curly braces in total, 1 seems to be missing.

Regards
Ralph
Ralph is offline  
Reply With Quote
Old 12-20-2008, 08:37 AM   #5
SteveB
Senior Member
 
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default

I appreciate everyone's help; it's not a bracket thing...just conveying my simple problem...

I can't believe something this simple is so difficult.

VB.Net guy
SteveB is offline  
Reply With Quote
Old 12-20-2008, 08:46 AM   #6
mrlogik
Certified NinjaScript Consultant
 
mrlogik's Avatar
 
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
Default

I made a GlobalVariables Indicator and posted it on this forum a few months ago. Since, I have also made a GlobalStrategy Strategy for use of global variables within strategies.

Take a look at the attached.

I have in here Set / Get methods for support / resistance values, but this can easily be changed for what you want.

You can reference this for aid, as well as this.

good luck.
"You look closely enough, you can find everything has a ... weak spot where it can break, sooner or later"

PureLogikTrading
mrlogik is offline  
Reply With Quote
Old 12-20-2008, 09:20 AM   #7
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

Hi Steve,

it is not a simple problem, because your code works, with the syntax as proposed by mrlogik.

It doesn't matter if one defines the clsAccount-class inside the the Strategy-class or just in the NinjaTrader.Strategy-namespace.
It is possible to call Acct.Check_OpenOrders() in Initialize() for example.

... but it doesn't work to apply Acct.Check_OpenOrders() outside a class-method and that raises the same error message you mentioned.
Is that your problem?

Regards
Ralph
Ralph is offline  
Reply With Quote
Old 12-20-2008, 04:35 PM   #8
SteveB
Senior Member
 
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
Default

Thank You Ralph!

Yes I was putzing just to get an example up and running and had the code outside a class.

Inside works like a charm.
SteveB 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
Replacing a shared indicator with an updated version Elliott Wave Miscellaneous Support 9 07-08-2009 07:38 AM
NinjaScript class? Speedie6 General Programming 1 11-03-2008 10:04 AM
Indicator Class Januson General Programming 5 06-18-2007 02:27 PM
Shared Draww methods only worl in Panel 1 scjohn General Programming 1 05-27-2007 12:51 PM
Access from external class VagyokC4 General Programming 4 03-30-2007 01:01 AM


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