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

StrategyPlot in NT8

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

    StrategyPlot in NT8

    Hi,

    I'm trying to convert my NT7 to NT8 and would like to add the plots. In NT7 i used the strategy plot as follows:

    protected override void Initialize ()
    {
    slopePriceLevel1 = new DataSeries(this);
    Add(StrategyPlot(0));
    StrategyPlot(0).Plots[0].Pen.Color = Color.Blue;
    StrategyPlot(0).PanelUI = 2;
    ...

    protected override void OnBarUpdate ()
    {
    slopePriceLevel1.Set(priceSlopeTrigger1);
    StrategyPlot(0).Value.Set(SMA(slopePriceLevel1, 1)[0]);
    ...

    Where slopePriceLevel1 is a parameter and priceSlopeTrigger1 is a data series.

    How do I do this in NT8?

    Thanks,

    Lee

    #2
    Hello Lee,
    Thanks for your post.

    While I do not have step by step instructions for your on how to convert this snippet, you would be well suited to check out the Series<t> section of the help guide as that replaced the DataSeries objects from NT7. I have included the link to that help guide document below.

    https://ninjatrader.com/support/help...s/?seriest.htm

    There are a few key items to look for when converting your scripts from NinjaTrader 7 format to NinjaTrader 8, and we keep a Code Breaking Changes table updated in the NinjaTrader 8 Help Guide to assist in identifying changes or new implementations of familiar methods and properties from NinjaTrader 7: https://ninjatrader.com/support/helpGuides/nt8/en-us/?code_breaking_changes.htm

    The names of many methods and properties have changed slightly, so you will need to refactor these in your code. The Code Breaking Changes table can make this task much easier, and there is also an alphabetical reference in the Help Guide that can help to find new method/property names: https://ninjatrader.com/support/helpGuides/nt8/en-us/?alphabetical_reference.htm

    You may also be interested in the reference sample we have available that demonstrates how to plot from a NinjaScript strategy: https://ninjatrader.com/support/help..._a_ninjasc.htm

    Let me know if I can assist with anything else.
    Last edited by NinjaTrader_JoshG; 01-14-2019, 08:20 AM.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hi Josh,

      thanks for the response. Some of the links did not work. Also, the example pulls from an indicator which didn’t really help me. Lets start simple. How do I plot a fixed parameter value from within my strategy in my strategy on a separate panel right below the main panel? Let’s say my fixed parameter is called PanelPlot.

      Thanks,
      Lee

      Comment


        #4
        lee612801,

        I fixed my links. Not sure what happened there..

        When you say a 'fixed parameter' do you mean that the value is never going to change?

        You only need to plot to single panel, correct?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi Josh,

          The value is a parameter that does not change when the strategy is running. But it can be changed by the user in the strategy window.

          Yes, a single panel. Eventually I will want multiple panels (probably 3) below the main panel.

          Thanks,
          Lee

          Comment


            #6
            lee612801,

            I would suggest using the concepts from the reference sample if you ever plan on plotting to multiple panels with that strategy. The ways you would go about adding a single plot is a little different.

            If you just need a single panel for now then you can use AddPlot() for a dynamic value, or AddLine() for a static value.

            https://ninjatrader.com/support/help...s/?addplot.htm

            https://ninjatrader.com/support/helpGuides/nt8/en-us/?addline.htm
            Last edited by NinjaTrader_JoshG; 01-14-2019, 02:50 PM.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Hi Josh,

              Thanks for the info. I was able to get the AddPlot to work by adding the Values parameter. But it plots the value as an overlay on the chart. How do I get the added plot to plot on its own separate panel below and not on the main panel as an overlay?

              Thanks,
              Lee

              Comment


                #8
                lee612801,

                You would use IsOverlay=false

                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  Josh,

                  Thank you. I will chew on this for a bit.

                  Regards,
                  Lee

                  Comment


                    #10
                    Josh,

                    Thanks again for the help. I was able to get the separate panel to plot, but how do I get more than one panel on the chart? Using the IsOverlay=false put all my plots on the same panel. In NT7 I just used the StrategyPlot(0).PanelUI = ; to get the desired panel for each plot. How do you do this in NT8?

                    Regards,
                    Lee

                    Comment


                      #11
                      If you decide to use AddChartIndicator(), the order of the plots can be controlled from the strategy calling the ChartIndicators collection with the index of the indicator and set the panel for that indicator.

                      ChartIndicators[0].Panel = 2;

                      I've attached two examples created by a colleague of mine to demonstrate this. One uses multiple indicator types, the other uses multiple instances of the same indicator type. Other than this I suggest you go with the concepts from the help guide reference sample I provided above.

                      Attached Files
                      Josh G.NinjaTrader Customer Service

                      Comment


                        #12
                        I'm probably wrong, but the reference example you provided above seems like it is creating a separate script that acts like an indicator just to use this feature. I guess I'm confused why NT7 had a relatively simple strategy plot function and NT8 does not?

                        Can you use AddChartIndicator() for parameters (such as my fixed value) other than actual indicators?

                        Thanks

                        Comment


                          #13
                          lee612801,

                          You are correct. You would not be able to use AddChartIndicator() without that plot actually being its own indicator.

                          As far as why it's different specifically I am not sure. A lot of things that were created in Inititialize() in NT7 have been changed to work most efficiently with NT8's OnStateChange() method. You can most easily see the changes made for this concept by comparing the NT7 'Plot from a strategy' sample to the NT8 'Plot from a strategy sample'. I already provided the link for the NT8 sample above, but I will post both versions below as well.

                          NT7: https://ninjatrader.com/support/help..._a_ninjasc.htm

                          NT8; https://ninjatrader.com/support/help..._a_ninjasc.htm


                          Additionally, you can see the rest of the code breaking changes here: https://ninjatrader.com/support/help...ng_changes.htm
                          Josh G.NinjaTrader Customer Service

                          Comment


                            #14
                            Hi Josh,

                            I'm trying to follow along with the SampleStrategyPlot for NT8. I'm bringing the code line by line over to my strategy. But I keep getting a CS0029 error on the sampleOverlayPlot.Strategy = this; in my strategy when compiling. Any ideas?

                            Thanks,
                            Lee

                            Comment


                              #15
                              Lee,

                              I am not sure why you would get that error with that snippet. I would expect it to compile fine if used in the same context as the sample strategy,

                              What is the specific error description that is displayed next to the error code?
                              Last edited by NinjaTrader_JoshG; 01-25-2019, 12:56 PM.
                              Josh G.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by bortz, 11-06-2023, 08:04 AM
                              47 responses
                              1,606 views
                              0 likes
                              Last Post aligator  
                              Started by jaybedreamin, Today, 05:56 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post jaybedreamin  
                              Started by DJ888, 04-16-2024, 06:09 PM
                              6 responses
                              19 views
                              0 likes
                              Last Post DJ888
                              by DJ888
                               
                              Started by Jon17, Today, 04:33 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Jon17
                              by Jon17
                               
                              Started by Javierw.ok, Today, 04:12 PM
                              0 responses
                              15 views
                              0 likes
                              Last Post Javierw.ok  
                              Working...
                              X