Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Disable Strategy on Realized Net PnL Target

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

    Disable Strategy on Realized Net PnL Target

    I have two separate strategies that work simultaneously. I would like to disable both strategies at the same time when the realized Net Profit from both strategies combined ( I would assume total account PnL) has reached specified currency values, say $3000 or -$1500.

    This is currently implemented in my two scripts:

    // if net PnL is greater than $3000 or a loss of less than -$1500, then we need to close the strategy.
    if (SystemPerformance.AllTrades.TradesPerformance.Cur rency.CumProfit > 3000
    || SystemPerformance.AllTrades.TradesPerformance.Curr ency.CumProfit < -1500)
    {
    CloseStrategy("My Custom Close");
    }


    The strategy disables on its own when either of these conditions are met which is great; however, I would like to change "CumProfit" with the total Net PnL of the two combined active strategies. What should be the correct syntax for the bots to gather the combined net PnL of all active strategies?

    Thanks for the help in advance.
    Last edited by Don22Trader1; 10-26-2021, 04:28 PM.

    #2
    Hello Don22Trader1,

    Thanks for your post.

    You could consider having the strategies read/write to static variables in an AddOn to share a combined Net PnL.

    See the MySharedMethodsAddOnExample script in post #2 of this forum thread linked below for an example of creating static methods.

    MySharedMethodsAddOnExample: https://ninjatrader.com/support/foru...est#post733956

    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

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Yesterday, 05:17 AM
    0 responses
    62 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    134 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    75 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