Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
AddOns
Collapse
X
-
AddOns
Is it possible to have a method in the AddOns folder than can be used by both a strategy and an indicator ?Tags: None
-
Hello spottysallrite,
Thank you for your post.
Yes, this may be done by creating a partial class in the NinjaTrader.NinjaScript.AddOns namespace. Then, you could access the method via any script type (such as strategies and indicators) by using the fully qualified namespace such as NinjaTrader.NinjaScript.AddOns.MySharedMethods.Sha redDouble from the MySharedMethodsAddOnExample posted here:
https://forum.ninjatrader.com/forum/...245#post712245
That example is a shared double; you could change it to a custom method instead and use the fully qualified namespace when using the method in other scripts. The following information should be kept in mind as well:
https://forum.ninjatrader.com/forum/...13#post1131313
Please let us know if we may be of further assistance.
-
Ok, I'm not quite following. How would such a method that exists in the AddOns folder in be called from within an indicator ? (Pseudo code is fine.)
Comment
-
A full-fledged example may be found by downloading the "MySharedMethodsAddonExample.zip" at the first link I shared:Originally posted by spottysallrite View PostOk, I'm not quite following. How would such a method that exists in the AddOns folder in be called from within an indicator ? (Pseudo code is fine.)
The .zip contains an AddOn, Indicator, and Strategy. The AddOn has a shared double in the AddOn namespace that may be accessed in both the indicator and strategy as well as a method in the indicator class only and one in the strategy class only. The code comments explicitly explain this as well.
Here is a more simple example of a custom method that could be created in a partial class in an AddOn script:
Then, from an indicator or strategy script, you could call this method as follows:Code://This namespace holds Add ons in this folder and is required. Do not change it. namespace NinjaTrader.NinjaScript.AddOns { public partial class MySharedMethods : NinjaTrader.NinjaScript.AddOnBase { // This double can be accessed from within another addon with MySharedMethods.SharedDouble // or can be accessed from any script using NinjaTrader.NinjaScript.AddOns.MySharedMethods.SharedDouble public static void PrintString(String stringToPrint) { NinjaTrader.Code.Output.Process(stringToPrint, PrintTo.OutputTab1); } } }
Hopefully this helps to clarify. Please let us know if we may be of further assistance.Code:protected override void OnBarUpdate() { NinjaTrader.NinjaScript.AddOns.MySharedMethods.PrintString("this is the string to print"); }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Today, 05:17 AM
|
0 responses
49 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
126 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
67 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
42 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
46 views
0 likes
|
Last Post
|

Comment