• 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

    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

    #2
    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.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      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.

      Comment


        #4
        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.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          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

          Comment


            #6
            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.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              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.

              Comment


                #8
                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
                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by shodson, 02-11-2020, 07:26 PM
                3 responses
                19 views
                0 likes
                Last Post shodson
                by shodson
                 
                Started by ksarin, Today, 04:31 PM
                0 responses
                4 views
                0 likes
                Last Post ksarin
                by ksarin
                 
                Started by ralett, Today, 03:39 PM
                0 responses
                8 views
                0 likes
                Last Post ralett
                by ralett
                 
                Started by koganam, Today, 03:17 PM
                1 response
                11 views
                0 likes
                Last Post NinjaTrader_Kate  
                Started by DTSSTS, Today, 02:46 PM
                4 responses
                15 views
                0 likes
                Last Post DTSSTS
                by DTSSTS
                 
                Working...
                X