No announcement yet.

Partner 728x90


Show PnL next to Active Trade markers in Chart Trader

  • Filter
  • Time
  • Show
Clear All
new posts

    Show PnL next to Active Trade markers in Chart Trader

    I'd like to know if it would be possible to update the Active Trade markers on the Chart Trader to show the PnL that would occur (based on current entry point and position size) at those points.
    I've attached a mockup to show what I mean.

    Here's the functionality I'd be after more specifically (forgive me for not knowing exactly what the different elements are actually called)

    1. On opening a trade with a Stop Loss and Take Profit, the PnL that would be achieved at those levels is represented as a currency amount directly attached to the active trade markers.
    2. If you were to re-position one of those markers by clicking and moving it on the chart, the PnL would update to reflect the new amount based on its new position.
    ----a. If possible, I'd love to have it dynamically update while dragging, just like it currently shows the number of ticks that you're adjusting the price by as you move it.
    3. If new contracts were added to the trade, the markers should update accordingly.

    I've searched the forums for a while and haven't found anything like this yet. Is anyone aware of any such solution that already exists?
    If not, would building an indicator like this, or modifying the current markers be possible?


    Thank you for your note.

    I suspect this version of our publicly available ATM Strategy identifier script may be of use. I've attached it below. fi you submit an ATM strategy order, when the entry fills the stop loss and profit target will display the current PnL that would be taken at those levels.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service



      The PnL is correct at each price level:

      Click image for larger version

Name:	Unreadable ATM Strategy identifier_1.jpg
Views:	716
Size:	25.4 KB
ID:	1201259

      But the PnL is incorrect if moving all orders to the same price:

      Click image for larger version

Name:	Incorrect total ATM Strategy identifier_2.jpg
Views:	672
Size:	14.5 KB
ID:	1201260

      If I may ask:

      Can the ATMStrategyIdentifire indicator be made to show the correct total PnL for all orders at that price ?

      Many thanks
      Last edited by dj22522; 05-13-2022, 10:24 AM.


        NinjaTrader_Kate thanks for the response! I'll check that out. and dj22522 thanks for adding on the note about that PnL issue on moving the stops!


          Hello NinjaTrader_Kate

          Can the indicator you posted above at #2 be improved on to correctly total orders when they're moved to the same price re: my post #3.

          Many thanks
          Last edited by dj22522; 05-26-2022, 12:53 AM.


            Hello dj22522,

            Thank you for your reply.

            At the current time it's not designed to handle that. While we may make further improvements to the indicator available at some point, I cannot give any kind of ETA on when we may have the bandwidth to accomplish your request. I will note this for future improvements and will work on that as time allows.

            Please let us know if we may be of further assistance to you.
            Kate W.NinjaTrader Customer Service



              Greetings! Please how can i add that to my chart trader??​
              Last edited by GBF_PAT; 01-04-2023, 02:01 PM.


                Hello GBF_PAT,

                The script is an indicator. Download, import, then add the indicator to a chart in the Indicators window.

                To import a NinjaScript into NinjaTrader 8 do the following:
                1. Download the script to your desktop, keep it in the compressed .zip file.
                2. From the Control Center window select Tools -> Import -> NinjaScript...
                3. Click the Desktop icon on the left to navigate to the desktop
                4. Select the downloaded .zip file -> then click Open
                5. NinjaTrader will then confirm if the import has been successful.
                Critical *Note that on any files that say "File already exists on your PC" that start with an "@" symbol are the ones that came preloaded inside of NinjaTrader so you would say "No" so that you do not override those files.

                Below is a link to the help guide on importing NinjaScripts.
                Chelsea B.NinjaTrader Customer Service


                  Thank you support team!


                    How do I change the currency symbol in the indicator? NinjaTrader_ChelseaB


                      Hello Dejavu7629,

                      Welcome to the NinjaTrader forums!

                      The string currently uses "C" for currency.

                      atmDictionary.ElementAt(i).Value.Name + " PnL: " + possiblePnL.ToString("C")

                      You would need to change your windows regional settings to use a different currency symbol.

                      Or you could use a different string and just type in the symbol you want.
                      Chelsea B.NinjaTrader Customer Service


                        Hi NinjaTrader_ChelseaB,
                        This seems like a very good indicator!

                        Please add my vote to updating it to display the correct stoploss values.


                          Here is the code for stops that calculates for each distinct stop, and appends PnL correctly (even if stacked). You can replicate the same for Targets.
                          entry price is the avg price from the Positions instead of Orders.
                          ticksize is the pointvalue - order.Instrument.MasterInstrument.PointValue;

                          ----------------------------- code -------------------------
                          List<double> stopsList = new List<double>();
                          foreach (Order order in atmDictionary.ElementAt(i).Value.stops){
                          stopsList.AddRange(Enumerable.Repeat(order.StopPri ce, order.Quantity));


                          stopsList.ForEach(a => {possiblePnL = (a-entryPrice) * ticksize * stopsList.Where(b => b.Equals(a)).Count();

                          SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory,
                          possiblePnL.ToString("C"), textFormat, ChartPanel.X + ChartPanel.W,
                          float x = (float)(ChartPanel.X + ChartPanel.W - offset);
                          float y = chartScale.GetYByValue(a) + textLayout.Metrics.Height/2;
                          SharpDX.Vector2 textPoint = new SharpDX.Vector2(x, y);
                          RenderTarget.DrawTextLayout(textPoint, textLayout, textBrushDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
                          Click image for larger version  Name:	image.png Views:	0 Size:	54.6 KB ID:	1234652​​
                          Last edited by Adnoker; 02-08-2023, 04:01 PM.


                            Hello Community,

                            I've made these modifications to show the PnL Sum for all quantities on stacked orders.

                            Uploaded to the User App Share.
                            Chelsea B.NinjaTrader Customer Service


                              NinjaTrader_ChelseaB and Adnoker

                              Thank you both for getting this done.

                              Two requests if I may:

                              1) Can there be an option to remove the ATM name. It interferes with the chart especially when additional ATM's are added.
                              (Or can you provide what script to alter in the code)

                              2) Can the PnL at each profit target and Stop be repositioned to be underneath the trade marker as per Adnokers chart example in post 13.

                              Again many thanks

                              Click image for larger version  Name:	Reposition PnL and delete ATM Name.jpg Views:	0 Size:	104.1 KB ID:	1234857
                              Last edited by dj22522; 02-12-2023, 06:45 PM.


                              Latest Posts


                              Topics Statistics Last Post
                              Started by Net_Trader, 03-15-2023, 03:17 PM
                              16 responses
                              Last Post Net_Trader  
                              Started by Vern10, Today, 10:51 AM
                              4 responses
                              Last Post Vern10
                              by Vern10
                              Started by HalTech, Today, 02:11 PM
                              2 responses
                              Last Post HalTech
                              by HalTech
                              Started by Gianpiero, Today, 01:41 PM
                              1 response
                              Last Post NinjaTrader_Ray  
                              Started by josh18955, Today, 11:16 AM
                              1 response
                              Last Post Leeroy_Jenkins