Re: Dynamic Zone indicators for MT4
Posted: Fri Jul 18, 2025 6:48 am
So how are you checking for the break conditions???mrtools wrote: Fri Jul 18, 2025 6:06 am The exact settings you are using is probably what is causing the problem, you are reversing the upper and lower bands!
The color of the bands has no influence on the value of the buffer.
So, if the issue is the color of the bands, then your code is flawed.
Otherwise, how am I reversing the upper and lower bands?
This is how I am using the indicator - it may not be the original idea, but I made this clear from the begining, didn't I?
Sorry check again!!!
Buffer3 is the lower buffer/band,
Buffer4 is the upper buffer/band
My idea is:
Code: Select all
string alertMessage = "";
if ( close[alertBar+1] < Buffer4[alertBar+1] && close[alertBar] > Buffer4[alertBar] )
{
alertMessage = "_Symbol+" "+Tf_as_string(PERIOD_CURRENT)+" Candle broke upper band UP !" ;
AlertOnce(alertMessage,alertBar,PERIOD_CURRENT);
}
if ( close[alertBar+1] > Buffer4[alertBar+1] && close[alertBar] < Buffer4[alertBar] )
{
alertMessage = "_Symbol+" "+Tf_as_string(PERIOD_CURRENT)+" Candle broke upper band DOWN retest !" ;
AlertOnce(alertMessage,alertBar,PERIOD_CURRENT);
}
if ( close[alertBar+1] > Buffer3[alertBar+1] && close[alertBar] < Buffer3[alertBar] )
{
alertMessage = "_Symbol+" "+Tf_as_string(PERIOD_CURRENT)+" Candle broke lower band DOWN !" ;
AlertOnce(alertMessage,alertBar,PERIOD_CURRENT);
}
if ( close[alertBar+1] < Buffer3[alertBar+1] && close[alertBar] > Buffer3[alertBar] )
{
alertMessage = "_Symbol+" "+Tf_as_string(PERIOD_CURRENT)+" Candle broke lower band UP retest !" ;
AlertOnce(alertMessage,alertBar,PERIOD_CURRENT);
}
//+------------------------------------------------------------------+
string Tf_as_string(ENUM_TIMEFRAMES period){
if(period == PERIOD_CURRENT) period = (ENUM_TIMEFRAMES) _Period;
string period_xxx = EnumToString(period); // PERIOD_XXX
return StringSubstr(period_xxx, 7); // XXX
}
//+------------------------------------------------------------------+
int AlertOnce(string alert_msg, int ref, int tf)
{
int i = 0;
static int LastAlert[1000];
while (i < 1000)
{
if (ref == i)
{
if( LastAlert[i] == 0 || LastAlert[i] < iBars(NULL,tf) )
{
if(AlertPopUp) Alert(MQLInfoString(MQL_PROGRAM_NAME)+" "+alert_msg);
if(AlertSound&&!AlertPopUp) PlaySound("alert.wav");
if(AlertEMail) SendMail(MQLInfoString(MQL_PROGRAM_NAME)+" Alert",alert_msg);
if(AlertNotify) SendNotification(alert_msg);
LastAlert[i] = iBars(NULL,tf);
return (1);
}
break;
}
i = i + 1;
}
return(0);
}
//+------------------------------------------------------------------+