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

Indicator to simulate basic scenario of Funding Evaluation. See the Trailing Drawdown

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

    Indicator to simulate basic scenario of Funding Evaluation. See the Trailing Drawdown

    I've been thinking about an indicator or dashboard window for NinjaTrader 8 to simulate the basic environment of a Trader Funding Evaluation.

    First, specifying the Account Initial Buying Power (BP). Let's take as example an Initial BP = $30,000 to do some illustrative calculations below, and from here, then the indicator will perform 3 main calculations which are the following:

    A) The dynamic Trailing Drawdown (TDD), which refers to the maximum drawdown the account can reach during the Funding Evaluation counting from highest open balance the account has reached, being dynamically calculated tick-by-tick with every new high the balance reaches and also being shown in real time while your trades are open, so it is like a floating Drawdown. In this section the trader must manually set the TDD value into the indicator, specifying the exact amount of money the evaluation s/he will select allows for Trailing Drawdown, for the next example let's say for an account with $30,000 of Initial Buying Power the Trailing Drawdown = $2,000. So for example, if you begin with the Initial Buying Power (BP) of the Evaluation = $30,000 and you have a $500 winning trade as the highest level reached while the trade was open, then the drawdown will trail up this same amount because your Buying Power has made a new high ($30,500) so now you need to avoid your balance descend to $28,500. It is important to note the Trailing Drawdown counts from the highest open balance the account has reached (balance peak), and Since the TDD is calculated based on the highest open balance the account has ever had, then consequently the TDD moves in only one direction, upwards or trailing up, and does not go backwards when the account is having open or closed losses.

    I will leave a random link I found that explain how works the Trailing Drawdown:

    https://blog.oneuptrader.com/market-...ey-management/

    B) The Auto-Liquidate Threshold Value (ALTV), which is the Trailing Drawdown just expressed in a different way, because the Trailing Drawdown is expressed as the amount of money if the account lose it then you are automatically disqualified, and the Auto-Liquidate Threshold Value is expressed as a Balance if the account descend and reaches it then you are automatically disqualified. So one more time, if the account balance reaches this ALTV level through open or realized losses then you are immediately disqualified from the Evaluation. To see this with numbers, if the Initial Buying Power (BP) of the evaluation is $30,000 and the Trailing Drawdown (TDD) is $2,000, then the Initial ALTV of the Evaluation will be $28,000, since the Initial ALTV = Initial BP - TDD. The only special condition is when the ALTV rise up being = Initial BP, in this example this happens when the ALTV = $30,000 = the Initial BP, where from this level upwards the ALTV and the TDD remain fixed at that level for all the profits and loses the account has from then on. So following the example, once the Auto-Liquidate Threshold Value = $30,000 this ATLV and the TDD won't move anymore from that level and the trader should avoid the Account Balance descend and reaches the $30,000 in order not to lose the Evaluation. As well as Trailing Drawdown, since the ALTV is calculated based on the highest open balance the account has ever had, then consequently the ALTV moves in only one direction, upwards or trailing up, and does not go backwards when the account has open or closed losses.

    C) Finally, the indicator need to show the evaluation Profit Target (PT), where if for example the Evaluation PT = $3,500, once the account reaches that target then the indicator could show a permanent notification in a corner of any chart you open or maybe as a new tab into the main screen NT8 dashboard, indicating the date and time when the PT was reached, and allowing to continue trading normally looking to increase the account size, and the trader only being alert the account balance doesn't go down and reaches the Auto-Liquidate Threshold Value level either with open trades or with closed trades. Once the PT is reached, it would simply be reflected in green color that the target has been reached, but of course, if the account balance falls below the Initial Buying Power + Profit Target level, then the indicator will continue showing the current Profit Target calculation as it was doing previously in the beginning of the evaluation test.

    It is important to note that these calculations must be made based on the whole group of open trades in the account, i.e. based on the portfolio held, and not only based on the one instrument you could have in a chart, or based on separately the long trades and the short trades, no. This means that if you have multiple open positions simultaneously, then consequently the calculations of: the Trailing Drawdown, the Auto-Liquidate Threshold Value and the Profit Target must be calculated based on the whole group of open trades in the account, i.e. always based on the Current Account Balance that is continously changing while your trades are open, regardless of whether you are trading with for example only 1 ES contract, or trading with 10 mixed contracts of ES, MYM, CL, etc., just to give an example.

    It is also important the indicator works with every type of account or datafeed, either:
    - in Live accounts with real-time datafeed.
    - in Demo/Simulated accounts, with real-time or sumulated datafeeds.
    - in Market Replay (Playback) historical data, being this is most important part for backtesting purposes before to start with a real evaluation.


    Finally, this indicator could be taken into the next level by additionally have the option for the user to manually set and specify:

    - The maximum number of contracts (full-size or Micros) that a particular evaluation allows.
    - The Daily Loss Limit, only in case the evaluation has it.
    - The Weekly Loss Limit, only in case the evaluation has it.

    But to start, I think with the A, B and C calculations described above it would have the most essential for a first version of the indicator.

    I was checking into the NT8 Trade Performance tool and I see it shows values like 'Max. drawdown', 'Avg. MAE' or 'Avg. ETD', etc. that are all them based on either trades entry points or divided by 2 groups, short or longs trades, but not based on the portfolio Highest Favorable Open Balance the account has reached of longs trades + shorts trades, both as a whole, that is the main point here as you've read.

    So, I make the request for the development or assistance in the development of an indicator to do and show what I'm describing here, in order to be able to prepare and refine your trading strategy for a funding evaluation. Even, to initiate and as the development progresses, the indicator could start showing only the Trailing Drawdown and the Auto-Liquidate Threshold Value in a simple and quick way, just as a good starting point and move forward from there, because I can't find an automated way to quickly see the Trailing Drawdown or the Auto-Liquidate Threshold Value, and the only way I've used in the previous 2 weeks is by taking the Ruler tool into a chart and measuring symbol by symbol in the visual highest level a trade has reached in a chart and see what PnL have the rest of others open positions, so as you may imagine it is not an useful way when you want to move fast.
    Last edited by futurenow; 02-07-2021, 01:55 PM.

    #2
    Hello futurenow,

    Thank you for your post.


    You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!


    https://ninjatraderecosystem.com/sea...mming-services

    Educators - https://ninjatraderecosystem.com/sea...ures=education

    You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

    This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
    Thomas C.NinjaTrader Customer Service

    Comment


      #3
      Thank you for the replay. I would have the thread open for any trader or developer that have a solution to work this

      By the way, I will leave an example about How the Trailing Drawdown works

      Please note the next numbers are just an example to understand how the calculations works, so there is no need to comment about if is a risky strategy, etc. because this is not extracted from any strategy.


      Initial Account Status:
      Initial Buying Power or Initial Account Balance = $20,000
      Initial Auto-Liquidate Threshold Value = $19,000
      Initial Allowed Drawdown = $1,000


      Note: in the next trades examples when we say 'Max. Open Profits/Losses' we are refering to the 'Maximum Unrealized Profits/Losses' reached while a trade was open.


      Trade #1:
      Portfolio Closing Profits = $300
      Portfolio Max. Open Profits = $500
      Portfolio Max. Open Losses = -$200
      • New Buying Power or New Account Balance = $20,300
      • New Auto-Liquidate Threshold Value = $19,500
      • New Allowed Drawdown = $800 (because $20,300 - $19,500)

      Comments for the Trade #1:
      • The Auto-Liquidate Threshold Value trails up from $19,000 to $19,500 because the Max. Open Profits = $500.
      • The Max. Open Losses < Current Allowed Drawdown ($200 < $800), so the trader continues in the evaluation as normal.


      Trade #2:
      Portfolio Closing Losses = -$100
      Portfolio Max. Open Profits = $150
      Portfolio Max. Open Losses = -$250
      • New Buying Power or New Account Balance = $20,200
      • New Auto-Liquidate Threshold Value = $19,650
      • New Allowed Drawdown = $550 (because $20,200- $19,650)

      Comments for the Trade #2:
      • The Auto-Liquidate Threshold Value trails up from $19,500 to $19,650 because the Max. Open Profits = $150. Remember the Auto-Liquidate Threshold Value moves in only one direction, upwards. It can move up or stay fixed if no new Open Profits but it never moves down, never moves backward.
      • The Max. Open Losses < Current Allowed Drawdown ($250 < $550), so the trader continues in the evaluation as normal.


      Trade #3:
      Portfolio Closing Profits = $900
      Portfolio Max. Open Profits = $1,250
      Portfolio Max. Open Losses = -$100
      • New Buying Power or New Account Balance = $21,100
      • New Auto-Liquidate Threshold Value = $20,000
      • New Allowed Drawdown = $1,100 (because $21,100- $20,000)

      Comments for the Trade #3:
      • Important goal achieved. The Auto-Liquidate Threshold Value trails up one last time from $19,650 to $20,000 because Max. Open Profits = or > a value to meet the Initial Buying Power, in this case $1,250. Remember the Auto-Liquidate Threshold Value trails up ONLY until = Initial Buying Power, for this Evaluation example = $20,000. From this level onwards theAuto-Liquidate Threshold Value remains fixed at $20,000 for all the profits and loses the account has from then on.
      • The Max. Open Losses < Current Allowed Drawdown ($100 < $1,100), so the trader continues in the evaluation as normal, now in a better situation because the Auto-Liquidate Threshold Value will remain fixed at $20,000.

      Trade #4:
      Portfolio Closing Profits = $1,400
      Portfolio Max. Open Profits = $1,600
      Portfolio Max. Open Losses = -$900
      • New Buying Power or New Account Balance = $22,500
      • New Auto-Liquidate Threshold Value = $20,000
      • New Allowed Drawdown = $2,500 (because $22,500 - $20,000)

      Comments for the Trade #4:
      • The Auto-Liquidate Threshold Value remains fixed at $20,000, it won’t have more movements.
      • The Max. Open Losses < Current Allowed Drawdown ($900 < $2,500), so the trader continues in the evaluation as normal, but be careful because IF this trade started moving against before to move in favor, in a case like this then with $200 extra in Open Losses the trader would lose the Evaluation, because in that situation the Max. Open Losses would be = ($1,100) and the highest Losses Allowed until before to start this trade was also = $1,100, that is the previous Drawdown. And remember, if the account balance reaches the current Drawdown level through open or realized losses then the trader is immediately disqualified from the Evaluation. Of course the Drawdown could move up while this trade was open, so for that reason this calculations need to be done in real-time tick-by-tick during the open trades to get the updates values in real-time too.

      Please note the calculation are based in Portfolio positions, so based in multiple open trades, all them open at the same time, so everything is based in the Account Balance in real time (Open Total Account Balance).


      Thank you
      Last edited by futurenow; 02-09-2021, 09:34 AM.

      Comment


        #4
        Originally posted by NinjaTrader_ThomasC View Post
        Hello futurenow,

        Thank you for your post.


        You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!


        https://ninjatraderecosystem.com/sea...mming-services

        Educators - https://ninjatraderecosystem.com/sea...ures=education

        You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third party services for NinjaTrader all pricing and support information will need to be obtained through the consultant.

        This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

        Please let me know if you have any questions, concerns or if I can provide any further assistance by responding to this thread at your convenience.
        Hello

        Ok, I've seen how to start to build a study or indicator and there is something I can't find.

        Could you please show how to extract the Current Account Balance value and display it in a chart or in a kind of dashboard in a separate window, or even better, being able to extract and show this value in the main NT8 window dashboard as a new tab as shown in the attached picture in this reply.

        The idea is to know how to display the exact Current Account Balance, running and self-updating itself in real-time, and in that way from there being able to do any self-update calculation you need with this value, also shown as a real-time calculation.

        Remember this need to work either for a Live, or Demo, or Simulated, or Market Replay (Playback) account or connection.
        Attached Files

        Comment


          #5
          Hello futurenow,

          What you are asking for would require quite a few concepts. We have individual samples of most of these items.

          To get the current account balance you could reference the account class from the addon framework. This would be the preferred way from an indicator. https://ninjatrader.com/support/help...ount_class.htm

          Once you store the account to a variable as shown in that example you can use other methods like Get to get a value: https://ninjatrader.com/support/helpGuides/nt8/get.htm

          For the account you want to target you can use the account selector type converter for a property or if creating an addon you can use the account selector directly.

          Code:
          [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
          public string AccountName { get; set; }
          https://ninjatrader.com/support/help...b=accountselec tor

          To display it on the chart you could use drawing objects or rendering. If you wanted to create a separate window you can do that as well using a NTWindow.
          https://ninjatrader.com/support/help...tsub=draw.text
          https://ninjatrader.com/support/help...t_overview.htm


          Modifying the control center window is not something that would be documented but you could add WPF components to the control center by using an addon. The OnWindowCreated override is called for each window in an addon so you could in theory add elements using that. The addon sample linked above adds a menu item to the control center, a similar approach could be used for other modifications.

          I look forward to being of further assistance.

          JesseNinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_Jesse View Post
            Hello futurenow,

            What you are asking for would require quite a few concepts. We have individual samples of most of these items.

            To get the current account balance you could reference the account class from the addon framework. This would be the preferred way from an indicator. https://ninjatrader.com/support/help...ount_class.htm

            Once you store the account to a variable as shown in that example you can use other methods like Get to get a value: https://ninjatrader.com/support/helpGuides/nt8/get.htm

            For the account you want to target you can use the account selector type converter for a property or if creating an addon you can use the account selector directly.

            Code:
            [TypeConverter(typeof(NinjaTrader.NinjaScript.Accou ntNameConverter))]
            public string AccountName { get; set; }
            https://ninjatrader.com/support/help...b=accountselec tor

            To display it on the chart you could use drawing objects or rendering. If you wanted to create a separate window you can do that as well using a NTWindow.
            https://ninjatrader.com/support/help...tsub=draw.text
            https://ninjatrader.com/support/help...t_overview.htm


            Modifying the control center window is not something that would be documented but you could add WPF components to the control center by using an addon. The OnWindowCreated override is called for each window in an addon so you could in theory add elements using that. The addon sample linked above adds a menu item to the control center, a similar approach could be used for other modifications.

            I look forward to being of further assistance.


            Thank you for the response

            By WPF, do you mean about Windows Presentation Foundation, something about WPF Controls or something related to this? I've been thinking to have an indicator running as a Control Center tab because to save space in the windows toolbar and not to have more open windows, so if is possible then great. If you have a link or video showing this, please send it in the response.

            One more question, is there a quick way to see the Maximum Unrealized Account Balance during a trade? and also the Mimimum Unrealized Account Balance during a trade?, to not to have to do extra calculations to get this 2 values.

            Let's say for example the account balance before to start a trade is $1,000 and during a trade the balance reached $1,200 as Maximum Favorable Balance Excusion and $800 as Maximum Adverse Balance Excursion. Maybe Finally you closed the trade in $1,100 that is a number you can easlily see because that's your real actual account balance, but what about the 2 values I need?

            Comment


              #7
              Hello futurenow,

              That's correct, WPF or windows presentation framework. That is the set of UI components which C# uses currently for UI design.

              For the indicator in the control center that's not really going to be possible from an addon. You could potentially apply an indicator to a chart and then have that indicator look for the control center window to modify it but you would need a chart open to do that. Indicators need a chart to work, an addon cannot call an indicator to get a value so a chart would be required to use indicators in any way.

              For the values you are asking about that would be something you would have to calculate. The platforms unrealized and realized Pnl information would be just the current value which is being calculated. If you wanted to know what the highest or lowest values were for the PnL since the trade started you would need to track that in your logic.



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

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post

                If you wanted to know what the highest or lowest values were for the PnL since the trade started you would need to track that in your logic.


                Hello Jesse!
                I just want to know exactly how do we translate this in code if we want only the Highest PNL of an open trade. I would love to get an example of an indicator on progress.

                Also, maybe it would be easier if we can make an indicator to a chart that:
                1. Shows the Highest Net Liquidation value (based on unrealized profit)
                2. A Max Trailing drawdown (which is based on the Highest Net Liquidation Value minus the desired trailing drawdown)

                An indicator would be fine but if we can actually add this in the accounts tab it would be better!

                thanks!

                Comment


                  #9
                  Hello jhudas88,

                  Thank you for your reply.

                  I would use the Position DIsplay Indicator my colleague Jim created to get an idea of what would be needed to get the position in an indicator and print the unrealized PNL:

                  https://ninjatraderecosystem.com/use...lay-indicator/

                  From there, once you have the Unrealized PNL, you could create a variable that holds the highest PnL value seen, and compare the PnL value to this each time. If the Unrealized PnL value is higher than what's held in the variable, update the variable value. Then you'd use that variable to print the highest seen value to the chart however you like. You could then subtract the desired trailing drawdown value from the highest seen value, save that to another variable and use that variable to print the max trailing value.

                  Please let us know if we may be of further assistance to you.

                  The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
                  Kate W.NinjaTrader Customer Service

                  Comment


                    #10
                    When calculating PNL, unrealized PNL - is it possible to get both of these values with commissions and without commissions using Account object? There are some paid indicator that can do it, wonder how to program my custom one...

                    Comment


                      #11
                      Hi music_p13, thanks for posting.

                      Commissions are only applied to executions and would not be applied to unrealized PnL. You would need to read the commission tempalte from the script and subtract the proper commission value from the unrealized PnL value.
                      Best regards,
                      -ChrisL
                      Chris L.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks, do you have any samples on how to read commissions template per side execution for given instrument programmatically? Also what is the best way to read last executions since position was flat using Account object?

                        Thanks a lot!

                        Comment


                          #13
                          Hi music_p13, thanks for your reply.

                          There is documentation and examples on the Microsoft page for the .NET xml reader:
                          https://docs.microsoft.com/en-us/dot...r?view=net-6.0 (publicly available)

                          Unfortunately, I do not know of any existing examples that are implemented in a script. The commission xml templates are located within Documents\NinjaTrader 8\templates\Commission.

                          This complexity is not required, though, It can be as simple as a public Double property input from the user that represents the commission value and subtract that value from the unrealized PnL.

                          Best regards,
                          ​​​​​​​-ChrisL
                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            That's what I thought - to read the XML file. Is there a way to find out which account is associated with which XML commissions template programmatically using Account object or some other way?

                            Thanks

                            Comment


                              #15
                              Hi music_p13, thanks for your reply.

                              There is no supported code to do it, but there has already been a discussion on the subject here that will help:
                              https://ninjatrader.com/support/foru...injascript-nt8

                              Best regards,
                              -ChrisL
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by AlessioCianini12, Today, 01:55 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post AlessioCianini12  
                              Started by rajneesh.sehgal, Today, 12:06 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by mo_fi, 01-21-2021, 10:08 PM
                              22 responses
                              1,313 views
                              0 likes
                              Last Post Wessel
                              by Wessel
                               
                              Started by ezrollin, 01-12-2022, 03:43 PM
                              2 responses
                              40 views
                              0 likes
                              Last Post iq200
                              by iq200
                               
                              Started by Red_70, Today, 11:07 AM
                              3 responses
                              16 views
                              0 likes
                              Last Post Red_70
                              by Red_70
                               
                              Working...
                              X