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

Plot strategy's PnL in a sub panel

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

    Plot strategy's PnL in a sub panel

    Hello,

    Can you please advise me on if there is any way to plot historical and real-time PnL of a NinjaScript strategy in a sub-panel in a form of indicator?

    Best regards,
    Alexei

    #2
    Hello akuntysh,

    You can pass values to an indicator to have it plotted from a strategy or you can plot directly from a strategy as well. The AddPlot works in both an indicator and a strategy. If you want this in a sub panel, you will likely need to follow the strategy plot example and the indicator which uses IsOverlay = false here: https://ninjatrader.com/support/help..._a_ninjasc.htm

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Got it, thank you!

      Best regards,
      Alexei

      Comment


        #4
        Hello,

        Is it possible to create multiple "SubPanels" from within a strategy?

        So I need to add few subpanel indicators for this? Any samples on adding few sub-panels?

        Thanks

        Comment


          #5
          Hello music_p13,

          Yes please see post #2 and the sample provided, that demonstrates using sub panels.

          Please let me know if I may be of further assistance.

          JesseNinjaTrader Customer Service

          Comment


            #6
            Jesse,

            After investigating for hours, I believe that this post is the closes one to the issue that I am having.

            Requirements:
            • Plot from a strategy on a different panel
            • The other panel needs to plot the zero and the actual plot
            • The second panel should be Plotting a different data series

            What I know at this time:
            • When using the AddChartIndicator(), it can only reference the primary data series for the strategy. Don't know how to overcome this.
            • I have to synch the data series
            • Not only I am synching the data series, but I can see that I am passing the plotting value from the strategy to indicator
            • I found the fallowing in the Help Guide (https://ninjatrader.com/support/help...tindicator.htm).
            • An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)

              o If a secondary or null Bars series is specified by the calling strategy (not the indicator itself), the strategy's primary series will be substituted instead.
            Current Behavior:
            • I have taken the script that is mentioned all the way at the top of this post. I am synching the data series and I can see that the second data series data is passing from the strategy to the indicator (the Print statements).
            • I cannot explain what is plotting, but it is definitely not what I am looking.
            I am loading the two files that I have modified attempting to accomplish my requirements.
            Last edited by GARZONJ; 01-11-2020, 06:46 PM.

            Comment


              #7
              I am including the code files.
              Attached Files

              Comment


                #8
                Hello GARZONJ,

                The problem with your test is that you are supplying a secondary series/calling it from the secondary series which goes against what is documented for AddChartIndicator:

                An indicator being added via AddChartIndicator() cannot use any additional data series hosted by the calling strategy, but can only use the strategy's primary data series. If you wish to use a different data series for the indicator's input, you can add the series in the indicator itself and explicitly reference it in the indicator code (please make sure though the hosting strategy has the same AddDataSeries() call included as well)
                You could instead have the indicator add its own data and then produce a plot however that is not what the strategy plot example is intended to demonstrate. The strategy plot example is not intended to be used with more than one series or pass a series like that, it is only intended to read values that the strategy has set to its series and plot them at the frequency of the primary series. This would be helpful for plotting values that directly apply to your strategy like its PnL or possibly an indicator value it uses which is using the primary data.

                If your goal is to use tick data from the indicator and strategy you could use AddDataSeries in both the indicator and strategy. When adding the indicator you would not need to pass anything to it, just call it when needed like a normal indicator. The indicator could calculate based on the tick data and plot a value, it could use a secondary panel for that purpose as well.





                Please let me know if I may be of further assistance.

                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by alifarahani, Today, 09:40 AM
                6 responses
                31 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                17 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by Kaledus, Today, 01:29 PM
                5 responses
                14 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by Waxavi, Today, 02:00 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Started by gentlebenthebear, Today, 01:30 AM
                3 responses
                17 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X