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

Position Display Indicator "2.0" ......

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

    Position Display Indicator "2.0" ......

    ....what I am always wondering again is that 90% of traders are spending time with indicators about what the market is doing or not doing. ......but managing the risk is the only thing what divides the winners and the loosers.

    ONE really simple helper would be,.....if I can see immediately, how many percent I am using of my available margin. (What I am actually doing with an excel file, but it is separate .....better would be if it could be inside) It shows the risk!

    For getting this most important issue solved, to have your money and your risk and what you have done intraday, always visible and "in front".


    What I have seen that Jim from the NT Team posted a "Position Display Indicator". ....this is great, but it would be perfect, if this Indicator would have the percentage of margin in relation to you live equity.

    Unfortunately I am not aware of programming, to add this. There should be a possibilty to set 3 variables ( Intraday, maintenance, overnight - margin in $ per contract) ....maybe someone can help.

    #2
    Hello pmmkm,

    Thank you for your post.

    The indicators that are posted on the file-sharing site come "as is" and the support team could not add new features. This thread will stay active indefinitely so a member of the community here on the forum could possibly assist with this. One would need to add logic that would calculate what percentage your PnL is of the accounts cash value. You can see that cash value is being accessed in OnAccountItemUpdate in the script.

    Please let me know if I can assist further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello,

      Is there a way to access Account PNL (realized/not realized) per instrument?

      Thanks

      Comment


        #4
        Hello music_p13, thanks for your post.

        The GetTrades() method will return a TradeCollection object of the specified instrument. That collection could then be used to calculate PnL the strategy made for that particular instrument. After you get the TradeCollection object for the instrument, use the TradePerformance object of that TradeCollection to get the PnL.

        Best regards.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Chris, thanks for reply!

          A follow up question:

          Function GetTrades has 2 extra parameters: string entrySignalName, int instance

          I am interested in getting PNL for the given instrument for current day and also cumulative PNL since strategy has been running (in replay or live mode).

          Do you have any guidance on how to accomplish these tasks, and what should be values of these 2 parameters?

          Also, to get unrealized PNL per instrument (assuming few strategies could be running for this instrument) is to use PositionAccount.GetUnrealizedProfitLoss(Performanc eUnit unit, double price)

          How to get PNL per instrument in combination with PositionAccount.GetUnrealizedProfitLoss ?

          Thanks
          Last edited by music_p13; 07-08-2019, 08:23 AM.

          Comment


            #6
            Hello music_p13, thanks for your reply.

            To get the PnL of a strategy since the start of the trading day, your script would need to keep track of that on a per-session basis. The reference sample below shows how to reset script values at the end of a trading session:


            To get the unrealized PnL of a multi-instrument script, you would use the PositionsAccount object:



            If your script does make multiple positions on multiple instruments, you should give all of your orders a signal name so they can be specifically referenced at a later point in time. You will notice that all order entry methods take a "SignalName" property. When the order is created, it will be given this signal name. If you don't give your orders signal names, just put a blank string into that parameter field (""). The instance will be the instance of the trade, do you want the most recently closed trade or the second to most recently closed trade?

            Kind regards.
            Chris L.NinjaTrader Customer Service

            Comment


              #7
              Hello,

              I would like to run few strategies in real time at the same time. I want to gather some statistics such as a combination of them and output it on 1 minute bar series. In there, I want to see total realized PNL each minute, (all instruments combined), total unrealized PNL (all instruments combined), total realized PNL per instrument each minute (even if few strategies run on same instrument), total unrealized PNL per instrument each minute)... Once I have these indicators, I could then also export its values and analyze them further.

              My question is how to filter PNL by instrument for positionAccount object from a single indicator provided I am running mutiple strategies on multiple instruments? In that indicator I will configure separate plots per instrument...

              Thanks

              Comment


                #8
                Hi music_p13, thanks for your reply.

                To do this from an indicator would be a bit different. First, you would need to set up an Account object in your indicator. In the example on that page they do this through an Addon, but it can be done through an indicator all the same. The PositionUpdate event seems like it will be useful for this purpose. Also note the other event methods that help keep track of action on the account: OnAccountItemUpdate, OnExecutionUpdate, and OnAccountStatusUpdate.

                The Strategies collection of the Account class seems to be what you are looking for. This holds a collection of StrategyBase objects where you can access an individual strategies Position, Unrealized PnL, etc.

                Here are all of the available properties of the StrategyBase object:



                Best regards.
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                213 views
                1 like
                Last Post PaulMohn  
                Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                4 responses
                544 views
                0 likes
                Last Post PaulMohn  
                Started by GLFX005, Today, 03:23 AM
                0 responses
                3 views
                0 likes
                Last Post GLFX005
                by GLFX005
                 
                Started by XXtrader, Yesterday, 11:30 PM
                2 responses
                12 views
                0 likes
                Last Post XXtrader  
                Started by Waxavi, Today, 02:10 AM
                0 responses
                7 views
                0 likes
                Last Post Waxavi
                by Waxavi
                 
                Working...
                X