Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
What's the problem if I add enterLong() inside of Indicator() instead of Stragtegy()?
Collapse
X
-
What's the problem if I add enterLong() inside of Indicator() instead of Stragtegy()?
https://ninjatrader.com/support/help...vel_ii_dat.htm has sample scripts for level 2 book. The book is implemented in the space of Indicator(). What if I add EnterLong() inside of OnBarUpdate() under Indicator()? Is this doable or I have to call EnterLong() under Strategy()? Thanks.Tags: None
-
You should receive a compilation error.Originally posted by localappleseed View PostWhat if I add EnterLong() inside of OnBarUpdate() under Indicator()?
Did you try it?Originally posted by localappleseed View PostIs this doable or I have to call EnterLong() under Strategy()?
The 'Indicator' class does not provide that method.
Think about it:
When your code does this,
your class 'MyXXX' inherits all the methods provided by the base class 'Indicator'.Code:namespace NinjaTrader.NinjaScript.[COLOR=#e74c3c]Indicators[/COLOR] { public class MyXXX : [COLOR=#e74c3c]Indicator[/COLOR] { ... } }
The 'Indicator' class does not have a method called 'EnterLong', so you should
receive a compilation error if you do that.
On other other hand,
When your code does this,
your class 'MyXXX' inherits all the methods provided by the base class 'Strategy'.Code:namespace NinjaTrader.NinjaScript.[COLOR=#e74c3c]Strategies[/COLOR] { public class MyXXX : [COLOR=#e74c3c]Strategy[/COLOR] { ... } }
The 'Strategy' class does have a method called 'EnterLong', so no error occurs.
Btw, the exact same class name 'MyXXX' is allowed -- this is not an error.
Why? Because the two 'MyXXX' classes are in different namespaces.
It's a bit confusing, because the base classes 'Indicator' and 'Strategy' provide
a huge amount of overlap in the methods they provide -- for example, both
classes have methods called 'Print', 'Alert', 'OnBarUpdate', etc etc.
But only 'Strategy' provides the order methods.
-
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, 03-31-2026, 09:41 PM
|
1 response
43 views
0 likes
|
Last Post
|
||
|
Started by CarlTrading, 04-01-2026, 02:41 AM
|
0 responses
21 views
0 likes
|
Last Post
by CarlTrading
04-01-2026, 02:41 AM
|
||
|
Started by CaptainJack, 03-31-2026, 11:44 PM
|
0 responses
30 views
1 like
|
Last Post
by CaptainJack
03-31-2026, 11:44 PM
|
||
|
Started by CarlTrading, 03-30-2026, 11:51 AM
|
0 responses
50 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:51 AM
|
||
|
Started by CarlTrading, 03-30-2026, 11:48 AM
|
0 responses
40 views
0 likes
|
Last Post
by CarlTrading
03-30-2026, 11:48 AM
|

Comment