Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Proper Syntax for bools

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

    Proper Syntax for bools


    if (
    ((ATSCyclePatternFilters12.LastCyclePlot[0] == -1)
    && (PatternFound12 == true)
    && (Close[0] > Open[0])))

    {
    PatternFound12 = false;
    }

    AS SHOWN ABOVE

    in strategy builder I see in Condition sets that the bool will have a double ==

    and in actions the bool will have a single =

    FIRST IS THE CORRECT?

    SECOND, IF SO, why can you in unlock code place a single = in the condition set

    && (PatternFound12 = true)

    and still compile without errors

    thanks

    #2
    Hello DTSSTS,

    That is correct syntax, a double equals means "equal to" a single equals is an assignment. The variable is being set to false with the single equal, the variable is being checked if it is true with the double equal.

    You can unlock the code and make it a single equals and have it compile because that's technically valid code, it just doesn't make sense to do that. You are checking if the variable equals a certain value in the if condition, not trying to set it to something else. You set it to something else if the condition is true as the action of the condition.

    Comment


      #3
      your are saying continue to use the double == in the condtions

      && (PatternFound12 == true)

      I was only trying to confirm it should compile both ways. I actually was have issues a few months ago with random trades that did not make sense, but later saw I had the bool rule being conditioned with a single =, which I think was the issue

      Comment


        #4
        Hello DTSSTS,

        Yes you should continue to use the code that was generated. Using a single equals in the if condition as part of the condition does not make sense.

        You can make C# code compile in a lot of strange ways however those use likely won't make sense or will not be valid.

        The issue you had seen with the trades would likely be related if you had used a single equals as part of an if condition.

        Code:
        && (PatternFound12 == true)
        reads as: AND PatternFound12 is equal to true

        Code:
        && (PatternFound12 = true)
        reads as: AND PatternFound12 is now set to true, this statement completed successfully so the result is true always.

        Comment


          #5
          NOW I understand "now" set to true

          Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          43 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