Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Custom indicator sample

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

    Custom indicator sample

    Hello,

    I am reading about custom indicators and there are important differecnces with NT7. Can you provide custom indicators examples for an easier migration?

    #2
    Hello guillembm,

    Thanks for your post.

    I would suggest looking at any NT7 system indicator to the NT8 system indicator for example of differences in coding. A simple example would be any of the moving averages such as SMA or EMA.

    We have also converted many of the NT7 indicators and strategies on the NT7 file sharing forum to NT8 and these are identified on the NT8 file sharing forum by the NT8 - in the title of the file post.

    There are a few key items to look for when converting your scripts from NinjaTrader 7 format to NinjaTrader 8, and we keep a Code Breaking Changes table updated in the NinjaTrader 8 Help Guide to assist in identifying changes or new implementations of familiar methods and properties from NinjaTrader 7: http://ninjatrader.com/support/helpG...ng_changes.htm

    Some notable items to consider when converting your code will be the following:

    Initialization has changed significantly. Initialize() has been replaced with OnStateChange(), which can be used to filter out different stages of the entire life cycle of a script (SetDefaults, Configure, Historical, Realtime, Terminated, etc.) OnStateChange() is fully covered in the Help Guide.

    The names of many methods and properties have changed slightly, so you will need to refactor these in your code. The Code Breaking Changes table can make this task much easier, and there is also an alphabetical reference in the Help Guide that can help to find new method/property names: http://ninjatrader.com/support/helpG..._reference.htm

    In numerous instances, you now have direct access to objects, where in NinjaTrader 7 you had to work with interfaces. For example, rather than the IOrder interface, you now have direct access to an Order object and its related fields. This will require a change in the way items like this are handled in your code.

    As always, we are more than happy to help out with tips and advice in this area, although we do not offer full script conversion services.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      I am having trouble with one indicator. I am having this two errors in the same line code:

      The best overloaded method match for 'NinjaTrader.NinjaScript.Indicators.Indicator.SMA( NinjaTrader.NinjaScript.ISeries<double>, int)' has some invalid arguments

      Argument 1: cannot convert from 'double' to 'NinjaTrader.NinjaScript.ISeries<double>'

      To get this I set this series:

      private Series<double> MySeries;

      and in OnBarUpdate I calculate the formula that makes the error:

      MySeries[0] = SMA(Volume[0],Period)[0];

      Period is an integer variable.

      What am I doing wrong?

      Comment


        #4
        Hello guillembm,

        Thanks for your reply.

        In the case of MySeries[0] = SMA(Volume[0],Period)[0]; The SMA is expecting a series and you are using a double by adding the [0] index to Volume. Please try MySeries[0] = SMA(Volume,Period)[0];

        Also, if you haven't already you would need to create the series object in State.DataLoaded as otherwise you would get an object reference error. Please see the 1st example here: https://ninjatrader.com/support/help...s/?seriest.htm
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Yes, in DataLoaded I set

          MySeries = new Series<double>(this, MaximumBarsLookBack.Infinite);

          I set

          MySeries[0] =Volume[0];
          Value[0] = SMA(MySeries,Period)[0];

          This way I don't get errors. Is this a correct syntax for the indicator?

          Comment


            #6
            Hello guillembm,

            Thanks for your reply.

            Yes, that would work.
            Paul H.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by TraderBCL, Today, 04:38 AM
            2 responses
            17 views
            0 likes
            Last Post TraderBCL  
            Started by martin70, 03-24-2023, 04:58 AM
            14 responses
            106 views
            0 likes
            Last Post martin70  
            Started by Radano, 06-10-2021, 01:40 AM
            19 responses
            609 views
            0 likes
            Last Post Radano
            by Radano
             
            Started by KenneGaray, Today, 03:48 AM
            0 responses
            5 views
            0 likes
            Last Post KenneGaray  
            Started by thanajo, 05-04-2021, 02:11 AM
            4 responses
            471 views
            0 likes
            Last Post tradingnasdaqprueba  
            Working...
            X