Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Daily loss limit examples

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

    #31
    Originally posted by NinjaTrader_Jim View Post
    Hello Trader17,


    If you change the strategy to Calculate.OnEachTick or OnPriceChange, line 53 if (Bars.IsFirstBarOfSession) will be true for each tick of that bar. I would suggest adding an IsFirstTickOfBar check with that condition to ensure it only happens once on that bar.

    Please let us know if you have any questions.
    Thank you. In this statement for Line 53 I would leave it as is because the PnL is reset each day on the first session bar, correct? And I add IsFirstTickOfBar in the logic itself to prevent calculation more than once for the last closed bar. Correct?

    Thanks a lot.

    Comment


      #32
      Originally posted by NinjaTrader_Jim View Post
      Hello Trader17,

      Bools return a true or false value and checking if (YourBool == true) is equivalent to checking if(YourBool). It can be very helpful and will at times be necessary to test out the concept to observe the behavior. For example, you could create a couple conditions that print a message if the condition becomes true.

      if (IsFirstTickOfBar) Print("Condition 1 This is true"");

      if (IsFirstTickOfBar == true) Print("Condition 2 This is true");

      We look forward to being of further assistance.
      So are both correct for Ninja Script? I know == True is meaningless as it is what is returned upon checking the logic.
      Thank you.

      Comment


        #33
        Hello Trader17,

        There will be countless questions in regards to what is possible with C#/NinjaScript and what is correct syntax. It will be necessary for you as an individual working on the script to test your questions to see if what you think you have written is correct or if it is not. For that reason, I will leave the question presented in #32 as an exercise to you. Please set up test conditions similar to my reply in which you have quoted. Testing this will be a straightforward answer to your question that you can set up on your end.

        Thank you. In this statement for Line 53 I would leave it as is because the PnL is reset each day on the first session bar, correct? And I add IsFirstTickOfBar in the logic itself to prevent calculation more than once for the last closed bar. Correct?
        If you add a check for IsFirstTickOfBar to the condition on line 53 in Chelsea's script and change the script to use Calculate.OnPriceChange or Calculate.OnEachTick, then you will restrict the code to only reset the daily PnL once, and not multiple times per bar.

        Many of these questions will be best answered by testing on your own. Our role is not to provide examples that perform multiple tasks so you can copy and use in your custom works, but to educate you on how each concept works. My recommendation would be to start with simple test scripts so you can get used to working with scripts that calculate OnEachTick or OnPriceChange, and then once you have mastered these concepts, combine the behavior with the Daily Loss example.

        We look forward to being of further assistance.
        JimNinjaTrader Customer Service

        Comment


          #34
          Originally posted by NinjaTrader_Jim View Post
          Hello Trader17,

          If you add a check for IsFirstTickOfBar to the condition on line 53 in Chelsea's script and change the script to use Calculate.OnPriceChange or Calculate.OnEachTick, then you will restrict the code to only reset the daily PnL once, and not multiple times per bar.

          We look forward to being of further assistance.
          Thanks. I was going to leave Line 53 as is with Calculate set to Each Tick and just use Is First Tick of Bar in the condition logic to restrict it from calculating entry logic on each tick. And Script will still recognize the first bar of session with calculate set to calculate on each tick, correct?

          Or to reset the PnL only once while using Calculate on Each Tick if I use Is First Tick of Bar and First Bar of Session keeps it from resetting on every tick in the first session bar as you mentioned. So as long as a tick is traded in the new session it assumes it is the first bar of session without waiting for it to close and we are calculating on each tick it will reset the PnL to zero only once, correct?

          Thank you.
          Last edited by Trader17; 04-17-2019, 01:55 PM.

          Comment


            #35
            Now when this is used in a strategy it calculates the PnL on all trades for the day including historical trades. What if I want to start it for just a couple of hours anytim I wish and have the PnL start from zero at that point? Anything in Script that can prevent calculating historical trades for the day till I start it?
            Thank you.

            Comment


              #36
              Hello Trader17,

              I noticed that you also have a ticket open regarding this item with my colleague, Kate, over email. We ask that you continue working with the current technician assigned to your ticket without opening a new ticket. This helps us to ensure that the same technicians are not working on the same items which improves our ability to serve all of our clients.

              Thanks. I was going to leave Line 53 as is with Calculate set to Each Tick and just use Is First Tick of Bar in the condition logic to restrict it from calculating entry logic on each tick. And Script will still recognize the first bar of session with calculate set to calculate on each tick, correct?
              We should be clear that our role is not to provide recommendation for modifying single lines of code. Our role is to provide educational information on how to use the software. As with learning any new language there will be a necessary level of testing to understand how to work with that language. This sort of hypothetical question would be best answered by testing with prints to see the behavior yourself.

              Or to reset the PnL only once while using Calculate on Each Tick if I use Is First Tick of Bar and First Bar of Session keeps it from resetting on every tick in the first session bar as you mentioned. So as long as a tick is traded in the new session it assumes it is the first bar of session without waiting for it to close and we are calculating on each tick it will reset the PnL to zero only once, correct?
              The first bar of a session is determined by the Trading Hours template. The first tick of that bar will have IsFirstTickOfBar == true and Bars.IsFirstBarOfSession == true. This is another item that would be best answered by testing with prints to observe the behavior.

              Now when this is used in a strategy it calculates the PnL on all trades for the day including historical trades. What if I want to start it for just a couple of hours anytim I wish and have the PnL start from zero at that point? Anything in Script that can prevent calculating historical trades for the day till I start it?
              You can have the strategy return from historical processing in OnBarUpdate with if (State == State.Historical) return;

              Please understand that while we are here to assist you on your journey, our support services are not equipped to handle large numbers of questions that involve confirming a concept, and many such items are best understood through testing. If you have any additional questions, please attach the debug prints you are using and the output received so we can offer further direction to help you test these items to better understand these concepts.

              We look forward to being of further assistance.
              JimNinjaTrader Customer Service

              Comment


                #37
                Hello,
                Does anyone know the status of the "loss limit tool for NinjaScript Strategies" ID# SFT-2936 and a link to track its progress or release? An indicator that stops my trades if I gain or loose set mounts would be a major improvement to my stratagies!
                Thank you!

                Comment


                  #38
                  Originally posted by JonTansey View Post
                  Rookie question here. How do I view the DailyLossLimitExample_NT8.zip (1.6 KB, 1 view) once I import it?
                  After Import it you have to enable the strategy on your chart or you can try to understand the logic of the script with the ninjascript editor and copy it on your own strategy

                  Comment


                    #39
                    Hello jpatri,

                    There is no ETA and feature requests are tracked internally as the requests often contain internal discussion which we would not want to have public facing.

                    Feature Request Disclaimer.

                    We receive many requests and cannot reasonably implement all requested features or changes. Interest is tracked internally and if enough interest is tracked, it would be weighed against how feasible it would be to make those changes to consider implementing.

                    When new features are implemented, they will be listed in the Release Notes page of the Help Guide. The ID number will be different than the internal feature request tracking ID, but the description of the feature will let you know if that feature has been implemented.

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

                    Let us know if you have any questions.
                    JimNinjaTrader Customer Service

                    Comment


                      #40
                      Hey everyone, I'm curious if it's possible to do something like this directly inside the strategy builder without manually coding it? For instance if I have a strategy working properly from the Strategy Builder, is there a way to allow for the ability of a daily loss limit or profit limit with a combination of the strategy builder parameters?

                      TIA

                      Comment


                        #41
                        Welcome to the forums TheTradingNetwork!


                        There would not be a parameter to add, the logic will have to be created in the Strategy Builder. Please see post 1 for the DailyLossLimitMultiTradeExample_NT8 example to see how this logic can be set up.

                        We look forward to assisting.
                        JimNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by fastnet, Yesterday, 10:58 PM
                        1 response
                        12 views
                        0 likes
                        Last Post NinjaTrader_PatrickG  
                        Started by stefanrvc, Today, 06:13 AM
                        1 response
                        7 views
                        0 likes
                        Last Post NinjaTrader_PaulH  
                        Started by tradingbobby, Yesterday, 10:41 PM
                        2 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_PaulH  
                        Started by WHICKED, Yesterday, 09:05 PM
                        1 response
                        16 views
                        0 likes
                        Last Post NinjaTrader_ChrisSch  
                        Started by donjay2101, Today, 05:32 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post donjay2101  
                        Working...
                        X