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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        649 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        576 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X