Determines the bar creation and trading behavior when the market is inactive, as on weekends, outside market hours, and at business holidays. By default, any bar must contain at least one price quote. When no price quotes arrive due to market inactivity, no new bars are created. This behavior can be changed with the following BarMode flags. Use | or + for combining flags and setf and resf for setting and resetting single flags.


BR_FLAT Generate bars even when they contain no price quote. Use this flag for special scripts that require artificial bars during market offtime, illiquid periods, or between lookback history and first live candle. These bars get flat candles with the close price of the last quote. This flag must be set in the INITRUN before any asset call
BR_WEEKEND Don't generate bars at holidays and between EndWeek and StartWeek in the bar time zone (BarZone), even when they contain price quotes (default). This flag must be set or reset in the INITRUN before any asset calls.
BR_MARKET Don't generate bars between EndMarket and StartMarket in the bar time zone (BarZone), even when they contain price quotes. This flag is for intraday bars and must be set in the INITRUN before any asset calls.
BR_LEISURE Don't enter or manage trades between EndMarket and StartMarket, at holidays, and between EndWeek and StartWeek in the currently selected asset's time zone (AssetMarket). If AssetMarket is not set, BarZone is used instead. If neither is set, UTC time is assumed.
BR_SLEEP Don't request or process price quotes when the market is closed due to BR_WEEKEND and BR_MARKET. Since no prices are updated, tick functions will not run and price-dependent events will not to be triggered during that time. For special purposes only.
BR_LOGOFF Log off on weekends or when the market is closed. BR_SLEEP and BR_WEEKEND must be set. Broker API settings, such as order texts or price or volume types, are usually reset when logging off. Only for special purposes, such as working around server maintenance or API unresponsiveness on weekends. Not all broker APIs support logging off during a trading session.





function run()
  StartWeek = 10400; // start Monday 4 am
  EndWeek = 51900; // end Friday 7 pm
  BarMode = BR_WEEKEND+BR_SLEEP; // don't process quotes during the weekend and don't generate bars

See also:

bar, BarZone, MinutesPerDay, AssetMarket, StartWeek/EndWeek, Holidays


► latest version online