tried scanner withy adx indicator got an error" semicolon expected in void " it may have more errors please help me

To add comments, please log in or register
arunkumar96
21
arunkumar96  
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#property strict
#property indicator_chart_window

string INDI_NAME="MPSCN-";

input int TimerInterval=60; //Update interval (secs)
input int FontSize=10;  //Font Size
input string FontName="Calibri"; //Font Name

input string Group0; //---------------------------------------------------
input ENUM_TIMEFRAMES AdxTimeframe=PERIOD_M5; //ADX Timeframe
input int AdxPeriod=14; //ADX Period
input ENUM_APPLIED_PRICE AdxAppliedPrice=PRICE_CLOSE; //ADX Applied Price

int GUIXOffset = 20;
int GUIYOffset = 30;

int GUIHeaderXOffset = 20;
int GUIHeaderYOffset = 0;

int GUIColOffset=100;

int ListXOffset = 10;
int ListYOffset = 10;

int ListXMultiplier = 15;
int ListYMultiplier = 10;

int OnInit()
  {
//--- indicator buffers mapping      
   ChartColorSet(CHART_COLOR_BACKGROUND,clrBlack);
   ChartColorSet(CHART_COLOR_FOREGROUND,clrWhite);
   ChartColorSet(CHART_COLOR_GRID,clrNONE);
   ChartColorSet(CHART_COLOR_VOLUME,clrNONE);
   ChartColorSet(CHART_COLOR_CHART_UP,clrNONE);
   ChartColorSet(CHART_COLOR_CHART_DOWN,clrNONE);
   ChartColorSet(CHART_COLOR_CHART_LINE,clrNONE);
   ChartColorSet(CHART_COLOR_CANDLE_BULL,clrNONE);
   ChartColorSet(CHART_COLOR_CANDLE_BEAR,clrNONE);
   ChartColorSet(CHART_COLOR_BID,clrNONE);
   ChartColorSet(CHART_COLOR_ASK,clrNONE);
   ChartColorSet(CHART_COLOR_LAST,clrNONE);
   ChartColorSet(CHART_COLOR_STOP_LEVEL,clrNONE);
   ChartModeSet(CHART_LINE);
  
   EventSetTimer(1);

   DrawHeader();
   DrawScanner();

   return(INIT_SUCCEEDED);
  }
  //+-------------------------------------------------------------------------------------------+
  int deinit()
  {
   ObjectsDeleteAll(ChartID(),INDI_NAME);
   return(0);
  }
