![]() |
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
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#2 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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 |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
Sorry, I did try that before...the error message with "()" is:
Invalid token "(" in class, struct, or interface member declaration. |
|
|
|
|
|
#4 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
I do count 7 curly braces in total, 1 seems to be missing.
Regards Ralph |
|
|
|
|
|
#5 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#6 |
|
Certified NinjaScript Consultant
Join Date: Sep 2006
Location: New York, USA
Posts: 774
Thanks: 1
Thanked 7 times in 5 posts
|
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 |
|
|
|
|
|
#7 |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
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 |
|
|
|
|
|
#8 |
|
Senior Member
Join Date: Jan 2008
Posts: 108
Thanks: 0
Thanked 0 times in 0 posts
|
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. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |