#property indicator_chart_window #property indicator_plots 0 #property strict input color Ask_Color = OrangeRed; //Ask Active Color input color Ask_No_Active_Color = Yellow; //Ask No Active Color #define Active_Name "Active Chart" //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ int OnInit() { EventSetMillisecondTimer(50); return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void OnDeinit(const int reason) { if(reason==REASON_REMOVE || reason==REASON_CHARTCHANGE || reason==REASON_RECOMPILE || reason==REASON_CHARTCLOSE || reason==REASON_CLOSE || reason==REASON_PARAMETERS) { ObjectDelete(0, "Active Chart"); EventKillTimer(); } ChartRedraw(); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void OnTimer( ) { refreshChart(); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spread[]) { refreshChart(); return(rates_total); } void refreshChart() { static bool inRefresh = false; if (inRefresh) return; inRefresh = true; ShowActiveChart(); ChartRedraw(); inRefresh=false; } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ void ShowActiveChart() { long currChart,prevChart=ChartFirst(); bool var=false; int i=0,limit=100; while(i