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

    #31
    I'm not sure what effects you'll see adding plots and instantiating DataSeries outside of the built in Initialize method.


    Maybe try the suggestions below:
    • Add all plots in the initialize method. Understand that they are just placeholders for the values you are to set in the case statements.
    • Instantiate all DataSeris as well in Initialize method.
    • You may call your other methods, but reserve the types of statements here to those that you would typically see in OnBarUpdate()
    • Don't use the word Indicator. It might not be conflicting here, but since it's the name of the class, it's safer to use another word.
    Ryan M.NinjaTrader Customer Service

    Comment


      #32
      Got nada.

      I know you can't debug but is it alright to post what I have so far to see if I followed your instructions?

      Comment


        #33
        Yes, feel free to share what you have so far and I'll take a look. As you're dealing with many new elements, it may be best to simplify, get one thing working first, and then start adding features.
        Ryan M.NinjaTrader Customer Service

        Comment


          #34
          Thanks for taking a look. I'll refrain from breaking things until I hear back.

          Dave

          P.S. After making those recent changes, the trendline no longer matches up with the original.
          Attached Files

          Comment


            #35
            It looks like there is an attempt to dynamically change items that need to be declared only once in the Initialize method. It may not be contributing to the issue, but try moving all your plot Add statements to just the initialize method, not enclosed in your case. Do the same for your data series instantiation as well.

            You only need to add two plots, and these values are set conditionally (based on the item selected in the enum drop-down list).

            There shouldn't be a need to Add plots later in the code. It may help to name them something generic, like:

            Add(new Plot(Color.Green, "indicator1"));
            Add(new Plot(Color.Orange, "IndicatorAvg"));
            Ryan M.NinjaTrader Customer Service

            Comment


              #36
              Okay. I was hoping to have the drop down change the Parameters, Lines and Plots choices, once selected. Though I only have two indicator choices in there right now for testing, I plan on adding all of the usual suspects and didn't want the box packed and confusing. I guess this isn't possible?

              I'd really rather every choice for every indicator didn't show at once but if I have no choice, well, then I guess I have no choice...

              Comment


                #37
                Also, I believe I found the problem with plotting. In order to use the selected indicator as a basis for the Swing data, I have this:

                PHP Code:
                lastHighCache.Add(Ind[0]);
                                if (
                lastHighCache.Count > (strength) + 1)
                                    
                lastHighCache.RemoveAt(0); 
                where Ind = the selected indicator:

                PHP Code:
                switch(tline)
                            {
                                case 
                IndLine.RSI:
                                {
                                    
                Ind RSI(ClosePeriodSmooth);
                                    if (
                CurrentBar == 0)
                                    {
                                        
                down.Set(0);
                                        
                up.Set(0);
                                        return;
                                    } 
                The culprit, I THINK, seems to be here:

                PHP Code:
                Variables
                private IDataSeries Ind
                as up until that point, everything plots as it should. Is there a way of declaring Ind without using IDataSeries so my Swing code knows to grab data from whatever indicator is selected from the drop down?

                Comment


                  #38
                  I am not sure what you mean. Couldn't you create an enum and then based on whatever enum value is selected, create Ind accordingly?
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #39
                    Hey Josh,

                    I'd like to but I can't figure out how. Nothing but IDataSeries seems to work in Variables. How else can I declare it? Or are you suggesting I do something else altogether?

                    Comment


                      #40
                      dsraider,

                      I was suggesting just using Ind as a double. Then depending on which enum is selected assign Ind = RSI(...)[0] or Ind = MACD(...)[0] since your code does not look like it actually wants a series. This has the added benefit of taking up less memory as well.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #41
                        Josh,

                        I don't follow. Part of the result of my enum is to have a dataseries for the Swing Indicator Code so I can then plot automatic trendlines. Using private double Ind = 0; in variables and then trying Ind = RSI(Close, Period, Smooth) just brings up error messages. Am I just formatting it wrong?

                        Comment


                          #42
                          Unfortunately this is not supported then. You will just need to program it in a way that uses the correct indicator.

                          Also, you cannot assign RS() to a double without [] indexing.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #43
                            Really? There's no way I can substitute an indicator for a word? The code I've posted is obviously not complete but in English, I just want it to say....

                            If RSI is selected, use RSI(Close, Period, Smooth) in the formula for swing highs/lows.
                            If MACD is selected, use MACD(Close, Fast, Slow, Smooth) in the formula for swing highs/lows.

                            It doesn't seem that crazy to me. In fact, I've been able to have the trendlines plot as they should. I just can't get the indicator to plot the RSI or MACD without getting corrupt historical data and I figured the issue was with using IDataSeries.

                            Post 28 is a perfect example. It's okay once I let in run for awhile but I'm hoping to make it plot historical data correctly as well.
                            Last edited by dsraider; 07-22-2010, 03:05 PM.

                            Comment


                              #44
                              Just code your switches to grab what you want properly. If you select RSI, then all of your code should just use the RSI indicator. Trying to dynamically set an indicator object is not supported. Furthermore you cannot dynamically create the objects to begin with.

                              Unfortunately we cannot be of further assistance on this.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              18 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Javierw.ok  
                              Started by timmbbo, Today, 08:59 AM
                              2 responses
                              10 views
                              0 likes
                              Last Post bltdavid  
                              Working...
                              X