Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

add daily loss and target to a atm strategy

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

    add daily loss and target to a atm strategy

    hello

    i have a bot that use a atm to place the trade and i would like to add the daily loss and target to the script but i notice that after the order is submit it and the atm place the order the daily loss /daily target dont update anymore could you let me know if this is posible to do in ninjascript or not

    #2
    Hello jhontorres,

    Thanks for your post.

    Please see the example scripts located in the forum thread linked below which demonstrate implementing a Daily Loss Limit to your strategy. Similar logic could be used to also implement a Daily Profit Limit.

    DailyLossLimit Example: https://ninjatrader.com/support/foru...limit-examples

    Let us know if we may assist further.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello jhontorres,

      Thanks for your post.

      Please see the example scripts located in the forum thread linked below which demonstrate implementing a Daily Loss Limit to your strategy. Similar logic could be used to also implement a Daily Profit Limit.

      DailyLossLimit Example: https://ninjatrader.com/support/foru...limit-examples

      Let us know if we may assist further.

      tried but didnt work

      do you think i could try to use this code after the // If the strategy has terminated reset the strategy id after doing some profit/loss calculations

      Comment


        #4
        Hello jhontorres,

        Thanks for your note.

        I'm not sure what you mean by 'after the // '. Please provide a brief description explaining exactly what you mean by '// '.

        Note that the DailyLossLimitExample script is intended to be a simple example script demonstrating how to incorporate a DailyLossLimit in a strategy. It would be up to you to implement and modify this logic to work in your script.

        For an example of using ATM Strategy Methods in a custom NinjaScript strategy, see the SampleAtmStrategy file that comes default with NinjaTrader. To view the script, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

        If you do not see the strategy behaving as expected, debugging steps would need to be taken to determine how the strategy is processing logic.

        Below is a link to a forum post that demonstrates how to use prints to understand behavior.
        https://ninjatrader.com/support/foru...121#post791121

        Let me know if I may assist further.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          Originally posted by NinjaTrader_BrandonH View Post
          Hello jhontorres,

          Thanks for your note.

          I'm not sure what you mean by 'after the // '. Please provide a brief description explaining exactly what you mean by '// '.

          Note that the DailyLossLimitExample script is intended to be a simple example script demonstrating how to incorporate a DailyLossLimit in a strategy. It would be up to you to implement and modify this logic to work in your script.

          For an example of using ATM Strategy Methods in a custom NinjaScript strategy, see the SampleAtmStrategy file that comes default with NinjaTrader. To view the script, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

          If you do not see the strategy behaving as expected, debugging steps would need to be taken to determine how the strategy is processing logic.

          Below is a link to a forum post that demonstrates how to use prints to understand behavior.
          https://ninjatrader.com/support/foru...121#post791121

          Let me know if I may assist further.


          okay guessing i didnt explain myself the right way

          so let me try again

          i already created a strategy that use a ATM and everything work fine.

          now what i would like to do is add a daily loss to my strategy and i also have the code to do it but because the ninjascript and the atm dont communicate i cant get the code to stopthe strategy when the daily loss is hit

          Comment


            #6
            Hello jhontorres,

            Thanks for your note.

            Something you could consider is creating a bool named something like OkToTrade and using that bool to control how the strategy places trades.

            You could set the bool to true when your Daily Loss Limit is not reached. Then create a condition that checks if the bool is true and then call your order entry method. Then you could flip the bool to false when your Daily Loss Limit is reached.

            ​​​​​​​This way, trades are only placed when the bool is true. The bool could be set to false when the Daily Loss Limit is reached so that the strategy stops placing trades.

            Let me know if I may assist further.
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            57 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            133 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            73 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X