• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

plot in strategy

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

    plot in strategy

    If I want my strategy to plot something other than an indicator, how can I do that?

    Using the Strategy Wizard, if I add a plot called "StrategyPlot", I get
    AddPlot(Brushes.Orange, "StrategyPlot") put into the SetDefaults block of code.

    So how do I assign values to this plot? In indicators it was easy since anything in Values[0] would be automatically get plotted to the first plot. I want something like that for strategies.

    #2
    Hello YD777, and thank you for your question. Plots can be assigned to in exactly the same way. The attached indicator, for instance, assigns the closing price to the Values[0][0] member on each bar. Please let us know if there are any other ways we can help.
    Attached Files
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      There is another thread in the NT7 area regarding the same question and discussing in fact NT8's solution.

      I just wonder if there is a way to combine all the code (strategy and indy) in one file. I tried to do that but with no success.

      Edit:
      Sorry, the thread I referenced is discussing plotting in a separate panel. I was confused with 'StrategyPlot' mentioned in the first post. Anyway, I'd like to know the answer to my question. Thanks in advance.
      Last edited by quicktrick; 04-05-2017, 09:02 PM.

      Comment


        #4
        Thank you for your question quicktrick. While it is true NT7 has fewer options as far as plotting from a Strategy, there are two approaches that may work for you.

        First, you can use methods such as DrawLine from your strategy.

        Second, you can make a very basic indicator, such as the one attached. You can then set up a strategy such as the attached strategy. This will let you handle all your logic from your strategy.
        Attached Files
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Thank you, Jessica! And now, please, tell me if there is a way to combine your two code files in just one strategy code file. To add there namespace NinjaTrader.Indicator and the indicator's code and so on?

          Comment


            #6
            Provided you are comfortable doing without any postprocessor extras for indicators, you can create instances of an indicator with the New keyword, and can then use code such as that attached. Code samples we provide are for educational purposes, and are not intended for live trading, and are not guaranteed to accomplish any user goal or to be maintained.
            Attached Files
            Jessica P.NinjaTrader Customer Service

            Comment


              #7
              Hi Jessica! Thanks a lot for your example! But it's for NT7. Could you please do the same for NT8? I tried to do it myself, but I had runtime errors. Thank you in advance!

              Comment


                #8
                For NT8, you can simply call AddPlot and assign directly to your Values array, as YD777 and I were discussing in the first 2 posts. Please let us know if any specific questions come up when acting on this advice. There is a code example in post #2 in this thread which accomplishes this goal. For convenience,

                http://ninjatrader.com/support/forum...5&d=1491422719
                Jessica P.NinjaTrader Customer Service

                Comment


                  #9
                  Thank you, Jessica! But I'd like to have plot on a separate panel and to have all the code (strategy and indicator) in one file. Is it possible? Now I have working code for a strategy and a separate panel plot in two files, but I'd like to have them in one file. Could you help in that, please?

                  Comment


                    #10
                    While I am happy to answer questions about the operation of NinjaTrader, fully developing a working user solution is beyond the scope of the support we may provide. The information you are requesting can be found elsewhere in this thread, with the exception of one new item you brought up.

                    One Indicator or Strategy plotting to multiple panels is not possible in NT7 or NT8. Please review this archived beta thread for more information.

                    http://ninjatrader.com/support/forum...ad.php?t=79165

                    In lieu of this, you can use the DrawOnPricePanel property to draw on the Price panel while plotting Indicator data to a panel owned by your NinjaScript.
                    Jessica P.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Jessica! Thank you for your reply. I don't mean to ask you to develop any specific user solution. Rather I'd like to know if NinjaScript allows to do some things common to any solution.

                      I don't mean to plot on two separate panels from one strategy or indicator. I have working solution where I use a strategy and an embedded separate indicator that plots on a separate panel. And I have my indicator in a separate file located in the 'Indicators' folder.

                      My question is: Is it possible to combine my strategy code and my indicator code in one file? That is to add 'namespace NinjaTrader.Indicator' and the indicator's code to my strategy file and make it work as if they were in two different files?

                      Comment


                        #12
                        While it is possible to do something similar to what you are doing, as I had done with the NT7 code, there are a few caveats

                        • The included indicator will no longer be able to plot in a separate panel from your strategy
                        • You will not be able to use the Indicator namespace, as there are symbol incompatibilities with the Strategy namespace
                        • You will need to make the Indicator a subclass to your Strategy; otherwise, the automated code generation will fail

                        I have attached an example for NT8 that works similarly to the example I posted for NT7.
                        Attached Files
                        Last edited by NinjaTrader_JessicaP; 04-10-2017, 08:03 AM.
                        Jessica P.NinjaTrader Customer Service

                        Comment


                          #13
                          Thanks a lot, Jessica! If combining strategy and indicator makes it impossible to plot on a separate panel, this solution isn't suitable for me. Thanks again for your efforts and for your code! I will use separate files for strategy and indicator. It was just a theoretical question.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by ronaldgreene828, Today, 07:50 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post ronaldgreene828  
                          Started by nailz420, Yesterday, 08:38 AM
                          2 responses
                          12 views
                          0 likes
                          Last Post nailz420  
                          Started by bouncetherubble, Today, 06:56 PM
                          0 responses
                          4 views
                          0 likes
                          Last Post bouncetherubble  
                          Started by James108, Today, 06:09 PM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_EricB  
                          Started by RandanAL, Today, 05:13 PM
                          0 responses
                          5 views
                          0 likes
                          Last Post RandanAL  
                          Working...
                          X