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

Daily loss limit examples

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

    #46
    Hello Steve4616,

    Thanks for your post.

    This feature request has not yet been implemented into NinjaTrader. I have added your note to the feature request to include a Daily Profit Limit as well as a Daily Loss Limit in the Strategy Builder.

    Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
    • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
    • Feasibility
    • Developer bandwidth
    • Current projects in the queue
    • Economics
    You'll find a note regarding your feature request in the release notes when a feature is implemented.

    Let me know if I may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #47
      Originally posted by NinjaTrader_BrandonH View Post
      Hello Steve4616,

      Thanks for your post.

      This feature request has not yet been implemented into NinjaTrader. I have added your note to the feature request to include a Daily Profit Limit as well as a Daily Loss Limit in the Strategy Builder.

      Deciding on features for future releases is not a simple black and white decision. There are many factors involved including but not limited to:
      • Demand which is measured by objective user requests and subjective discretion on the part of our Product Management team.
      • Feasibility
      • Developer bandwidth
      • Current projects in the queue
      • Economics
      You'll find a note regarding your feature request in the release notes when a feature is implemented.

      Let me know if I may assist further.
      Thanks Brandon

      Comment


        #48
        Originally posted by NinjaTrader_ChelseaB View Post
        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

        DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367

        Update Sep 4th, 2018:
        - I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.

        Update July 13th, 2020:
        - Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.


        Hello,

        What changes do I make in the strategy builder so that the "DailyLossLimitBuilderExample" attached file will work 'on price change' or on 'each tick' (intrabar)instead of on bar close? It works fine on bar close but I want it to operate with intrabar.

        Comment


          #49
          Hello burmaz,

          Thanks for your note.

          I am not aware of anything in that example script that would need to occur at the close of a bar.

          The DailyLossLimitBuilderExample script should work with either Calculate.OnPriceChange or Calculate.OnEachTick.

          You would change the Calculate mode to OnPriceChange or OnEachTick when enabling the strategy.

          Let me know if I may assist further.
          Brandon H.NinjaTrader Customer Service

          Comment


            #50
            Hi is there an option with this to stop trading if reached a profit as well?

            Comment


              #51
              Hello MatthewLesko,

              Thanks for your note.

              Unfortunately, we do not have a reference sample that demonstrates making a Daily Profit Limit.

              That said, you could use the same concept as the Daily Loss Limit reference samples to create a Daily Profit Limit in your strategy.

              Essentially, you would create a DailyProfit variable in your script similar to the DailyLoss variable in the DailyLossLimit script. Then, you would create a condition that compares DailyPNL to your DailyProfit variable.

              Let me know if I may assist further.
              Brandon H.NinjaTrader Customer Service

              Comment


                #52
                Does anybody has a working code that sets a Daily Max Loss?
                Thank You

                Comment


                  #53
                  Originally posted by afisher1965 View Post
                  Does anybody has a working code that sets a Daily Max Loss?
                  Thank You
                  I never did get the daily profit or daily loss working. Tried multiple things but no luck. I'd share if I did

                  Comment


                    #54
                    Originally posted by NinjaTrader_ChelseaB View Post
                    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

                    DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367

                    Update Sep 4th, 2018:
                    - I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.

                    Update July 13th, 2020:
                    - Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.
                    How do I install it? I went to Tools>Import >Ninjascript Add on, restarted the NT8 but cant find where the options are to set Daily Limits. Help Please

                    Comment


                      #55
                      Hello afisher1965 and grimes12,

                      Thanks for your notes.

                      afisher1965:

                      You could download and view the DailyLossLimit example scripts created by my colleague Chelsea attached in post # 1 on page 1 of this forum thread.

                      grimes12:

                      First, download the example script from post # 1 on page 1 of this forum thread. After downloading the file, open NinjaTrader and go to Tools > Import > NinjaScript Addon. To use the strategy, open a New > Chart window and enable the strategy on the chart. Note that this is a sample script demonstrating the concept of how to code a daily loss limit in a NinjaScript. This is not a fully functioning out-of-the-box strategy.

                      See this help guide page: https://ninjatrader.com/support/help...t_strategy.htm

                      Let me know if I may assist further.
                      Brandon H.NinjaTrader Customer Service

                      Comment


                        #56
                        Originally posted by NinjaTrader_BrandonH View Post
                        Hello afisher1965 and grimes12,

                        Thanks for your notes.

                        afisher1965:

                        You could download and view the DailyLossLimit example scripts created by my colleague Chelsea attached in post # 1 on page 1 of this forum thread.

                        grimes12:

                        First, download the example script from post # 1 on page 1 of this forum thread. After downloading the file, open NinjaTrader and go to Tools > Import > NinjaScript Addon. To use the strategy, open a New > Chart window and enable the strategy on the chart. Note that this is a sample script demonstrating the concept of how to code a daily loss limit in a NinjaScript. This is not a fully functioning out-of-the-box strategy.

                        See this help guide page: https://ninjatrader.com/support/help...t_strategy.htm

                        Let me know if I may assist further.
                        Hello Brandon, I was able to enable the strategy, thanks
                        But what is the difference between the "Daily Loss Limit Example_NT8" and "Daily Loss Limit MultiTrade Example_NT8"? When I load both strategies, I same no difference in terms of properties. Please help me understand.

                        Comment


                          #57
                          Originally posted by NinjaTrader_ChelseaB View Post
                          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

                          DailyLossLimitMultiTradeExample_NT7 - http://ninjatrader.com/support/forum...367#post475367

                          Update Sep 4th, 2018:
                          - I realized the print in OnPositionUpdate should print when currentPnL is equal to less than the LossLimit, not just less than it.

                          Update July 13th, 2020:
                          - Added DailyLossLimitBuilderExample_NT8; NinjaTrader_PaulH was clever enough to realize the Strategy Builder custom series can be used with offsets to do math and subtract the total pnl from yesterdays pnl to get the current pnl and provided an example.
                          With the "DailyLossLimitBuilderExample_NT8" should it close the current position when it hits that target? Also, the default number is 100, is that ticks? Points? or Dollars? Thanks

                          Comment


                            #58
                            Originally posted by Steve4616 View Post

                            With the "DailyLossLimitBuilderExample_NT8" should it close the current position when it hits that target? Also, the default number is 100, is that ticks? Points? or Dollars? Thanks
                            Also, in the builder under set 4 it says "CurrentBars{Default input} >20". What is the purpose of this statement? Thanks

                            Comment


                              #59
                              Hello grimes12 and Steve4616,

                              Thanks for your notes.

                              grimes12:

                              "what is the difference between the "Daily Loss Limit Example_NT8" and "Daily Loss Limit MultiTrade Example_NT8"?"

                              DailyLossLimitMultiTradeExample calls EnterLong() multiple times using separate signal names ("long1" and "long2"). DailyLossLimit_NT8 calls EnterLong() once using one signal name ("long1"). This could be seen by viewing and comparing each script's code and noting the differences between the two.

                              Steve4616:

                              " should it close the current position when it hits that target? Also, the default number is 100, is that ticks? Points? or Dollars?"

                              When the CrossAbove condition becomes true and CurrentBars is greater than 20 and DailyPNL is greater than DailyLoss, the strategy will call EnterLong() to place a long Entry order. When the CrossBelow condition becomes true and CurrentBars is greater than 20 and DailyPNL is greater than DailyLoss, the strategy will call EnterShort() to reverse positions so that you end up in a short position.

                              The DailyLoss default value refers to currency (Dollars).

                              "under set 4 it says "CurrentBars{Default input} >20". What is the purpose of this statement?"

                              This condition checks if the CurrentBars value is greater than 20 to ensure that at least 20 bars have been processed before trades are placed.

                              Let me know if I may further assist.


                              Brandon H.NinjaTrader Customer Service

                              Comment


                                #60
                                in my strategy there is no ONPositionUpdate, only onORderupdate. Can this logic that is below be used in onOrderUdate instread?
                                I want to add daily stop loss limit

                                protected override void OnPositionUpdate(Position position, double averagePrice, int quantity, MarketPosition marketPosition)
                                {
                                if (Position.MarketPosition == MarketPosition.Flat && SystemPerformance.AllTrades.Count > 0)
                                {
                                // when a position is closed, add the last trade's Profit to the currentPnL
                                currentPnL += SystemPerformance.AllTrades[SystemPerformance.AllTrades.Count - 1].ProfitCurrency;
                                // print to output window if the daily limit is hit
                                if (currentPnL <= -LossLimit)
                                {
                                Print("daily limit hit, no new orders" + Time[0].ToString());
                                }
                                }
                                }​

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by bmartz, 03-12-2024, 06:12 AM
                                4 responses
                                32 views
                                0 likes
                                Last Post bmartz
                                by bmartz
                                 
                                Started by Aviram Y, Today, 05:29 AM
                                4 responses
                                12 views
                                0 likes
                                Last Post Aviram Y  
                                Started by algospoke, 04-17-2024, 06:40 PM
                                3 responses
                                28 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by gentlebenthebear, Today, 01:30 AM
                                1 response
                                8 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by cls71, Today, 04:45 AM
                                1 response
                                7 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Working...
                                X