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

adding moving averages to indicators

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

    adding moving averages to indicators

    is there a simple way to add an ema or sma to an indicator. initially when i plotted a rsi to a price structure, the rsi and the avg plotted with it in the data series would both reflect on the chart, for some reason, the avg has disappeared leaving me with just the rsi. I would like it back, however would actually like to learn how to plot my own. I thought it to be easy as adding an indicator to my data series and selecting the same panel as my rsi, but the ema/sma appears flat, merely a horizontal line. I dont even know what data it would address if it were to succeed. Would it reflect the price action or the indicator in the panel it is assigned. Anyways, some guidance would be awesome.

    #2
    You can view the Ninjascript for all the supplied indicators using NT text editor ( Tools - Edit Ninjascript - Indicator).

    If you look at the Ninjascript for RSI() it will show how a Plot Class is initialized using the Add() method. All added plot values are then set using the Values[int index], provided the get/set properties are defined in the Properties section of the code.

    Code:
    Add(new Plot(Color.Green, "RSI"));
    Add(new Plot(Color.Orange, "Avg"));
    
    
    double rsi	  = avgDown[0] == 0 ? 100 : 100 - 100 / (1 + avgUp[0] / avgDown[0]);
    double rsiAvg = (2.0 / (1 + Smooth)) * rsi + (1 - (2.0 / (1 + Smooth))) * Avg[1];
    
    Avg.Set(rsiAvg);
    Value.Set(rsi);
    
    #region Properties
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Avg
     {
    	get { return Values[1]; }
    }
    [Browsable(false)]
    [XmlIgnore()]
    public DataSeries Default
    {
    	get { return Values[0]; }
    }

    Comment


      #3
      Hello,
      Borland's instructions on how to look at the code for system indicators code is correct and great advice. We recommend to reivew their code and our reference samples on the forum to help with learning and as great tools.
      If you are wanting to add an indicator to a strategy you can do so using the Add()-Indicator method which you can find more information on in our help guide at the following link: http://ninjatrader.com/support/helpGuides/nt7/add2.htm

      From your inquiry though it sounds like you may have some idea how to do this though and the code is not giving you the expected results. We would be more than happy to take a look at the code if you want to provide a snippet of how you are adding the indicator.
      Cody B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by usazencortex, Today, 12:43 AM
      0 responses
      1 view
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,262 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      10 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by WeyldFalcon, 12-10-2020, 06:48 PM
      14 responses
      1,429 views
      0 likes
      Last Post Handclap0241  
      Started by DJ888, 04-16-2024, 06:09 PM
      2 responses
      9 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Working...
      X