Author: Yuriy Tokman (YTG)
2 Views
0 Downloads
0 Favorites
Link
ÿþ//+------------------------------------------------------------------+

//|                                                         Link.mq4 |

//|                                               Yuriy Tokman (YTG) |

//|                                               https://ytg.com.ua |

//+------------------------------------------------------------------+

#property copyright "Yuriy Tokman (YTG)"

#property link      "https://ytg.com.ua"

#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://ytg.com.ua/";



//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   Button("Link",clrDimGray,"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, int xs=100,int ys=35, int sz = 10){



 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,clrLime);

   ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);

   ObjectSetInteger(0,name,OBJPROP_XSIZE,xs);

   ObjectSetInteger(0,name,OBJPROP_YSIZE,ys);

   ObjectSetString(0,name,OBJPROP_FONT,"Arial Black");

   ObjectSetString(0,name,OBJPROP_TEXT,_txt);

   ObjectSetInteger(0,name,OBJPROP_FONTSIZE,sz);

   ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);

   

   return(true);

}



Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---