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

Indicator vs Strategy

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

    Indicator vs Strategy

    I do not know if this has been asked or is in the help files somewhere .... if so, I have not come across it and often wondered "Where does an Indicator end and a Strategy begin?"

    For instance, I have developed several strategies for program trading and several indicators for marking up charts.

    Now I want an indicator with multiple instruments and multiple time frames. I realize that a strategy is required to add additional Bars objects...still what is the defining point where you need to switch to a strategy?

    Thanks.
    Last edited by ATI user; 09-04-2007, 07:38 PM.

    #2
    At the moment indicators cannot do multiple instruments/time frames, but you might find Gumphrie's work on this issue to your likings (http://www.ninjatrader-support.com/vb/showthread.php?t=3185).

    I would consider the defining point of when to switch to a strategy to be when you want to automatically place trades. If you have no intentions to automate order placing/handling you should be able to do everything you need via indicators.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Josh.

      I suspected that the auto-trading feature might be the cutoff and was not sure. I started with strategies for that very purpose and only lately have gotten into indicators.

      Thanks for the link to Gumphrie's work. Good job there. It would appear however that if I also need a second instrument working on a separate timeframe that I will need to move up to an strategy. Will give it a shot that way.

      Thanks again for the prompt response.

      Scott
      Last edited by ATI user; 09-04-2007, 08:41 PM.

      Comment


        #4
        Josh

        While I am thinking about it, is it possible to plot in two panels from the same strategy? For instance plot on the price panel and plot volume bars/histos in panel 2 also?

        Thanks

        Scott

        Comment


          #5
          Yup. You can set these options in the Initialize() section of your code. Because the VOL indicator is defaulted to not overlay your price panel all you need to do is add this:
          Code:
          Add(VOL());
          If, for instance, you wanted to add a VOLMA onto the same panel as VOL() you would add this to the Initialize() section as well:
          Code:
          VOLMA(20).Panel = 2;
          Add(VOLMA(20));
          Basically you can add any indicator you want in a strategy with the Add() function. If you want them on a different panel simply use the .Panel property.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Now that is very cool. Thanks Josh.

            That solves a nagging problem I was having.

            Scott

            Comment


              #7
              Here are some additional examples of things you can do in the Initialize() section to modify your indicators in strategies:
              Code:
              EMA(13).Plots[0].Pen.Color = Color.Blue;
              EMA(13).Plots[0].Pen.Width = 1;
              RegressionChannel(60, 2).Plots[0].Pen.DashStyle = DashStyle.Dash;
              RSI(2, 1).Lines[0].Value = 5;
              RegressionChannel(60, 2).PaintPriceMarkers = false;
              With those you can modify any indicator's plots/line's style to your likings. Don't forget you need to still do the Add() along with the above code to add indicators.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Excellent. Thanks Josh. Will need those also.

                Comment


                  #9
                  Josh

                  Possilby a little more difficult than I thought as I would like to include the code for the colored volume plot that you wrote for me within a strategy only have it plot in panel 2.

                  Is this possible or do I need to use a separate indicator for the colored volume?

                  Wait....I assume I can just call up your volume indicator within the strategy, per your code below, right. Will try it.

                  Thanks

                  Scott
                  Last edited by ATI user; 09-04-2007, 09:08 PM.

                  Comment


                    #10
                    No, to do it that way would be a complete mess. It is much easier to just have a separate indicator for it. If you want to use the colored volume just add VOLColor() instead of VOL().
                    Code:
                    Add(VOLColor());
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Yes. Our posts crossed. I amended my last post and tried it while you were typing your post.

                      And of course, it works perfectly.

                      This is new to me in ninjascript (did something similar in javascript/efs) and is very cool.

                      Thanks.

                      Comment


                        #12
                        Josh

                        Just to clarify:
                        - you can not add an Indicator to an Indicator, and
                        - you can not use the same parameter names in both the strategy and indicator if passing parameters from a strategy to an indicator; this would not compile for me

                        Thanks

                        Scott

                        Comment


                          #13
                          That is correct. The examples above are strictly for strategies only. If you want to do indicator on indicator you can check out this tutorial: http://www.ninjatrader-support.com/H...tml?Overview22
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Josh

                            Thanks. You have been a big help as usual.

                            I am now running the indicator from the strategy and passing parameter values from the strategy using:

                            Add(VolColorTrend(TrendFilter,BarColorDn,BarColorU p,MomentumAlert,VolumeColorDn,VolumeColorUp));

                            In the indicator this works fine for the following code in the OnBarUpdate section:

                            BackColor = Color.FromArgb(0,VolUpColor,0);

                            But not for the following code in the Initialize section:
                            Add(new Plot(new Pen(Color.FromArgb(0,BarColorUpv,0),3), PlotStyle.Bar, "UpVol"));

                            I assume this is because you can not change parameters in the Initialize section of code in the indicator by passing the value from the strategy?

                            So I added:
                            Plots[0].Pen = new Pen(Color.FromArgb(0,BarColorUpv,0),3);
                            to the indicator code in the OnBarUpdate section...which works fine.

                            I must confess however I do not know why...I just deduced that might be the problem...i.e. trial and error. Can you please tell me if this is the correct way or if there is a better way?

                            Thanks

                            Scott
                            Last edited by ATI user; 09-05-2007, 07:55 PM.

                            Comment


                              #15
                              Your original attempt should work in the Initialize() section. What it will do is just take the default value of your BarColorUpv variable and use that. You are right in that it will not update as you change the BarColorUpv variable because it is only called once. You can put your Plots[0].Pen snippet in the Initialize() section as well if you want. There isn't really a point in putting it in OnBarUpdate() because you don't need to keep telling the plot what color pen to use. If your goal is multi-colored plots you are going to need to use two plots with different colors and just set your indicator to whichever color you want at a particular point. See http://www.ninjatrader-support.com/H...tml?Overview25 for how to do it.
                              Last edited by NinjaTrader_JoshP; 09-05-2007, 08:18 PM.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by burtoninlondon, Today, 12:38 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post burtoninlondon  
                              Started by AaronKoRn, Yesterday, 09:49 PM
                              0 responses
                              14 views
                              0 likes
                              Last Post AaronKoRn  
                              Started by carnitron, Yesterday, 08:42 PM
                              0 responses
                              11 views
                              0 likes
                              Last Post carnitron  
                              Started by strategist007, Yesterday, 07:51 PM
                              0 responses
                              13 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,983 views
                              3 likes
                              Last Post jhudas88  
                              Working...
                              X