Join & EARN

FOREX ALGOS { }

Flags (Flag Variables)

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 bool variable (true/false) that signals state changes or event occurrences. Commonly named like isTradeOpenfilterActiveentryAllowed.

  • Context: In trading code, a flag may prevent repeated entries or track a mode. For example:

    bool tradePlaced = false;
    if (!tradePlaced && BuySignal)
    {
    OrderSend(...);
    tradePlaced = true;
    }

    Here, tradePlaced is a flag ensuring only one trade is entered until reset.

  • Example:

    // cAlgo: Only trade after initial conditions met
    bool ready = false;
    if (!ready && Bars.Count > 200)
    ready = true;
    if (ready && ...entry conditions...)
    ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000);