Announcement

Collapse
No announcement yet.

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 WeyldFalcon, Today, 02:07 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_ThomasC  
      Started by hfwiley, Today, 03:02 PM
      2 responses
      15 views
      0 likes
      Last Post hfwiley
      by hfwiley
       
      Started by pdennis, Today, 02:34 PM
      3 responses
      15 views
      0 likes
      Last Post NinjaTrader_ChrisL  
      Started by tonynt, Today, 01:47 PM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Kate  
      Started by WesFoster, Today, 12:39 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Dennis  
      Working...
      X