If you use LastAlertTime != Time[rates_total - 1] to check if the current bar has already been alerted, then you have to add LastAlertTime = Time[rates_total - 1] right after alert. Something like this:
MQL4:
if ((AlertDemandClimaxBuyOn) && (HistogramColor[i] ==0) && (i == rates_total - 1) && (LastAlertTime != Time[rates_total - 1]))
{
Alert("Climaxbuy");
LastAlertTime = Time[rates_total - 1];
}
The same should be done with all other alert conditions too.
here is how was done in MT4 in separated indicator:
---------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
extern bool AlertOnBarClimax = true;
double D[],S[],W[];
bool redVol;
bool whiteVol;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
Offset = Offset*Point;
StopOffset = StopOffset*Point;
EntryOffset = EntryOffset*Point;
BreakEven = BreakEven*Point;
TakeProfit = TakeProfit*Point;
SetIndexBuffer(0,D);
SetIndexStyle(0,DRAW_ARROW,0,0);
SetIndexArrow(0, 233);
SetIndexLabel(0,"Demand");
SetIndexBuffer(1,S);
SetIndexStyle(1,DRAW_ARROW,0,0);
SetIndexArrow(1,234);
SetIndexLabel(1,"Supply");
SetIndexBuffer(2,W);
SetIndexStyle(2,DRAW_ARROW,0,1);
SetIndexArrow(2, 251);
SetIndexLabel(2,"debug");
//----
return(0);
}
//---------- BEGIN CDRW Code ---------------\\
spd1 = High[i+1] - Low[i+1];
spd2 = High[i+2] - Low[i+2];
D
=0; S=0; W=0;
v1=iVolume(NULL,0,i+1);
v2=iVolume(NULL,0,i+2);
if ( spd1 > spd2 )
{
if ( v1 < v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
S[i+1] = 0;
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
D[i+1] = 0;
}
}
if ( v1 > v2 )
{
if ( High[i+1]-Close[i+1] < Close[i+1]-Low[i+1] )
{
if (redVol)//originaö
{
D[i+1] = Low[i+1] - Offset;
if ( PriceLabelsOn )
}
}
if ( High[i+1]-Close[i+1] > Close[i+1]-Low[i+1] )
{
if (whiteVol)
{
S[i+1] = High[i+1] + Offset;
}//end if white vol
}//if impo bar
}//end if v1 v2
}
//---------- END CDRW Code ---------------\\
} //end for
if ( AlertOnBarClimax )
{
if ( (redVol && D[1] != 0) && alertonce != Time[0] )
Alert("Demand Bar with Climax on ", Symbol()," ","M",Period() );
if ( (whiteVol && S[1] != 0) && alertonce != Time[0] )
Alert("Supply Bar with Climax on ", Symbol() ," ","M",Period());
alertonce = Time[0];
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
DrawVSAArrows();
if (true)
DrawSRLines();
return(0);
}
//+------------------------------------------------------------------+
Thank you .Well there is no alert. I want to have alert let say on red bar when it close...after that red bar close should be alert and new bar will start...basicaly that would be last closed bar. So how to fix this?
if ((AlertSupplyClimaxSellOn) && (HistogramColor == 3) && (i == rates_total - 1) && (LastAlertTime != Time[rates_total - 1]))
{
Alert("Supply on Climax");
LastAlertTime = Time[rates_total - 1];
}
I need to add this condition in Better Volume barcharts indicator:
condition for SDRW Supply and white bar from BV ...for red bar and demand (SDRW) also....and on all other red and whit just to have alert(no conditions)
Code is above for alert and CDRW condition...you createrd this indicator too.
So how to do that?