Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.

    Chris L.NinjaTrader Customer Service

    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 Haiasi, 04-25-2024, 06:53 PM
      2 responses
      17 views
      0 likes
      Last Post Massinisa  
      Started by Creamers, Today, 05:32 AM
      0 responses
      5 views
      0 likes
      Last Post Creamers  
      Started by Segwin, 05-07-2018, 02:15 PM
      12 responses
      1,786 views
      0 likes
      Last Post Leafcutter  
      Started by poplagelu, Today, 05:00 AM
      0 responses
      3 views
      0 likes
      Last Post poplagelu  
      Started by fx.practic, 10-15-2013, 12:53 AM
      5 responses
      5,408 views
      0 likes
      Last Post Bidder
      by Bidder
       
      Working...
      X