Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

daily loss limit in strategy builder

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

    daily loss limit in strategy builder

    hi, hoping to find a method in nj8 strategy builder whereby i could set an overall loss limit on a strategy. in other words to have it exit positions and turn off the working strategy, thanks

    #2
    Hello 37s29nala,

    Thank you for your post.

    Here's an example script a former colleague of ours created that should help. It's a little tricky to do this in the Strategy Builder, but you can if you use a custom series to track the current Strategy PnL. I'd advise importing this and then opening a new Strategy Builder window. On the first screen, find "DailyLossLimitBuilderExample" in the list and from there you can use the Builder navigation buttons to view the necessary logic.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      hi kate

      i wasn't successful here. i downloaded the zip and copied it i dont know where i should paste this. should i be using the strateg;y analyzer.

      Comment


        #4
        Hello 37s29nala,

        Thank you for your reply.

        It should not be copied and pasted, it should be imported into NinjaTrader and then you can open a new Strategy Builder window, select "DailyLossLimitBuilderExample" from the dropdown on the first page, and then you can use the navigation buttons to view how the logic is set up.

        Note — To import NinjaScripts you will need the original .zip file.

        To Import:
        1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
        2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
        3. Select the downloaded .zip file
        4. NinjaTrader will then confirm if the import has been successful.

        Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

        Once installed, you may add the strategy to a chart to test with the Sim101 account by:
        • Right-click your chart > Strategies... > Select the Strategy from the 'Available' list on the left > Add > Check the Enable checkbox on the right > OK
        Here is a short video demonstration of the import process:Please let me know if I can be of further assistance.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Click image for larger version

Name:	Screenshot 2024-05-26 153218.png
Views:	237
Size:	403.4 KB
ID:	1304957Hey Kate,

          Jumping in here.

          I ran this strategy by itself through the strategy analyzer to verify that it worked. One of the things that I noticed was that the Net Profit column in the strategy analyzer was still showing days that had -$7,000 or more, while the daily loss was set at -100. That doesn't make sense. Shouldn't the daily loss prevent a net loss greater than -$100?

          Is there some setting in the Strategy Analyzer that I am missing, or is there something that I am missing in the process? I am just trying to stop the strategy from losing a lot of money on it's bad days. Please help!
          Last edited by 102531911197541600524:NTB; 05-26-2024, 03:05 PM.

          Comment


            #6
            Hello,

            Thank you for your post.

            The actual PnL of the strategy does not have to match the amount for the DailyLoss you have set in code - this is is just the limit to prevent the following trade.

            As an example, if you enter and it goes bad and the PnL of that trade is -300 when it's closed, then the next trade won't be submitted because it is past the limit. However, the actual PnL is -300 which is what the Analyzer is reporting.

            If you take a look at the output of the script, you can see once your DailyLoss has been hit no further trades are taken until the next trading day.

            If you want the analyzer to only show losses of 100, you would need to add additional code to check the unrealized PnL while in a trade and check if it is past -100, then close the trade.

            Please let us know if you have any further questions.
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Kate View Post
              Hello 37s29nala,

              Thank you for your reply.

              It should not be copied and pasted, it should be imported into NinjaTrader and then you can open a new Strategy Builder window, select "DailyLossLimitBuilderExample" from the dropdown on the first page, and then you can use the navigation buttons to view how the logic is set up.

              Note — To import NinjaScripts you will need the original .zip file.

              To Import:
              1. Download the NinjaScripts to your desktop, keep them in the compressed .zip file.
              2. From the Control Center window select the menu Tools > Import > NinjaScript Add-on...
              3. Select the downloaded .zip file
              4. NinjaTrader will then confirm if the import has been successful.

              Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'

              Once installed, you may add the strategy to a chart to test with the Sim101 account by:
              • Right-click your chart > Strategies... > Select the Strategy from the 'Available' list on the left > Add > Check the Enable checkbox on the right > OK
              Here is a short video demonstration of the import process:Please let me know if I can be of further assistance.
              "Critical - Specifically for some NinjaScripts, it will prompt that you are running newer versions of @SMA, @EMA, etc. and ask if you want to replace, press 'No'[/B]"
              Well I accidentally pressed yes. is there any way to revert back?

              Comment


                #8
                Hello,

                There is no way to revert back - you may need to do a clean install to restore them to the default versions. However, if you simply installed the script posted by Kate then there is nothing to worry about as the script she posted did not change any of these default scripts.
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Gaby View Post
                  Hello,

                  There is no way to revert back - you may need to do a clean install to restore them to the default versions. However, if you simply installed the script posted by Kate then there is nothing to worry about as the script she posted did not change any of these default scripts.
                  Yep I installed only those scripts. Thank you

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by lorien, 08-08-2021, 07:33 AM
                  10 responses
                  711 views
                  0 likes
                  Last Post AndyM871  
                  Started by henann, Today, 04:47 PM
                  0 responses
                  2 views
                  0 likes
                  Last Post henann
                  by henann
                   
                  Started by zstheorist, 11-23-2024, 09:06 AM
                  3 responses
                  19 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Started by Ousher, 02-07-2022, 07:37 PM
                  6 responses
                  456 views
                  0 likes
                  Last Post nelslynn  
                  Started by connorgrant5, Today, 03:04 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X