Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Concise reset code needed

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

    Concise reset code needed

    Is there are more efficient to reset the “GreenCount” to zero without all the repetition?

    Any coding help will be greatly appreciated.

    Code:
    if (BarsInProgress == 0 && Position.MarketPosition == MarketPosition.Long)
    {
        if (currentTradeNumber == 1)
            {
            ExitLong(4, qtyLong1, "LX01_");
            GreenCount = 0;
            }
        else
        if (currentTradeNumber == 2)
            {
            ExitLong(4, qtyLong2, "LX02_”);
            GreenCount = 0;
            }
        else
        if (currentTradeNumber == 3)
            {
            ExitLong(4, qtyLong3, "LX03_”);
            GreenCount = 0;
            }
        else
        if (currentTradeNumber == 4)
            {
            ExitLong(4, qtyLong4, "LX04_”);
            GreenCount = 0;
            }
        else
        if (currentTradeNumber == 5)
            {
            ExitLong(4, qtyLong5, "LX05_”);
            GreenCount = 0;
            }
    }

    Thanks in advance.

    #2
    Hello ArmKnuckle,

    Thanks for your post.

    if (currentTradeNumber >= 1 && currentTradeNumber <= 5)
    {
    GreenCount = 0;
    }

    Comment


      #3
      Originally posted by ArmKnuckle View Post
      Is there are more efficient to reset the “GreenCount” to zero without all the repetition?

      Any coding help will be greatly appreciated.

      Code:
      if (BarsInProgress == 0 && Position.MarketPosition == MarketPosition.Long)
      {
      if (currentTradeNumber == 1)
      {
      ExitLong(4, qtyLong1, "LX01_");
      GreenCount = 0;
      }
      else
      if (currentTradeNumber == 2)
      {
      ExitLong(4, qtyLong2, "LX02_”);
      GreenCount = 0;
      }
      else
      if (currentTradeNumber == 3)
      {
      ExitLong(4, qtyLong3, "LX03_”);
      GreenCount = 0;
      }
      else
      if (currentTradeNumber == 4)
      {
      ExitLong(4, qtyLong4, "LX04_”);
      GreenCount = 0;
      }
      else
      if (currentTradeNumber == 5)
      {
      ExitLong(4, qtyLong5, "LX05_”);
      GreenCount = 0;
      }
      }

      Thanks in advance.
      Every single branch of the code sets GreenCount = 0. You might just as well unconditionally set GreenCount = 0 once before or after the complete set of branches.
      Last edited by koganam; 11-18-2019, 10:22 AM. Reason: Added the word "once" to make the statement clearer.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      52 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      29 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      194 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      355 views
      0 likes
      Last Post CaptainJack  
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      274 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X