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

NT8 daily goal/Loss indicator for Strategy Analyzer

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

    NT8 daily goal/Loss indicator for Strategy Analyzer

    May I request someone consider an indicator that can determine the calendar day or session (ETH, RTH…) “Realized PnL” Daily/Session for a strategy with a plot readable from Strategy Builder for conditions and actions. such as -1 = Max Loss; 0 = neutral; 2 = Max Profit Target

    Strategy Analyzer currently will continue making trades throughout a day without concern for win / loss values. So a strategy that is winning at 6am may be a loss at 9pm that shows up as a failure for a strategy. The creator may dismiss a good strategy due to overtrading. Because it failed over the full course of the day it looks like it should be abandoned. Yet with a daily goal it would show a real winner.

    Title suggestion: PnLGoal or PnLplan OR StopTrading

    “PnL Goal” or something similar would allow strategy analyzer to perform more like a novice trader trains. If it hits goal – stop for the day – but continue with the same strategy the next day.

    I am not a coder so I am just suggesting the logic would be something like”

    Current day Unrealized PNL + Realized PNL <= DailyGOal; this would stop the trade for the day if it exceeded that goal and the next day it should trade again.

    Current day Unrealized PNL + Realized PNL >= DailyLOSS; this would stop the trade for the day if it exceeded that loss and the next day it should trade again.

    Surely someone could just code this into a custom strategy but non-coders cannot add code to the strategy builder without breaking the code. Then they cannot continue using Strategy Builder to further refine their strategy.

    Any help would be GREATLY appreciated.

    #2
    Hello JMont1,

    Thanks for your post and interesting idea to present.

    I could think of a few challenges that would come up for someone trying to create an indicator that can accomplish this, be plugged into the Strategy Builder, and also be backtestable in the Strategy Analyzer.
    1. Strategy performance for Unrealized PnL would involve reading the Position object and the Position object is only available from a Strategy.
    2. Strategy performance for Realized PnL would come from the SystemPerformance object which is also unavailable in an indicator.
    3. We could find a strategy by name that is running on the current account, but since the Strategy Analyzer does not use an actual account, this approach would only have value when testing in the Playback Connection.
    As mentioned for Number 3, you could work around numbers 1 and 2 by using code to loop through strategies active on the Playback101 account. I've attached an example that shows how an indicator can loop through and find this information for an active account. Another NinjaScript developer on the forums may wish to use this as their starting point to build an indicator that can accomplish the goals you have outlined.

    Please let me know if I can be of further assistance.
    Attached Files
    JimNinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_Jim, Glad I asked. I am not a coder and thought about trying to do this with the basic indicator creator. Now that sounds foolish.

      Any chance that this type of function could be added to Strategy Analyzer's core capability?

      MEMBERS, anyone willing to give this complex, but probably very helpful to many, a try?

      It would be a great help to Strategy Builders. Currently you can limit the hours traded but no way to have max gain / loss for the day, only for the whole trade test period. So a good trading system may test poorly because it trades too long. There is the capability to limit the hours of trading but that usually would be used after you see the full hours of trading. And using too tight a trade period leads to curve fitting the strategy to the current test bed. PLEASE think of helping

      Comment


        #4
        Hello Jmont1,

        I have opened a new feature request for a fully functional Backtest account so that an approach mentioned above would be backtestable. The ID is SFT-3707.

        We collect interest in feature requests before determining if the feature should be implemented. For that reason we cannot offer an ETA or promise of fulfillment. Upon implementation, the number for the ticket ID can be publicly found in the Release Notes page of the help guide. I will provide a link below.

        Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

        I'll leave this thread open for any community members that would like to develop this indicator.
        JimNinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_Jim thank you. If I recall it helps if other members post a "vote" for this feature request.

          Members, PLEASE post a vote for this since it appears too difficult for me to accomplish. OR hopefully some actual coder could create this indicator. Thank you.
          Last edited by JMont1; 12-22-2018, 09:57 AM.

          Comment


            #6
            NinjaTrader_Jim is there a method to add code to an indicator that would for that section of code start with something indicating it is in a strategy with a position? I tried using: "if ((Position.MarketPosition != MarketPosition.Flat)" but it would not work in the indicator. Is that code only active in strategy?

            Any ideas on how to test for a market position?
            Last edited by JMont1; 12-23-2018, 07:44 AM.

            Comment


              #7
              Hello JMont1,

              Thank you for your note.

              Indicators are not intended to place orders and do not have order methods or a Position property.

              If you were placing orders using the Addon approach, you can check the <account>.Positions collection and loop through all positions on that account.

              Below is a public link to the help guide.



              If you have a strategy, you can supply the instance of that strategy to the indicator by creating a property in the indicator to hold the instance of the strategy. Then from the indicator you can access any public properties, series, or other objects in the strategy (such as the Position).

              The SampleStrategyPlot_NT8 reference sample demonstrates this.



              I also wanted to provide you with a working demonstration of a daily loss limit coded with logic in a strategy.
              Hello, I've updated the DailyLossLimit and DailyLosLimitMultiTrade examples that were posted on the forum for NinjaTrader 7 for NinjaTrader 8. These are often requested and I felt they are good examples to have for NT8. DailyLossLimitExample_NT7 - http://ninjatrader.com/support/forum...241#post451241 (http://ninjatrader


              This thread will remain open for any community members that would like to modify your script as a convenience to you.

              You can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script. The NinjaTrader Ecosystem has affiliate contacts who provide educational as well as consulting services. Please let me know if you would like our business development follow up with you with a list of affiliate consultants who would be happy to create this script or any others at your request.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by PaulMohn, Today, 12:36 PM
              2 responses
              16 views
              0 likes
              Last Post PaulMohn  
              Started by Conceptzx, 10-11-2022, 06:38 AM
              2 responses
              53 views
              0 likes
              Last Post PhillT
              by PhillT
               
              Started by Kaledus, Today, 01:29 PM
              0 responses
              4 views
              0 likes
              Last Post Kaledus
              by Kaledus
               
              Started by yertle, Yesterday, 08:38 AM
              8 responses
              37 views
              0 likes
              Last Post ryjoga
              by ryjoga
               
              Started by rdtdale, Today, 01:02 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X