It could be that after a new start of the terminal or the EA (after weekend, after upgrade) OnTick() didn't have all the values it needs.
In this case your BB-bands might have returned EMPTY_VALUE (=2147483647, default for not yet calculated and not to be drawn)
and your if (..) becomes true:
if (iOpen(NULL,0,0)<PreviousOpenLowerBand)OrderEntry(0);
In order not to be trapped that way I use:
bool IsIni = false; void OnTick(){ if ( !IsIni ) { int o = OrdersHistoryTotal(); if ( o>0 ) IsIni = true; else return; } ... }
BTW you use for direction 0 for sell and 1 for buy, it could be easier for you read your code if you use predefined numbers: OP_BUY and OP_SELL.
mr. gooly, THANK YOU SO MUCH for ur reply. . but I still don't understand ur logic. . this is the characteristic of the EA anomaly I talk about:
1. it happen only in EA with custom made Bollinger Bands (not the standard MT4 B. Bands)
2. it only happen at the opening of the week (Monday at 00:00)
3. my broker is Alpari UK.
4. it only open SELL position
5. it happen 3x in 2 weeks. .
I don't understand. . I use PREVIOUS day Bol. band. . it's already not moving. . it's value is DEAD how can my EA make wrong logic. . (P.S. I use custom made Weighted Bollinger Bands). .
Have you checked the values of you "Bands with changes 2.mq4" at those moments?
May be they are 'getting mad' due to a bigger weekend gap?
Print them out or look at the chart.How can I print it?? it only happen at milisecond around 00:00 - 00:01. . .
I have question, is the Metaquotes Bands built-in did not make the same mistake at weekend??
if so, what part of the code that did this>? (MQL4 code that make iBands didn't behave strangely at week opening?)
How can I print it?? it only happen at milisecond around 00:00 - 00:01. . .
I have question, is the Metaquotes Bands built-in did not make the same mistake at weekend??
if so, what part of the code that did this>? (MQL4 code that make iBands didn't behave strangely at week opening?)
How can I print it?? it only happen at milisecond around 00:00 - 00:01. . .
if ( hour()==0 && Minute() == 0 && Seconds()< 10 ) Print(..); if ( hour()==23 && Minute() == 50 && Seconds()> 50 ) Print(..);This way you can catch every Tick around midnight and print what you need..

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Here's my story, I trade with specific broker (Alpari UK) only
At opening trading time this week (monday at 00:00), my EA open position with very wrong logic..
here's the screenshot..
my EA logic is to open BUY, if price open below the lower band of PREVIOUS day Bollinger Band (BLUE BAND), open SELL, if price open above the upper band of PREVIOUS day Bollinger Band (Blue Band)..
as u can see the price open at the middle of the band, and my EA initiate SELL.. Anybody know why this happen??
This is my EA code