Flags - Boolean variables used as markers or switches within code. Flags typically indicate that a certain condition has been met or to enable/disable features. The GeeksforGeeks tutorial explains: “Flag variable is used as a signal in programming to let the program know that a certain condition has met. It usually acts as a boolean variable indicating a condition to be either true or false”.
-
Definition: A
boolvariable (true/false) that signals state changes or event occurrences. Commonly named likeisTradeOpen,filterActive,entryAllowed. -
Context: In trading code, a flag may prevent repeated entries or track a mode. For example:
Here,
tradePlacedis a flag ensuring only one trade is entered until reset. -
Example: