Hi, FX5.
I can suggest some cosmetic code changes. I think, this may make code a little more readable.
1. In deinit()
change
if(StringSubstr(label, 0, 14) != "DivergenceLine")
continue;
ObjectDelete(label);
to
if(StringSubstr(label, 0, 14) == "DivergenceLine")
ObjectDelete(label);
2. In IsIndicatorPeak()
change
if(OsMA[i] > OsMA[shift])
break;
to
if(OsMA[i] > OsMA[shift])
return(false);
(and so in IsIndicatorTrough()).