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 The_Sec, Yesterday, 03:53 PM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by mmenigma, Yesterday, 03:25 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by kujista, Today, 05:44 AM
      0 responses
      7 views
      0 likes
      Last Post kujista
      by kujista
       
      Started by ZenCortexCLICK, Today, 04:58 AM
      0 responses
      9 views
      0 likes
      Last Post ZenCortexCLICK  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      172 responses
      2,281 views
      0 likes
      Last Post sidlercom80  
      Working...
      X