HELP : SCANNER

 

Hi all,

who helps me?
I have a question: I have created this scanner that plays at the end of the formation doji, but it also plays the same alarm in the following candle.
Who tells me where it is wrong?
I would want that it played an only time at the end of the doji and enough, without repeating.
I thank who helps me.

Antonio (Italy)

#property indicator_separate_window
string ver="SCANNER DOJI ";

//---- input parameters
extern bool UseAlert = 1;//*****

// -----------DICHIARAZIONE VARIABILI GENERICHE--------------------------
double alertBar;//*****
bool alertdoji=False;
bool flgrs;

string nome_fin; //nome finestra
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
nome_fin=StringConcatenate(" (",ver,")");
IndicatorShortName(nome_fin);//nome separate window
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{

return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//###############################################################################################
// ----------------------------
if (
Close[1] == Open[1]&& //DOJI
flgrs==0)
{
alertdoji = 1;
flgrs=1;
}
else
{
flgrs=0;
}
//*****************ALERT****************
if (UseAlert==1 && Bars>alertBar && alertdoji==1)
{
Alert(Symbol(), " DOJI " );
alertBar=Bars;
alertdoji=0;
}
return(0);
}
//+------------------------------------------------------------------+