Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop entering trade when profit hit and reset

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

    Stop entering trade when profit hit and reset

    Hi ,

    How can I make the strategy to stop trading when a certain profit is hit and then reset it the next day without having to disable it

    I tried the following but this does not seem to work.


    double MyNetProfit = SystemPerformance.AllTrades.TradesPerformance.NetP rofit ;

    if (MyNetProfit >= MaxProfitHit) return;

    if (Bars.IsFirstBarOfSession) MyNetProfit = 0;

    Thanks


    #2
    Hello jpsjrj,

    Thanks for your post.

    The strategy profit accumulates each day that the strategy runs and is not reset.

    What you would need to do is to at the first bar of the session, to store the strategy accumulated PNL into a variable. Then the daily PNL would be the difference between the accumulated PNL and the saved PNL.

    Something like this:

    if (Bars.IsFirstBarOfSession)
    {
    priorPNL = SystemPerformance.AllTrades.TradesPerformance.NetP rofit ; // priorPNL would be a double type variable created at the class level as private double priorPNL
    }

    double MyNetProfit = SystemPerformance.AllTrades.TradesPerformance.NetP rofit - priorPNL; // daily PNL value


    if (MyNetProfit >= MaxProfitHit) return;

    Comment


      #3
      Thanks !! That did the trick.

      I did the same thing for GrosssLoss or Drawdown but that did not work. What do I need to do differently. ?


      if (Bars.IsFirstBarOfSession) {
      priorDrawDown = SystemPerformance.AllTrades.TradesPerformance.Curr ency.Drawdown ;
      priorGrossLoss = SystemPerformance.AllTrades.TradesPerformance.Gros sLoss;
      }


      double MyCurrentDrawn = SystemPerformance.AllTrades.TradesPerformance.Curr ency.Drawdown + priorDrawDown ;

      double MyGrossLoss = SystemPerformance.AllTrades.TradesPerformance.Gros sLoss + priorGrossLoss ;


      if (MyCurrentDrawn > 200) return;

      if (MyGrossLoss > 200 ) return;

      Comment


        #4
        Hello jpsjrj,

        Thanks for your reply.

        I would suggest using print statements to print out those values to help clarify what your strategy is using and working with.



        Comment


          #5
          Hello jpsjrj,
          GrossLoss and DrawDown are shown as negative numbers in strategy analyzer. Thus, I would assume, you need to change the code:

          if (MyCurrentDrawn*-1 > 200) return;
          if (MyGrossLoss*-1 > 200 ) return;
          Or
          if (MyCurrentDrawn < -200) return;
          if (MyGrossLoss < -200 ) return;

          NT-Roland

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          44 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          65 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X