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!
See more
See less

Partner 728x90

Collapse

generic classes and functions

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

    generic classes and functions

    Hello,

    I would like to create a set of generic classes and functions useful for building strategies and indicators.
    For example I have not found functions for examine bar and get information:
    1. is outside day
    2. is inside day
    3. true range for that bar
    4. get the highest bar for X days back...
    .....
    For some of functions, the bar itself is enough, for others more bars are needed (points 3,4).
    My question is:
    How can I create a class holding such a group of functions? The class should be generic, and able to be used in other indicators, for example through namespace clause "using MyNamespace" so I would like it to be hold in separate namespace. What in situation I do not want to create class but only global functions? Is this possible?
    Of course there should be a possibility of receiving price bars (open, high,low,close, volume...) in such a class or function... How?

    Thank you for answer

    Majkie

    #2
    See UserDefinedMethods.

    - http://www.ninjatrader-support.com/H...verview45.html

    You could also implement each function as an indicator, this is what I recommend.
    RayNinjaTrader Customer Service

    Comment


      #3
      Originally posted by majkie View Post
      I would like to create a set of generic classes and functions useful for building strategies and indicators.
      For example I have not found functions for examine bar and get information:
      1. is outside day
      2. is inside day
      3. true range for that bar
      4. get the highest bar for X days back...
      Some of this already exists. Instead of making new classes, I find it more efficient to implement each of these things a simple line of code.

      outside_day = (High[0]>High[1] && Low[0]<Low[1]);
      inside_day = (High[0]<High[1] && Low[0]>Low[1]);
      true_range = Math.Max(High[0],Close[1])-Math.Min(Low[0],Close[1]);
      highest_of_N = MAX(High,N); // method already exists as an indicator

      I've become so accustomed to simply writing those functions out like that, that I hardly think about it anymore.
      -Alex

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by FrazMann, Today, 11:21 AM
      0 responses
      3 views
      0 likes
      Last Post FrazMann  
      Started by geddyisodin, Yesterday, 05:20 AM
      8 responses
      52 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      10 responses
      36 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      24 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      19 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X