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 kinfxhk, 07-14-2026, 09:39 AM
      0 responses
      127 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 10:18 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 09:50 AM
      0 responses
      85 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-13-2026, 07:21 AM
      0 responses
      105 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 07-11-2026, 02:11 AM
      0 responses
      86 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X