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

    AutoTrendLine and Indicator?

    Wondering is it's possible to use the AutoTrendLine on, say, the RSI, instead of price. Is there a setting about which I don't know or can this be done by swapping out price for RSI highs and lows in the code?

    #2
    Hello dsraider,

    Yes, this should be possible, but you would essentially have to rewrite a swing indicator for RSI values rather market highs and lows.

    You set the property DrawOnPricePanel = false, and then could set the Y values they're drawn on according to RSI values to have these drawn in an indicator panel.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply, Ryan. Is there anything I would need to change other than Highs and Lows? Meaning, would going from (High[0]) to (RSI(High[0])) and the same for "Low" take care of the Swing Indicator end?

      Thanks,
      Dave

      Comment


        #4
        Unfortunately, I'm not sure the exact changes needed to move the swing indicator from price as its basis to RSI. The autotrendline indicator works closely with swing, so you would have to look at both and determine the changes needed.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Okay, I'm not sure if this is exactly what you meant but I THINK I made the Swing Indicator correctly (RaiderSwing in Panel 2).

          However, as you can see, when I changed "Swing" to "RaiderSwing" in the Trendline indicator code, I did something wrong. It looks as if it's using price instead of RSI readings. Do I need to change something other than the Swing indicator to which the Trendline refers?
          Attached Files

          Comment


            #6
            Great progress on the swing indicator modified for RSI. I'd look at the places in the AutoTrendLine code where it draws at highs and lows and see if you can adjust to draw instead at RSI values.

            DrawRay("UpTrendLine", upTrendStartBarsAgo, startBarPrice, upTrendEndBarsAgo, endBarPrice, UpTrendColor, DashStyle.Solid, LineWidth);

            DrawArrowDown("UpTrendBreak", barsAgo, High[barsAgo] + TickSize, Color.Blue);

            DrawRay("DownTrendLine", downTrendStartBarsAgo, startBarPrice, downTrendEndBarsAgo, endBarPrice, DownTrendColor, DashStyle.Solid, LineWidth);

            DrawArrowUp("DownTrendBreak", barsAgo, Low[barsAgo] - TickSize, Color.Blue);
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan,

              First, apologies for my last message. I posted it before I saw yours. I did notice one thing, though. My swing dots don't really line up (as indicators don't show highs and lows, only close). Maybe I'd be better using Close instead of High and Low or would that mess everything up?

              I did get the trendline to draw on the RSI but I obviously need to keep working on it...

              Thanks.
              Attached Files

              Comment


                #8
                It LOOKS like that did it (changing High and Low to Close).

                I'll watch for awhile and make sure it works. If so, I'll post. Well, maybe I'll try and give the option for other indicators first, if I can figure out how.

                Thanks for the pointers, Ryan.

                Dave
                Attached Files

                Comment


                  #9
                  Thanks for the update and glad to hear you've been able to adapt auto trend line for this. It will be a nice addition to the filesharing section if everything ends up checking out on your side.
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Ryan,

                    In trying to enumerate the indicators, I'm getting the following error message:

                    The namespace '<global namespace>' already contains a definition for 'IndicatorMethod'

                    Here's what I have so far:

                    PHP Code:
                    public enum IndicatorMethod
                    {
                        
                    RSI,
                        
                    MACD
                    }

                    // This namespace holds all indicators and is required. Do not change it.
                    namespace NinjaTrader.Indicator
                    {
                        
                    /// <summary>
                        /// Automatically draws a line representing the current trend and generates an alert if the trend line is broken.
                        /// </summary>
                        
                    [Description("")]
                        [
                    Gui.Design.DisplayName("RaiderIndicatorTrendLine")]
                        public class 
                    RaiderIndicatorTrendLine Indicator
                        

                    Do you see a violation on my part or would you need more information?

                    Comment


                      #11
                      dsraider,

                      I'm pretty sure that every enum needs have an unique name associated with it.

                      RJay


                      Originally posted by dsraider View Post
                      Hi Ryan,

                      In trying to enumerate the indicators, I'm getting the following error message:

                      The namespace '<global namespace>' already contains a definition for 'IndicatorMethod'

                      Here's what I have so far:

                      PHP Code:
                      public enum IndicatorMethod
                      {
                          
                      RSI,
                          
                      MACD
                      }

                      // This namespace holds all indicators and is required. Do not change it.
                      namespace NinjaTrader.Indicator
                      {
                          
                      /// <summary>
                          /// Automatically draws a line representing the current trend and generates an alert if the trend line is broken.
                          /// </summary>
                          
                      [Description("")]
                          [
                      Gui.Design.DisplayName("RaiderIndicatorTrendLine")]
                          public class 
                      RaiderIndicatorTrendLine Indicator
                          

                      Do you see a violation on my part or would you need more information?
                      RJay
                      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                      Comment


                        #12
                        Hi Dsraider,

                        This reference sample offers an example implementation of this. As RJay says the enums must be unique, meaning only declared one time throughout the program. The message you're getting suggests that you're using that name elsewhere.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks, guys, though I'm starting to think there's a better way, using "If" statements. In the meantime, while I'm taking baby steps, is there a way to call an indicator to plot?

                          Right now I'm adding the RSI and then adding my TrendLine indicator on top of it in the same panel. In the end, I'd like to have it add both once the indicator is selected from a drop down list.

                          Any chance there's an example of that?

                          Thanks,
                          Dave

                          Comment


                            #14
                            Indicator plots are Set and you can use any of your existing indicators or other data series to set the plots of another.

                            You can conditionally set your plots based on a case with enums or with an if statement. Enums will work the best because you can populate a list of available items that will appear in a drop down list and then base your plot on this selection. You can set multiple plots within the switch statement of your enums.

                            PseudoCode below:

                            switch (indicatorType)
                            {
                            // If the matype is defined as an EMA then...
                            case indicatorType.RSI:
                            {
                            Plot0.Set(RSI)[0];
                            Plot1.Set(RSITrendLine)[0];
                            break;
                            }

                            case indicatorType.MACD:
                            {
                            Plot0.Set(MACD)[0];
                            Plot1.Set(MACDTrendLine)[0];
                            break;
                            }

                            }
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks, Ryan, but I'm still kind of a novice at this and usually need an example in front of me as I'm guessing I'm missing a bunch of basic steps here.

                              If one comes to mind, please let me know.

                              Thanks.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by usazencort, Today, 01:16 AM
                              0 responses
                              1 view
                              0 likes
                              Last Post usazencort  
                              Started by kaywai, 09-01-2023, 08:44 PM
                              5 responses
                              603 views
                              0 likes
                              Last Post NinjaTrader_Jason  
                              Started by xiinteractive, 04-09-2024, 08:08 AM
                              6 responses
                              22 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Pattontje, Yesterday, 02:10 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post Pattontje  
                              Started by flybuzz, 04-21-2024, 04:07 PM
                              17 responses
                              230 views
                              0 likes
                              Last Post TradingLoss  
                              Working...
                              X