//+------------------------------------------------------------------+
//|                                                         Link.mq4 !
//|                                               Yuriy Tokman (YTG) |
//|                                               https://ytg.com.ua |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "http://forum.tradelikeapro.ru/"
#property version   "1.00"
#property strict
#property indicator_chart_window

#import "shell32.dll"                   
int ShellExecuteW(int hwnd,string Operation,string File,string Parameters,string Directory,int ShowCmd);
#import

input string  site             = "http://forum.tradelikeapro.ru/";
extern ENUM_BASE_CORNER Corner = CORNER_LEFT_UPPER;
extern int    PositionX        = 5;
extern int    PositionY        = 15;
extern string Font             = "Lucida Console";
extern color  FontColor        = Green;
extern int    TextSize         = 10;
extern color  TextColor        = Yellow;
extern int    ButtonSizeX      = 120;
extern int    ButtonSizeY      = 30;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   Button("Link",TextColor,"Visit Website",524,3);
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
   ObjectDelete(0,"Link");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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[])
  {
   //--- return value of prev_calculated for next call
   return(rates_total);
  }

void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam)
  {
   if(id==CHARTEVENT_OBJECT_CLICK)
     {
      string clickedChartObject=sparam;
      if(clickedChartObject=="Link")
        {
         Button("Link",clrSlateGray,"Visit Website",524,3);
         ShellExecuteW(0,"Open",site,"","",1);
        }
      ChartRedraw();
     }
  }
//+------------------------------------------------------------------+
bool Button(string name="",color clr=clrWhite,string _txt="",int x=0,int y=0)
  {
   if(ObjectFind(name)>=0)ObjectDelete(name);

   ResetLastError();
   if(!ObjectCreate(0,name,OBJ_BUTTON,0,0,0))
     {
      Print(name,__FUNCTION__,": Error = ",GetLastError());
      return(false);
     }
   ObjectSetInteger(0,name,OBJPROP_COLOR,clr);
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,FontColor);
   ObjectSetInteger(0,name,OBJPROP_CORNER,Corner);
   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,PositionX);
   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,PositionY);
   ObjectSetInteger(0,name,OBJPROP_XSIZE,ButtonSizeX);
   ObjectSetInteger(0,name,OBJPROP_YSIZE,ButtonSizeY);
   ObjectSetString(0,name,OBJPROP_FONT,Font);
   ObjectSetString(0,name,OBJPROP_TEXT,_txt);
   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,TextSize);
   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);

   return(true);
  }
//+------------------------------------------------------------------+
