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

Plotting text example

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

    Plotting text example

    I need to plot text of GetProfitLoss() value (value always changes during the trade)somewhere on the chart, like lower right with big fonts. Is there any example that I can use to do this?

    Thanks

    #2
    ssg10, you could for example take a look at this example - http://www.ninjatrader.com/support/f...ad.php?t=19148 and then adapt it to your needs.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Position and MarketPosition

      Thanks.

      protected override void OnBarUpdate()
      {
      // If not flat print our open PnL
      if (Position.MarketPosition != MarketPosition.Flat)
      Print("Open PnL: " + Position.GetProfitLoss(Close[0], PerformanceUnit.Points));
      }

      I tried the code above and Position. and MarketPosition yield compile errors that it doesn't exist in current context. How to fix this?

      Comment


        #4
        Are you trying this from a strategy script? This would not for indicator accessing manual trading positions currently held. The ATM example was a NinjaScript strategy called ATM's for trade management, this would be a special case.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I accessed it from indicator, not strategy

          Comment


            #6
            So, how can i show my percent loss/gain in current position on screen? It is simple stuff.

            Comment


              #7
              Hello,

              Indicators do not have access to strategy items such as MarketPosition. This is the difference between indicators and strategies in NinjaTrader.

              To output your PnL you would either use text. DrawText(). Or if you want a second panel with a PnL line/graph you can do this with strategy plot inside your strategy.

              Please use this sample for strategy plot.

              When running a strategy on a chart you may find the need to plot values onto a chart. If these values are internal strategy calculations that are difficult to migrate to an indicator, you can use the following technique to achieve a plot. NinjaTrader 8 With NinjaTrader 8 we introduced strategy plots which provide the ability


              Let me know if I can be of further assistance.

              Comment


                #8
                Could you elaborate more on "To output your PnL you would either use text. DrawText(). " ?

                Is this in indicator script, or... ?

                What method to call to output PnL and assign it to the DrawText?

                Comment


                  #9
                  I think I have to make it clear what I want to do here.

                  I want to see my real-time PnL on the screen in percentage. And, it is not strategy trades. It is manual trades that I execute myself from the chart trader or DOM.

                  Furthermore, would love to see the total account gain/loss % of the day.

                  I hope this makes it clear, since I think the replies so far is suggesting to plot PnL of strategy trades. Thanks!

                  Comment


                    #10
                    ssg10, what you could do is shown in the strategy script attached - this would not work from an indicator for manual trades. It would work from a strategy for the account it's executing on and up to the level of info what we show documented for the GetAccountValue method :

                    Attached Files
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by ssg10 View Post
                      I think I have to make it clear what I want to do here.

                      I want to see my real-time PnL on the screen in percentage. And, it is not strategy trades. It is manual trades that I execute myself from the chart trader or DOM.

                      Furthermore, would love to see the total account gain/loss % of the day.

                      I hope this makes it clear, since I think the replies so far is suggesting to plot PnL of strategy trades. Thanks!
                      I am not sure what you are asking. Chart Trader shows that information directly.
                      Attached Files

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Gerik, Today, 09:40 AM
                      1 response
                      6 views
                      0 likes
                      Last Post NinjaTrader_Gaby  
                      Started by RookieTrader, Today, 09:37 AM
                      1 response
                      10 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by alifarahani, Today, 09:40 AM
                      0 responses
                      5 views
                      0 likes
                      Last Post alifarahani  
                      Started by KennyK, 05-29-2017, 02:02 AM
                      3 responses
                      1,284 views
                      0 likes
                      Last Post NinjaTrader_Clayton  
                      Started by AttiM, 02-14-2024, 05:20 PM
                      11 responses
                      186 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Working...
                      X