//+------------------------------------------------------------------+
//|
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[])                                                                  
//+------------------------------------------------------------------+
 void OnTimer()
 {
      DrawScanner();
     }
  //+------------------------------------------------------------------+
  double getRange(string symbol,int period)
  {
   int DataPeriod=PERIOD_D1;
   int DataBar=iBarShift(symbol,DataPeriod,Time[0]);
   double range = iHigh(symbol, period, DataBar) - iLow(symbol, period, DataBar);
   double point = MarketInfo(symbol, MODE_POINT);
   if(point > 0) return (NormalizeDouble(range / point, 0));
   return 1;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------//

void DrawLabel(string name,int x,int y,string label,int size=9,string font="Arial",color clr=DimGray,string tooltip="")
  {
   name=INDI_NAME+":"+name;
   ObjectDelete(name);
   ObjectCreate(name,OBJ_LABEL,0,0,0);
   ObjectSetText(name,label,size,font,clr);
   ObjectSet(name,OBJPROP_CORNER,0);
   ObjectSet(name,OBJPROP_XDISTANCE,x);
   ObjectSet(name,OBJPROP_YDISTANCE,y);
   ObjectSetString(0,name,OBJPROP_TOOLTIP,tooltip);
//--- justify text
//ObjectSet(name, OBJPROP_ANCHOR, 0);
//ObjectSetString(0, name, OBJPROP_TOOLTIP, tooltip);
//ObjectSet(name, OBJPROP_SELECTABLE, 0);
//---
  }
  //+------------------------------------------------------------------+
//| The function sets chart background color.                        |
//+------------------------------------------------------------------+
bool ChartColorSet(int prop_id,const color clr,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set the chart background color
   if(!ChartSetInteger(chart_ID,prop_id,clr))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
//+------------------------------------------------------------------+
//| Set chart display type (candlesticks, bars or                    |
//| line).                                                           |
//+------------------------------------------------------------------+
bool ChartModeSet(const long value,const long chart_ID=0)
  {
//--- reset the error value
   ResetLastError();
//--- set property value
   if(!ChartSetInteger(chart_ID,CHART_MODE,value))
     {
      //--- display the error message in Experts journal
      Print(__FUNCTION__+", Error Code = ",GetLastError());
      return(false);
     }
//--- successful execution
   return(true);
  }
//+------------------------------------------------------------------+
void DrawScanner()
  {
   Print("=============>DrawScanner");
   for(int x=0; x<SymbolsTotal(true); x++)
     {
      DrawSymbol(SymbolName(x,true),x);
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawSymbol(string symbolName,int symbolIdx)
  {
   int x= GUIXOffset+ListXOffset + ListXMultiplier;
   int y= GUIYOffset+ListYOffset + ListYMultiplier *symbolIdx;

   DrawSymbolColumn(symbolName,x,y,symbolName,FontSize,FontName);

   DrawAdxColumn(symbolName,x+=GUIColOffset,y,symbolName,FontSize,FontName);
   }
   //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

double getPoint(string symbol)
  {
   return MarketInfo(symbol,MODE_POINT);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double getModifier(string symbol)
  {
   int digits=(int)MarketInfo(symbol,MODE_DIGITS);
   double modifier=1;
   if(digits==3 || digits==5)
      modifier=4.0;
   return modifier;
  }
  //|                                                                  |
//+------------------------------------------------------------------+
  void DrawAdxColumn(string symbolName,int x,int y,string text,int fontSize=8,string fontName="Calibri")
  {
   double adxni=iADX(symbolName,AdxTimeframe,AdxPeriod,AdxAppliedPrice,MODE_MINUSDI,0);
   double adxpi=iADX(symbolName,AdxTimeframe,AdxPeriod,AdxAppliedPrice,MODE_PLUSDI,0);
   string tooltip=symbolName+"\n.: "+GetPeriodStr(AdxTimeframe)+" ADX ("+IntegerToString(AdxPeriod)+"):.\nCurrent";
   DrawLabel("adx_"+symbolName,x,y,GetAdxStr(adxni,adxpi),fontSize,fontName,GetAdxColor(adxni,adxpi),tooltip);
  }
  //+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetAdxStr(double adxni,double adxpi)
  {
   if((adxni<=25)||(adxpi<=25))
      return "No Trend";
   if((adxni<=30)||(adxpi<=30))
      return "Weak Trend";
   if((adxni<=40)||(adxpi<=40))
      return "Strong Trend";
   return "Very Strong Trend";
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
color GetAdxColor(double adxni,double adxpi)
  {
   if((adxni<=25)||(adxpi<=25))
      return clrWhite;
   if((adxni<=30)||(adxpi<=30))
      return clrGreen;
   if((adxni<=40)||(adxpi<=40))
      return clrYellow;
   return clrRed;
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawSymbolColumn(string symbolName,int x,int y,string text,int fontSize=8,string fontName="Calibri")
  {
   DrawLabel("lbl_"+symbolName,x,y,text,fontSize,fontName,clrWhite,symbolName);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void DrawHeader()
  {

   string objName="Header";

   int x = GUIXOffset+GUIHeaderXOffset;
   int y = GUIYOffset+GUIHeaderYOffset;

   DrawLabel(objName+"name",x,y,"Name",FontSize,FontName,clrWhite,"Name");
  {
      DrawLabel(objName+",adx",x+=GUIColOffset,y,"ADX ("+GetPeriodStr(AdxTimeframe)+")",FontSize,FontName,clrWhite,"ADX");
     }
     }
string GetPeriodStr(int period)
  {
   string TMz="";
   switch(period)
     {
      case 1:     TMz = "M1";  break;
      case 2:     TMz = "M2";  break;
      case 3:     TMz = "M3";  break;
      case 4:     TMz = "M4";  break;
      case 5:     TMz = "M5";  break;
      case 6:     TMz = "M6";  break;
      case 7:     TMz = "M7";  break;
      case 8:     TMz = "M8";  break;
      case 9:     TMz = "M9";  break;
      case 10:    TMz = "M10"; break;
      case 11:    TMz = "M11"; break;
      case 12:    TMz = "M12"; break;
      case 13:    TMz = "M13"; break;
      case 14:    TMz = "M14"; break;
      case 15:    TMz = "M15"; break;
      case 20:    TMz = "M20"; break;
      case 25:    TMz = "M25"; break;
      case 30:    TMz = "M30"; break;
      case 40:    TMz = "M40"; break;
      case 45:    TMz = "M45"; break;
      case 50:    TMz = "M50"; break;
      case 60:    TMz = "H1";  break;
      case 120:   TMz = "H2";  break;
      case 180:   TMz = "H3";  break;
      case 240:   TMz = "H4";  break;
      case 300:   TMz = "H5";  break;
      case 360:   TMz = "H6";  break;
      case 420:   TMz = "H7";  break;
      case 480:   TMz = "H8";  break;
      case 540:   TMz = "H9";  break;
      case 600:   TMz = "H10"; break;
      case 660:   TMz = "H11"; break;
      case 720:   TMz = "H12"; break;
      case 1440:  TMz = "D1";  break;
      case 10080: TMz = "W1";  break;
      case 43200: TMz = "M1";  break;
     }
   return TMz;
  }
To add comments, please log in or register