• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

UserDefinedMethods from NT7 to NT8

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • NinjaTrader_ChelseaB
    replied
    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

    Leave a comment:


  • stevenev1
    replied
    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#post1051574
    Last edited by stevenev1; 03-16-2019, 08:46 AM.

    Leave a comment:


  • NinjaTrader_JoshG
    replied
    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:


  • kiss987
    replied
    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:


  • NinjaTrader_JoshG
    replied
    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.

    https://ninjatrader.com/support/foru...72&postcount=6

    Help Guide- BarsRequest

    Please let me know if you have any questions.

    Leave a comment:


  • kiss987
    replied
    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:


  • NinjaTrader_JoshG
    replied
    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.
    https://ninjatrader.com/support/foru...104#post457104

    Please let me know if you have any questions.

    Leave a comment:


  • kiss987
    started a topic UserDefinedMethods from NT7 to NT8

    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
        {
              // .....
        }
    }
    and

    Code:
    namespace NinjaTrader.Indicator
    {
        partial class Indicator
        {
            public void MyFunction()
            {
                  // .....
            }
        }
    }
    Where those 2 code parts should be transferred to on NT8?


    Thanks

Latest Posts

Collapse

Topics Statistics Last Post
Started by vivekniwas, Today, 02:15 PM
1 response
14 views
0 likes
Last Post NinjaTrader_ChrisL  
Started by fibbee, Today, 02:06 PM
1 response
11 views
0 likes
Last Post NinjaTrader_Tyler  
Started by Spaggetti Ninjja, Today, 01:23 PM
1 response
9 views
0 likes
Last Post NinjaTrader_PatrickG  
Started by rexsole, Today, 12:34 PM
1 response
7 views
0 likes
Last Post NinjaTrader_PatrickG  
Started by Stormy7, Today, 12:20 PM
3 responses
13 views
0 likes
Last Post NinjaTrader_Heath  
Working...
X