• 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

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.
    JoshNinjaTrader 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?
        JoshNinjaTrader 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.
            JoshNinjaTrader 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

                https://ninjatrader.com/support/help...?isoverlay.htm
                JoshNinjaTrader 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
                      JoshNinjaTrader 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
                          JoshNinjaTrader 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.
                              JoshNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sun0781, Today, 05:02 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post sun0781
                              by sun0781
                               
                              Started by ronhb107, 09-12-2019, 10:09 AM
                              4 responses
                              41 views
                              0 likes
                              Last Post Mr.Trader  
                              Started by rwilliam, Today, 03:55 PM
                              0 responses
                              3 views
                              0 likes
                              Last Post rwilliam  
                              Started by asmmbillah, Today, 03:42 PM
                              2 responses
                              8 views
                              0 likes
                              Last Post asmmbillah  
                              Started by NT-Roland, Today, 03:25 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post NT-Roland  
                              Working...
                              X