can anyone add alert to this please

To add comments, please log in or register
karthik720
44
karthik720  
//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Carlos Oliveira"
#property link      "https://www.forextradingtools.eu/products/indicators/forex-scanner-furce=mt4terminal"
#property version   "1.00"
#property strict
#property indicator_chart_window
static datetime TimeStamp;

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_APPLIED_PRICE AdxAppliedPrice=PRICE_CLOSE; //ADX Applied Price
input ENUM_TIMEFRAMES AdxTimeframe=PERIOD_M5; //ADX Timeframe
input int AdxPeriod=20; //ADX Period

int GUIXOffset = 20;
int GUIYOffset = 10;

int GUIHeaderXOffset = 20;
int GUIHeaderYOffset = 0;

int GUIColOffset=100;

int ListXOffset = 10;
int ListYOffset = 10;

int ListXMultiplier = 15;
int ListYMultiplier = 10;

int ColumnHeight=44;
int ColumnOffset=200;

datetime TimeMissing;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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[])
  {
//DrawMissingTime();
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
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 yMult = fmod(symbolIdx, ColumnHeight);
        int xMult = symbolIdx/ColumnHeight;             
  
   int x= GUIXOffset+ListXOffset + ListXMultiplier;
   int y= GUIYOffset+ListYOffset + ListYMultiplier * yMult;      
         
   DrawSymbolColumn(symbolName,x + ColumnOffset*xMult,y,symbolName,FontSize,FontName);
   DrawAdxColumn(symbolName,x+=GUIColOffset + ColumnOffset*xMult,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 CCI=iCCI(symbolName,AdxTimeframe,AdxPeriod,AdxAppliedPrice,0);
   double CCIY=iCCI(symbolName,AdxTimeframe,AdxPeriod,AdxAppliedPrice,1);
   string tooltip=symbolName+"\n.: "+GetPeriodStr(AdxTimeframe)+" ADX ("+IntegerToString(AdxPeriod)+"):.\nCurrent("+DoubleToStr(CCI,CCIY)+")";
   DrawLabel("adx_"+symbolName,x,y,GetAdxStr(CCI,CCIY),fontSize,fontName,GetAdxColor(CCI,CCIY),tooltip);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string GetAdxStr(double CCI,double CCIY)
  {
   if((CCIY<100)&&(CCI>100))
      return "buythis";
   if((CCIY> -100)&&(CCI< -100))
      return "sell this";
      return "nothing";
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
color GetAdxColor(double CCI,double CCIY )
  {
   if((CCIY<100)&&(CCI>100))
      return clrWhite;
  if((CCIY> -100)&&(CCI< -100))
      return clrLawnGreen;
       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;
  }
  //+------------------------------------------------------------------+
 
Naguisa Unada
441
Naguisa Unada  
karthik720:

This indicator requires some values of ADX on the setting panel, but it is actually calculating CCI. I have fixed some parts and added alerts.

Files:
karthik720
44
karthik720  
Naguisa Unada:

This indicator requires some values of ADX on the setting panel, but it is actually calculating CCI. I have fixed some parts and added alerts.

thank you .  and alert comes with symbol of chart i use ,not symbol that actually generated alert

i changed SYMBOL()to symbol name but  no difference see THE IMAGES

Files:
Capture2.PNG 141 kb
Capture3.PNG 22 kb
Naguisa Unada
441
Naguisa Unada  

Line 232

DrawLabel("cci_" + symbolName, x, y, GetAdxStr(CCI, CCIY, symbolName), fontSize, fontName, GetAdxColor(CCI, CCIY), tooltip);

Line 237

string GetAdxStr(double CCI, double CCIY, string symbolName)

Line 241, 247

Do_Alert(" Buy Signal", symbolName);

Do_Alert(" Sell Signal", symbolName);

Line 442

void Do_Alert(string doWhat, string symbolName)
karthik720
44
karthik720  

thanks . but it remains the same i can adjust with that.


now if buy signal from  one and sell signal from another happens at same time .the alert is given continuously every second .can u  solve this please

image  attached

Files:
Capture4.PNG 73 kb
Naguisa Unada
441
Naguisa Unada  

To do that, you have to set up and manage an index for each currency pair.

But it's impossible because the original program does not have it.

If a timer is used, an approximate method can be used.

Line 15

input int   TimerInterval = 5;  //Update interval (minutes)

Line 70

EventSetTimer(TimerInterval * 60);
Umar Ismail
15143
Umar Ismail  
karthik720:

thanks . but it remains the same i can adjust with that.


now if buy signal from  one and sell signal from another happens at same time .the alert is given continuously every second .can u  solve this please

image  attached

it can be fixed
you only need to open a job in the job section
then your problem will soon be resolved
:)
Marco vd Heijden
Moderator
10999
Marco vd Heijden  
Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • www.mql5.com
Hi, I need to create an a EA based on a indicator, Which is show simple buy sell colours , When blue shows BUY and when the Red shows SELL. Below features required . EA need to be work on all pairs when I add it into a single chart . Manual TP and SL  Trailing Stop Close all trades when reach the maximum Draw down. Close all trades when reach...
karthik720
44
karthik720  
Umar Ismail:
it can be fixed
you only need to open a job in the job section
then your problem will soon be resolved
:)

thanks man .before this  i didn't know it even existed

To add comments, please log in or register