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 yeikson89, Today, 02:53 PM
      2 responses
      11 views
      0 likes
      Last Post yeikson89  
      Started by sdauteuil, Today, 01:06 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by trumpy, 03-09-2017, 02:11 PM
      30 responses
      3,226 views
      0 likes
      Last Post foxthorn  
      Started by shani77, Today, 09:58 AM
      1 response
      24 views
      0 likes
      Last Post NinjaTrader_Eleanore  
      Started by cjanau, Yesterday, 11:07 AM
      1 response
      31 views
      0 likes
      Last Post NinjaTrader_ThomasC  
      Working...
      X