Author: Yuriy Tokman (YTG)
Indicators Used
Relative strength index
0 Views
0 Downloads
0 Favorites
Table In
ÿþ//+------------------------------------------------------------------+

//|                                             Table Indicator .mq4 |

//|                                               Yuriy Tokman (YTG) |

//|                       https://www.mql5.com/ru/users/satop/seller |

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

#property copyright "Yuriy Tokman (YTG)"

#property link      "https://www.mql5.com/ru/users/satop/seller"

#property version   "1.00"

#property strict



int qwe = 0;

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

//| Expert initialization function                                   |

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

int OnInit()

  { 

//--- create timer

   EventSetMillisecondTimer(100);

   LabelCreate(0,"ytg_q",0,20,30,CORNER_LEFT_UPPER,"v","Wingdings",10,clrRed,0.0);

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//--- destroy timer

   GetDellName();

   EventKillTimer();

   Comment("");

  }

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

//| Timer function                                                   |

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

void OnTimer()

  {

//---

   if(qwe<0)

      qwe=0;

   if(qwe>100)

      qwe=100;

   int x = 0;

   int y = 0;



   if(ObjectFind(0,"ytg_q")!=-1)

     {

      x = (int)ObjectGetInteger(0,"ytg_q",OBJPROP_XDISTANCE);

      y = (int)ObjectGetInteger(0,"ytg_q",OBJPROP_YDISTANCE);

     }

   if(x>0 && y>0)

     {

      LabelCreate(0,"ytg_w",0,x,y+15,CORNER_LEFT_UPPER,"y","Wingdings",10,clrRed,0.0,ANCHOR_LEFT_UPPER,true,false);

      LabelCreate(0,"ytg_e",0,x,y+25,CORNER_LEFT_UPPER,"y","Wingdings",10,clrRed,180,ANCHOR_RIGHT_LOWER,true,false);



      ButtonCreate(0,"ytg_r",0,x+13,y,      60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "M1="+rsi(PERIOD_M1)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_t",0,x+73+qwe*10,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "M5="+rsi(PERIOD_M5)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_y",0,x+133+qwe*20,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "M15="+rsi(PERIOD_M15)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_u",0,x+193+qwe*30,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "M30="+rsi(PERIOD_M30)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);

      //+60

      ButtonCreate(0,"ytg_i",0,x+253+qwe*40,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "H1="+rsi(PERIOD_H1)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_o",0,x+313+qwe*50,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "H4="+rsi(PERIOD_H4)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_p",0,x+373+qwe*60,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "D1="+rsi(PERIOD_D1)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_a",0,x+433+qwe*70,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "W1="+rsi(PERIOD_W1)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);



      ButtonCreate(0,"ytg_s",0,x+493+qwe*80,y,60+qwe*10,40+qwe,CORNER_LEFT_UPPER,

                   "MN="+rsi(PERIOD_MN1)

                   ,"Arial",10+qwe,clrBlack,clrLightBlue,clrNONE,false,true);}

  }

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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

//---

//--- =060B85 <KH:>9 =0 3@0D8G5A:>< >1J5:B5

   if(id==CHARTEVENT_OBJECT_CLICK)

     {

      if(sparam=="ytg_w")

         qwe+=5;

      if(sparam=="ytg_e")

         qwe-=5;

     }

  }

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

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

//| !>7405B B5:AB>2CN <5B:C                                          |

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

bool LabelCreate(const long              chart_ID=0,               // ID 3@0D8:0

                 const string            name="Label",             // 8<O <5B:8

                 const int               sub_window=0,             // =><5@ ?>4>:=0

                 const int               x=0,                      // :>>@48=0B0 ?> >A8 X

                 const int               y=0,                      // :>>@48=0B0 ?> >A8 Y

                 const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

                 const string            text="Label",             // B5:AB

                 const string            font="Arial",             // H@8DB

                 const int               font_size=10,             // @07<5@ H@8DB0

                 const color             clr=clrRed,               // F25B

                 const double            angle=0.0,                // =0:;>= B5:AB0

                 const ENUM_ANCHOR_POINT anchor=ANCHOR_LEFT_UPPER, // A?>A>1 ?@82O7:8

                 const bool              back=true,               // =0 704=5< ?;0=5

                 const bool              selection=true,          // 2K45;8BL 4;O ?5@5<5I5=89

                 const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                 const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

   if(ObjectFind(chart_ID,name)>=0)

      ObjectDelete(chart_ID,name);

//--- A>74048< B5:AB>2CN <5B:C

   if(!ObjectCreate(chart_ID,name,OBJ_LABEL,sub_window,0,0))

     {

      Print(__FUNCTION__,

            ": =5 C40;>AL A>740BL B5:AB>2CN <5B:C! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CAB0=>28< :>>@48=0BK <5B:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< B5:AB

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- CAB0=>28< C3>; =0:;>=0 B5:AB0

   ObjectSetDouble(chart_ID,name,OBJPROP_ANGLE,angle);

//--- CAB0=>28< A?>A>1 ?@82O7:8

   ObjectSetInteger(chart_ID,name,OBJPROP_ANCHOR,anchor);

//--- CAB0=>28< F25B

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O <5B:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//----

//----

void GetDellName(string name_n="ytg_")

  {

   string vName;

   for(int i=ObjectsTotal()-1; i>=0; i--)

     {

      vName=ObjectName(i);

      if(StringFind(vName,name_n)!=-1)

         ObjectDelete(vName);

     }

  }

//----+

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

//| !>7405B :=>?:C                                                   |

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

bool ButtonCreate(const long              chart_ID=0,               // ID 3@0D8:0

                  const string            name="Button",            // 8<O :=>?:8

                  const int               sub_window=0,             // =><5@ ?>4>:=0

                  const int               x=0,                      // :>>@48=0B0 ?> >A8 X

                  const int               y=0,                      // :>>@48=0B0 ?> >A8 Y

                  const int               width=50,                 // H8@8=0 :=>?:8

                  const int               height=18,                // 2KA>B0 :=>?:8

                  const ENUM_BASE_CORNER  corner=CORNER_LEFT_UPPER, // C3>; 3@0D8:0 4;O ?@82O7:8

                  const string            text="Button",            // B5:AB

                  const string            font="Arial",             // H@8DB

                  const int               font_size=10,             // @07<5@ H@8DB0

                  const color             clr=clrBlack,             // F25B B5:AB0

                  const color             back_clr=C'236,233,216',  // F25B D>=0

                  const color             border_clr=clrNONE,       // F25B 3@0=8FK

                  const bool              state=false,              // =060B0/>B60B0

                  const bool              back=false,               // =0 704=5< ?;0=5

                  const bool              selection=false,          // 2K45;8BL 4;O ?5@5<5I5=89

                  const bool              hidden=true,              // A:@KB 2 A?8A:5 >1J5:B>2

                  const long              z_order=0)                // ?@8>@8B5B =0 =060B85 <KHLN

  {

//--- A1@>A8< 7=0G5=85 >H81:8

   ResetLastError();

   if(ObjectFind(chart_ID,name)>=0)

      ObjectDelete(chart_ID,name);

//--- A>74048< :=>?:C

   if(!ObjectCreate(chart_ID,name,OBJ_BUTTON,sub_window,0,0))

     {

      Print(__FUNCTION__,

            ": =5 C40;>AL A>740BL :=>?:C! >4 >H81:8 = ",GetLastError());

      return(false);

     }

//--- CAB0=>28< :>>@48=0BK :=>?:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XDISTANCE,x);

   ObjectSetInteger(chart_ID,name,OBJPROP_YDISTANCE,y);

//--- CAB0=>28< @07<5@ :=>?:8

   ObjectSetInteger(chart_ID,name,OBJPROP_XSIZE,width);

   ObjectSetInteger(chart_ID,name,OBJPROP_YSIZE,height);

//--- CAB0=>28< C3>; 3@0D8:0, >B=>A8B5;L=> :>B>@>3> 1C4CB >?@545;OBLAO :>>@48=0BK B>G:8

   ObjectSetInteger(chart_ID,name,OBJPROP_CORNER,corner);

//--- CAB0=>28< B5:AB

   ObjectSetString(chart_ID,name,OBJPROP_TEXT,text);

//--- CAB0=>28< H@8DB B5:AB0

   ObjectSetString(chart_ID,name,OBJPROP_FONT,font);

//--- CAB0=>28< @07<5@ H@8DB0

   ObjectSetInteger(chart_ID,name,OBJPROP_FONTSIZE,font_size);

//--- CAB0=>28< F25B B5:AB0

   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);

//--- CAB0=>28< F25B D>=0

   ObjectSetInteger(chart_ID,name,OBJPROP_BGCOLOR,back_clr);

//--- CAB0=>28< F25B 3@0=8FK

   ObjectSetInteger(chart_ID,name,OBJPROP_BORDER_COLOR,border_clr);

//--- >B>1@078< =0 ?5@54=5< (false) 8;8 704=5< (true) ?;0=5

   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);

//--- ?5@52545< :=>?:C 2 7040==>5 A>AB>O=85

   ObjectSetInteger(chart_ID,name,OBJPROP_STATE,state);

//--- 2:;NG8< (true) 8;8 >B:;NG8< (false) @568< ?5@5<5I5=8O :=>?:8 <KHLN

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);

   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);

//--- A:@>5< (true) 8;8 >B>1@078< (false) 8<O 3@0D8G5A:>3> >1J5:B0 2 A?8A:5 >1J5:B>2

   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);

//--- CAB0=>28< ?@8>@8B5B =0 ?>;CG5=85 A>1KB8O =060B8O <KH8 =0 3@0D8:5

   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

//--- CA?5H=>5 2K?>;=5=85

   return(true);

  }

//----

string rsi(ENUM_TIMEFRAMES TF = PERIOD_CURRENT)

  {

   string txt = "";

   txt = DoubleToString(iRSI(Symbol(),TF,14,PRICE_CLOSE,0),0);

   if(iRSI(Symbol(),TF,14,PRICE_CLOSE,0)>iRSI(Symbol(),TF,14,PRICE_CLOSE,1))

      txt += ShortToString(0x2191);

   else

      txt += ShortToString(0x2193);

   return(txt);

  }

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

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 ---