Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to have multiple instances of an indicator?

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

    How to have multiple instances of an indicator?

    It seems that the indicator methods in a strategy instantiate a "singleton" or static reference to the indicator object. That means only one instance of it exists.

    However, I have an indicator called Current10MinsOHL() to calculated the same for only 10 minutes. But I now need it to be variable on 20 minutes and 5 minutes as well as 10 minutes.

    So rather than hard code the time span, it needs a property, Minutes, to set how many minutes to track the current OHL.

    Currently in the initialize method, I call the Add() method like the examples:

    Add(Current10MinsOHL());

    However, if I make this indicator property driven, can the Add function work this way instead?

    CurrentOHL slowOHL = new CurrentOHL();
    slowOHL.Minutes = slowMinutes; // from a property
    Add( slowOHL );

    CurrentOHL medOHL = new CurrentOHL(10);
    medOHL.Minutes = medMinutes; // from a property
    Add( medOHL );

    CurrentOHL fastOHL = new CurrentOHL(10);
    fastOHL.Minutes = fastMinutes; // from a property
    Add( fastOHL );

    Or will it get confused expecting a single instance of CurrentOHL();

    Sincerely,
    Wayne

    #2
    >> Add(Current10MinsOHL());
    Anything else than that is not supported. Meaning you should not try to create multiple instances.

    Note: Basically you only can multiple instances if the params of an indicator differ. Does not work here, since this indicator has no params.

    Comment


      #3
      Oh, thanks. This helps. I saw some of the auto-generated code doing something related to multiple params. That helps me understand. I'll experiment.

      Thanks,
      Wayne

      Comment


        #4
        Muliple instances

        Only way I hav found to do this is to use identical inicators with differing names

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X