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

AutoTrendLine and Indicator?

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

    #16
    The sample earlier on universal moving averages is the closest one we have for custom enums.


    That reference sample includes a link to C# tutorial on this as well.


    Share what you have so far and I can take a look.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Ahh, that helps. I must have missed the earlier post. Before I dive into it, though....since the trendline indicator relies on the swing indicator, I have to enum both, right?

      Comment


        #18
        The enum declaration will provide the items available from the drop down list. You don't need to declare additional items in the list for the swing indicator. The list should just be the names of indicators that you would like to support for your indicator. However, when you actually set plots based on the case (which indicator selected), you'll be using different versions of the swing indicator than the standard to construct your indicator.
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          Okay, the only problem is I have the swing indicator using the RSI so if I want to be able to use it for all the other indicators, I guess I need to make it generic. Not sure how to do that, though, without changing the Swing code...

          Comment


            #20
            Right. The modifcations you used to move swing from price values to RSI will also be needed for other indicators you plan on adding here. You may have to create separate instances of swing for each indicator. SwingRSI, SwingMACD, etc.
            Ryan M.NinjaTrader Customer Service

            Comment


              #21
              Ryan,

              I know I'm asking for trouble here but maybe I'd be better off combining both indicators into one, whereby the dropdown selection declares both the indicator plotted and the formula for the trendline?

              Comment


                #22
                The drop down selection is only visible for the end user, and then what you actually do with this is determined by what you specify in the case block for that enum selection. As far as the drop down selection goes: Yes, it makes sense to design this so only the indicator name is available.

                Play around with the UniversalMovingAverage indicator on a chart to see how this works. User selects EMA, and then the code that gets executed can be seen under the EMA case.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #23
                  Yep, I get it, but I meant something a little different. Right now, I have two indicators. Swing is setup with the RSI and Trendline calls Swing. Instead of doing that, I was thinking of combining both codes into one indicator and then when you select MACD, I can have a case for plotting the MACD and a case for swing formula so everything's in one. Would that work? I'm thinking that would be a lot easier in the long run.

                  Comment


                    #24
                    I see what you're asking now. How you structure the code is really up to you. It may be easier to maintain if they are in separate files, but tradeoff is a little more complicated distribution and more room for dependency errors because of this. A generic swing indicator that you could apply to any series would be good, but we wouldn't be able to tell you exactly how to develop it.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #25
                      Haha oh this definitely has Greek Tragedy written all over it. Still, I'll give it a shot.

                      Thanks for all your help so far, Ryan.

                      Dave

                      Comment


                        #26
                        No problem, Dave. Let us know if we can be of further assistance.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #27
                          Morning Ryan,

                          Making good progress here but ran into an issue. The top indicator represents a normal RSI with my TrendLine indicator on top of it. The bottom one is the new combo and, as you can see, doesn't plot correctly. While the trendline matches up perfectly, the RSI plots are obviously off AND the orange line shouldn't even be plotting as I have it set to smooth 1. I'm a little stuck here. Does anything pop out for you?

                          Thanks,
                          Dave
                          Attached Files

                          Comment


                            #28
                            Update:

                            It looks as if it magically started plotting correctly. Could this be an historical data issue? I see nothing about that in the original RSI code.
                            Attached Files

                            Comment


                              #29
                              Hi Dave,

                              Unfortunately nothing pops out here. Use plenty of Print() statements throughout your code - everything related to what you're trying to plot so that you can see where values aren't matching up to your expectations.
                              Ryan M.NinjaTrader Customer Service

                              Comment


                                #30
                                Ryan,

                                I'm getting nowhere fast. Since it starts plotting correctly eventually, I'm guessing it's a DataSeries issue. Would this line in my Variables be causing the problem?:

                                private IDataSeries Indicator;

                                Maybe I have to resync each indicator case when called?

                                PHP Code:
                                protected override void OnBarUpdate()
                                        {
                                switch(
                                indicatorType)
                                            {
                                                case 
                                IndicatorMethod.RSI:
                                                    
                                InitRSI();
                                                    
                                Indicator RSI(ClosePeriodSmooth);
                                                    break;
                                                    
                                                case 
                                IndicatorMethod.MACD:
                                                    
                                InitMACD();
                                                    
                                Indicator MACD(FastSlowSmooth);
                                                    break;
                                            }

                                ---------------------------------------------------------------------------------------------------------------------

                                private 
                                void InitRSI()
                                            {
                                                
                                Add(new Plot(Color.Green"RSI"));
                                                
                                Add(new Plot(Color.Orange"Avg"));
                                    
                                                
                                Add(new Line(System.Drawing.Color.DarkViolet30"Lower"));
                                                
                                Add(new Line(System.Drawing.Color.YellowGreen70"Upper"));
                                    
                                                
                                avgUp        = new DataSeries(this);
                                                
                                avgDown        = new DataSeries(this);
                                                
                                down        = new DataSeries(this);
                                                
                                up            = new DataSeries(this);
                                                
                                            
                                            } 
                                Last edited by dsraider; 07-21-2010, 09:56 AM.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by algospoke, Yesterday, 06:40 PM
                                2 responses
                                19 views
                                0 likes
                                Last Post algospoke  
                                Started by ghoul, Today, 06:02 PM
                                3 responses
                                14 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by jeronymite, 04-12-2024, 04:26 PM
                                3 responses
                                45 views
                                0 likes
                                Last Post jeronymite  
                                Started by Barry Milan, Yesterday, 10:35 PM
                                7 responses
                                20 views
                                0 likes
                                Last Post NinjaTrader_Manfred  
                                Started by AttiM, 02-14-2024, 05:20 PM
                                10 responses
                                181 views
                                0 likes
                                Last Post jeronymite  
                                Working...
                                X