#property copyright "1"
#property link "1"
#property version "1.00"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots 1
//---------------------
input string Prefix_1 ="auto";
input string Prefix_2 ="20";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit() {
//--- indicator buffers mapping
Comment("");
ChartSetInteger(0,CHART_SHOW_GRID,0,0); ChartSetInteger(0,CHART_COLOR_CHART_UP,White);ChartSetInteger(0,CHART_MODE,1);ChartSetInteger(0,CHART_SHOW_OHLC,0,0);
ChartSetInteger(0,CHART_COLOR_CANDLE_BULL,White);ChartSetInteger(0,CHART_COLOR_CANDLE_BEAR,LightSeaGreen);
ChartSetInteger(0,CHART_SCALE,2); ChartSetInteger(0,CHART_SHIFT,true);
zButton("Cleaner1" ,120,2,50,15,"Delete 1",8,false,0);
zButton("Cleaner2" ,172,2,50,15,"Delete 2",8,false,0);
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason) {
//---
ObjectDelete(0,"Cleaner1"); ObjectDelete(0,"Cleaner2");
} //-- OnDeinit
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) {
//---
//--- return value of prev_calculated for next call
return(rates_total);
} //--
//+------------------------------------------------------------------+
//| ChartEvent function |
//+------------------------------------------------------------------+
void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam) {
//---
//---------------- D_Cleaner ---------------------
if(ObjectGetInteger(0,"Cleaner1",OBJPROP_STATE)==true) {
ObjectsDeleteAll(0,Prefix_1);
ObjectSetInteger(0,"Cleaner1",OBJPROP_STATE,false);
} //-- if(ObjectGet("D_Cleaner"
if(ObjectGetInteger(0,"Cleaner2",OBJPROP_STATE)==true) {
ObjectsDeleteAll(0,Prefix_2);
ObjectSetInteger(0,"Cleaner2",OBJPROP_STATE,false);
} //-- if(ObjectGet("D_Cleaner"
//--- return value of prev_calculated for next call
} //-- OnChartEvent
//---
//+------------------------------------------------------------------+
//================================================== zButton ==============================================
void zButton(string name="",int Hdist=0,int Vdist=0,int H=0,int V=0,string text="",int FontSize=8,bool status=0,int corn=CORNER_RIGHT_UPPER) {
ObjectCreate(0,name,OBJ_BUTTON,0,0,0);
ObjectSetInteger(0,name,OBJPROP_XDISTANCE,Hdist);
ObjectSetInteger(0,name,OBJPROP_YDISTANCE,Vdist);
ObjectSetInteger(0,name,OBJPROP_XSIZE,H);
ObjectSetInteger(0,name,OBJPROP_YSIZE,V);
ObjectSetInteger(0,name,OBJPROP_CORNER,corn);
ObjectSetString (0,name,OBJPROP_TEXT,text);
ObjectSetString (0,name,OBJPROP_FONT,"Arial");
ObjectSetInteger(0,name,OBJPROP_FONTSIZE,FontSize);
ObjectSetInteger(0,name,OBJPROP_COLOR,clrBlack);
ObjectSetInteger(0,name,OBJPROP_BGCOLOR,clrSilver);
ObjectSetInteger(0,name,OBJPROP_STATE,status);
ObjectSetInteger(0,name,OBJPROP_ZORDER,10);
} //-- zButton