Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Master and Secondary Strategy files
Collapse
X
-
Hello bltdavid,
We are only going to provide support/advise for things that are documented and have been thoroughly tested/used by our support team.
We don't have educational examples built using abstract classes so we are not going to provide insight for using them with NinjaScript.
Leave a comment:
-
Hello bltdavid,
Thank you for your reply.
Jim is out of the office today and I would need to confirm that with him. I will confirm whether or not this would be the case with him when he returns.
Thanks in advance for your patience.
Leave a comment:
-
Originally posted by NinjaTrader_Jim View PostThere can be limitations with using more advanced C# concepts like inheritance (and other concepts) where NinjaScript wrappers for indicators cannot be properly applied.
We have some examples showing how partial classes can be used in NinjaScript, but we do not have examples prepared for abstract classes and methods.
Since we have not fully navigated those ideas, we would not officially support/suggest using those concepts.
no such limitation exists when an abstract base class is used
with a Strategy-- is that correct?
Leave a comment:
-
Hello bltdavid,
There can be limitations with using more advanced C# concepts like inheritance (and other concepts) where NinjaScript wrappers for indicators cannot be properly applied.
We have some examples showing how partial classes can be used in NinjaScript, but we do not have examples prepared for abstract classes and methods.
Since we have not fully navigated those ideas, we would not officially support/suggest using those concepts.
Leave a comment:
-
Originally posted by NinjaTrader_Kate View PostThere can be limitations using advanced C# concepts in NinjaScript, so your mileage may vary
With regard to use of an 'abstract base class' ...
Can you provide any specific examples where its use caused a problem?
I mean, to what limitations are you referring to?
ThanksLast edited by bltdavid; 11-06-2021, 11:23 PM.
Leave a comment:
-
Originally posted by bltdavid View Post
Hmm, you may have a lot of learning ahead of you.
(But that's ok, there are plenty of paths forward.)
I just wanted to say,
You actually asked about an advanced topic common to every professional
programmer everywhere: and that is how to best organize the code so you
have as little duplication and overlap as possible.
You even used a common code word among engineers -- the word "refactor"
suggested to me that you might know something about the need and benefits
of such code organization. Perhaps I was wrong -- but that's ok.
What I want to say is: Welcome to the world of Software Engineering 101.
I'm not being mean or condescending at all. I'm trying to say, if you are new
to this, then your wonderful journey of discovery is about to begin. The C#
language is very elegant and quite beautiful, but learning (more of) it may
come at a considerable cost -- mostly your time.
My point is: Don't give up!
Keep learning, the dividends from mastering the examples in that website link
will provide you enormous benefits as you move forward with NinjaScript.
Some very advanced concepts in the C# language were invented precisely
to help organize code. To do what you are asking, take my example and
understand how MyStrategyBase fits into the class hierarchy -- technically,
you would say "MyStrategyBase extends Strategy" -- then keep on reading
about C# classes and surfing the web for more examples and tutorials.
Hang in there!
You are not mean or codescending, I am familiar with your posts and I found you being helpful in other topics.
What I consider as difficulty for me - all the resources on web are for pure C# and there are so few courses dedicated to NinjaTrader coding. It is interesting and I follow along, as long as I have resources. But once I am stuck, it gets difficult. I find myself having much more ideas than skills and knowledge that would let me implement those ideas.
Leave a comment:
-
Originally posted by bltdavid View PostSure.
Study the attached files.
The abstract base class "MyStrategyBase" acts like a middle-man.
You're inserting this class into the inheritance hierarchy, and anything
in MyStrategyBase has full and complete access to the class it inherits
from -- in this case, the Strategy class.
You add your own methods, variables, properties, to MyStrategyBase.
The reason this is so powerful is that you are extending the 'Strategy'
class with new 'features' -- sorta like what a partial class does -- but
you can really fine tune the contents of MyStrategyBase for just one or
two strategies -- or you can make it a common base that you use for all
your strategies.
Inheritance is the heart and soul of OOP, and the C# language supports
inheritance extremely well.
There are lots of resources on the web.
Inheritance is a standard feature of the C# language.
Good luck!
For sample strategy attached, it will color the background based upon the
begin/end times you specify (but stop coloring for the break period, which
represents known high volatility times, like for an economic report).
For ex,
Trade BeginTime = 600
Trade EndTime = 1100
Break BeginTime = 900
Break EndTime = 930
Restricts trading to the hours 6am to 11am, with a 30min break starting
at 9am. All times 24hr format, and all times are local.
Leave a comment:
-
Originally posted by UltraNIX View PostThank you, even though examples in that website are not that easy for me to implement.
(But that's ok, there are plenty of paths forward.)
I just wanted to say,
You actually asked about an advanced topic common to every professional
programmer everywhere: and that is how to best organize the code so you
have as little duplication and overlap as possible.
You even used a common code word among engineers -- the word "refactor"
suggested to me that you might know something about the need and benefits
of such code organization. Perhaps I was wrong -- but that's ok.
What I want to say is: Welcome to the world of Software Engineering 101.
I'm not being mean or condescending at all. I'm trying to say, if you are new
to this, then your wonderful journey of discovery is about to begin. The C#
language is very elegant and quite beautiful, but learning (more of) it may
come at a considerable cost -- mostly your time.
My point is: Don't give up!
Keep learning, the dividends from mastering the examples in that website link
will provide you enormous benefits as you move forward with NinjaScript.
Some very advanced concepts in the C# language were invented precisely
to help organize code. To do what you are asking, take my example and
understand how MyStrategyBase fits into the class hierarchy -- technically,
you would say "MyStrategyBase extends Strategy" -- then keep on reading
about C# classes and surfing the web for more examples and tutorials.
Hang in there!
- Likes 2
Leave a comment:
-
Sure.
Study the attached files.
The abstract base class "MyStrategyBase" acts like a middle-man.
You're inserting this class into the inheritance hierarchy, and anything
in MyStrategyBase has full and complete access to the class it inherits
from -- in this case, the Strategy class.
You add your own methods, variables, properties, to MyStrategyBase.
The reason this is so powerful is that you are extending the 'Strategy'
class with new 'features' -- sorta like what a partial class does -- but
you can really fine tune the contents of MyStrategyBase for just one or
two strategies -- or you can make it a common base that you use for all
your strategies.
Inheritance is the heart and soul of OOP, and the C# language supports
inheritance extremely well.
There are lots of resources on the web.
Inheritance is a standard feature of the C# language.
Good luck!
For sample strategy attached, it will color the background based upon the
begin/end times you specify (but stop coloring for the break period, which
represents known high volatility times, like for an economic report).
For ex,
Trade BeginTime = 600
Trade EndTime = 1100
Break BeginTime = 900
Break EndTime = 930
Restricts trading to the hours 6am to 11am, with a 30min break starting
at 9am. All times 24hr format, and all times are local.
- Likes 4
Leave a comment:
-
Originally posted by NinjaTrader_Kate View PostHello UltraNix,
Thank you for your reply.
Abstract classes are a C# concept and would be unsupported by NinjaTrader staff. There can be limitations using advanced C# concepts in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.
A publicly available resource can be found here: https://www.geeksforgeeks.org/c-sharp-abstract-classes/
Please let us know if we may be of further assistance to you.
Leave a comment:
-
Hello UltraNix,
Thank you for your reply.
Abstract classes are a C# concept and would be unsupported by NinjaTrader staff. There can be limitations using advanced C# concepts in NinjaScript, so your mileage may vary. As of now, we do not have any examples that can be used to navigate that path.
A publicly available resource can be found here: https://www.geeksforgeeks.org/c-sharp-abstract-classes/
Please let us know if we may be of further assistance to you.
Leave a comment:
-
Originally posted by bltdavid View PostAlthough Kate means well, I would forget the 'partial class' suggestion.
There is a better way.
Create your own abstract base class that inherits from Strategy.
Code:abstract public class MyStrategyBase : Strategy
All of your common strategy code goes into MyStrategyBase.
Leave a comment:
-
Although Kate means well, I would forget the 'partial class' suggestion.
There is a better way.
Create your own abstract base class that inherits from Strategy.
Code:abstract public class MyStrategyBase : Strategy
All of your common strategy code goes into MyStrategyBase.
Leave a comment:
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by jpkulkarni, Today, 09:27 PM
|
0 responses
4 views
0 likes
|
Last Post
by jpkulkarni
Today, 09:27 PM
|
||
Started by Scalper888, Yesterday, 05:09 PM
|
5 responses
23 views
0 likes
|
Last Post
by Scalper888
Today, 06:43 PM
|
||
Started by CardozoPeggy, Today, 06:01 PM
|
0 responses
3 views
0 likes
|
Last Post
by CardozoPeggy
Today, 06:01 PM
|
||
Started by aaaa7389, Today, 05:33 PM
|
0 responses
4 views
0 likes
|
Last Post
by aaaa7389
Today, 05:33 PM
|
||
Started by aaaa7389, Today, 05:32 PM
|
0 responses
5 views
0 likes
|
Last Post
by aaaa7389
Today, 05:32 PM
|
Leave a comment: