Warrior_EA/System/NewBar.mqh
AnimateDread 5efdb48de4 refactor(comments): stdlib comment style across the remaining in-scope files
Same pass as 0b06f8e, applied file by file: comment runs of 4+ lines compressed
to their leading topic sentences, capped at 4 lines, whole sentences only.
Warning sentences (NEVER / MUST / trap / would-have) survive the budget.

Every file was checked the same way before committing: the list of non-comment
lines is byte-identical to HEAD, and braces balance. No code was touched.

Panel/, Enumerations/ and the already-terse System headers needed little or
nothing - PooledGate, TradeChecks, BinomialStats and Random came through with
no blocks over the threshold at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-22 00:25:52 -04:00

26 lines
No EOL
1.2 KiB
MQL5

//+------------------------------------------------------------------+
//| NewBar.mqh |
//| AnimateDread |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "AnimateDread"
#property link "https://www.mql5.com"
bool NewBar()
{
datetime cTime[];
ArraySetAsSeries(cTime, true);
static datetime LastTime = 0;
// CopyTime can return 0/fail (history not yet synced right after attach, or a data gap on an
// illiquid symbol) leaving cTime empty - indexing cTime[0] unguarded would raise an "array out
// of range" runtime error and abort this tick's processing (skipping bar-close-triggered logic
// like autosave/era boundaries) with no diagnostic.
if(CopyTime(Symbol(), Period(), 0, 1, cTime) <= 0 || ArraySize(cTime) == 0)
{
Print(__FUNCTION__ + ": CopyTime failed or returned no data (error " + IntegerToString(GetLastError()) + ") - treating this tick as not-a-new-bar.");
return false;
}
bool ret = cTime[0] > LastTime && LastTime > 0;
LastTime = cTime[0];
return ret;
}