Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Copy indicator values to a custom series

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

    Copy indicator values to a custom series

    I'd like to be able to copy a selected indicator, say SMA, EMA, WMA or whatever... into a custom series... at least, I think that's what I want to do ;-)

    I really want to be able to select an MA in my indicator/strategy.... and then use that data in various places.

    I have looked at the SampleUniversal MA code... but it seems this is a) terribly inefficient (copies a value on each OnBarUpdate) , and b) does not give me an object I can work with... it just plots the selected MA. Not what I need.

    I tried something like this: (sort of psuedo code...not actual code... just the idea.
    private Series<double> myseries;
    private SMA mySMA;
    private EMA myEMA;
    ...
    mySMA = SMA(period);
    myEMA = EMA(period);

    if (I_selected_SMA) myseries = mySMA;
    else if (I_selected_EMA) myseries = myEMA;

    but the compiler does not allow assignment of the SMA/EMA object to my target series.

    Is this possible? Seems fairly simple, and it would make my life so much easier, rather than subsequent code needing to always test what SMA I chose and then call other methods (eg IsRising) using different arguments...

    Thanks,
    T.

    #2
    Hi tgn55, thanks for your note.

    The SMA or EMA object is already a Series<double> (in a roundabout way), so copying it into another series would not be good for performance. You can store further info within a custom series to access that easily. Here is a reference sample:



    Please let me know if this does not resolve your inquiry.

    Comment


      #3
      Thanks, I am aware of that post...

      It also populates the custom series one bar at a time... in OBU...
      I was hoping there was a way to do it more efficiently than that... maybe I just need to bite the bullet and do it that way...

      Thanks Chris.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      637 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      366 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      107 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      569 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      571 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X