Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
UserDefinedMethods from NT7 to NT8
Collapse
X
-
Hello stevenev1,
I also have an example you may find helpful.
https://ninjatrader.com/support/forum/forum/historical-beta-archive/version-8-beta/83018-partial-class-does-not-work?p=712245#post712245
-
After long search, this is the solution that finally worked for me. It shares method between indicators, but not between indicators and strategies (which I don't need). Putting code in AddOns directory is for me very complex and involves passing parameters such as Highs/Lows, etc. which I do not want to do.
https://ninjatrader.com/support/foru...74#post1051574Last edited by stevenev1; 03-16-2019, 09:46 AM.
Leave a comment:
-
Hello kiss987,
That would not be possible the way you currently have it since the Addon class would have no idea what instrument you are requesting TickSize for.
It would be possible by using BarsRequest similar to the samples on the forum post that I linked to.
Leave a comment:
-
Thank you for your reply.
I'm not sure I'm following your answer. I have the following code:
public double ReturnTickSize()
{
return (TickSize);
}
which I want to transfer it to my add on, so it will be available for both indicators and strategies:
namespace NinjaTrader.NinjaScript.AddOns
{
public partial class MySharedMethods : NinjaTrader.NinjaScript.AddOnBase
{
}
}
How is that possible?
Thank you
Leave a comment:
-
Hello kiss987,
You would need to add a bars request to access that information inside the addon class. Please see the following post that includes 2 samples on implementing a bars request.
Help Guide- BarsRequest
Please let me know if you have any questions.
Leave a comment:
-
Thank you for your reply,
Can I use objects such as TickSize, Highs, etc. from:
public partial class MySharedMethods : NinjaTrader.NinjaScript.AddOnBase
{
}
I wan only able to do so from within:
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator
{
and:
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy
{
However, I do not want to duplicate my code for strategies and indicators.
Leave a comment:
-
Hello kiss987,
Thanks for your post.
You will want to copy/paste the entire Indicator namespace into a .cs file placed in the Addons folder.
Please see the sample script at the following forum post that demonstrates.
Please let me know if you have any questions.
Leave a comment:
-
UserDefinedMethods from NT7 to NT8
Hello
I'm trying to transfer my code from NT7 to NT8.
On my indicator UserDefinedMethods file I used to have the following code:
Code:namespace NinjaTrader.Indicator { public class MyClass { // ..... } }
Code:namespace NinjaTrader.Indicator { partial class Indicator { public void MyFunction() { // ..... } } }
ThanksTags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by chbruno, 04-24-2024, 04:10 PM
|
3 responses
47 views
0 likes
|
Last Post Today, 01:29 PM | ||
Started by samish18, Today, 01:01 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:25 PM | ||
Started by WHICKED, Today, 12:56 PM
|
1 response
8 views
0 likes
|
Last Post Today, 01:17 PM | ||
Started by cre8able, Today, 01:16 PM
|
1 response
3 views
0 likes
|
Last Post Today, 01:30 PM | ||
Started by WHICKED, Today, 12:45 PM
|
1 response
11 views
0 likes
|
Last Post Today, 01:08 PM |
Leave a comment: