Author: Copyright 2021, Alexandermax Software
0 Views
0 Downloads
0 Favorites
Demomause
ÿþ//+------------------------------------------------------------------+

//|                                                   Demo_mause.mq4 |

//|                            Copyright 2021, Alexandermax Software |

//|                       https://www.mql5.com/ru/users/alexandermax |

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

#property copyright "Copyright 2021, Alexandermax Software"

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

#property version   "1.00"

#property strict

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

//| Expert initialization function                                   |

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

string obj = "My_Object";



int OnInit()

  {

//--- create timer

   EventSetMillisecondTimer(200);

   ChartSetInteger(ChartID(),CHART_EVENT_MOUSE_MOVE,true); //A>>1I05B :>>@48=0BK <KH8

   

   

//---

   return(INIT_SUCCEEDED);

  }

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

//| Expert deinitialization function                                 |

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

void OnDeinit(const int reason)

  {

//--- destroy timer

   EventKillTimer();

   ObjectsDeleteAll(0, obj);

   

  }

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

//| Expert tick function                                             |

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

void OnTick()

  {

  

 

   

  }

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

//| Timer function                                                   |

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

void OnTimer()

  {

   //A>740=85 >1J5:B0

   ObjectCreate(0,obj,OBJ_RECTANGLE,0,iTime(Symbol(),PERIOD_CURRENT,50),Bid,iTime(Symbol(),PERIOD_CURRENT,0),Ask+250*Point);

   ObjectSetInteger(0, obj, OBJPROP_BACK, true);  

   

  }

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

//| ChartEvent function                                              |

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

void OnChartEvent(const int id,

                  const long &lparam,

                  const double &dparam,

                  const string &sparam)

  {

if (id == CHARTEVENT_MOUSE_MOVE)//A>1KB85 ?5@5<5I5=85 <KH8

        {

          //?>;CG05< :>>@48=0BK  x = lparam; y=dparam     

          if(Rollover ((int)lparam,(int)dparam,"My_Object",5)==true)

          ObjectSetInteger(0,"My_Object", OBJPROP_COLOR, clrDeepSkyBlue);

          else 

          ObjectSetInteger(0,"My_Object", OBJPROP_COLOR, clrBlue);

        }

   

  }



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

//|     DC=:F8O 4;O >1=0@C65=85O <8H8 =04 >1J5:B>< ?@O<>C3>;L=8:     |                                                       |

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

bool Rollover(int mouse_x, int mouse_y, string object, int fat_maus=0)

  {

   bool cross = false;             //?5@5A5G5=85

   int x1,x2,y1,y2;                //4;O ?>;CG5=8O 8A:;<KE :>>@48=0B

   int ax,bx,cx,dx,ay,by,cy,dy;    //4;O ?>;CG5=8O :>>@48=0B >1J5:B0



//?>;CG8< 40==K5 F5=K 8 2@5<5=8 ?> >1J5:BC

   double   p1 = ObjectGet(object,OBJPROP_PRICE1);

   double   p2 = ObjectGet(object,OBJPROP_PRICE2);

   datetime t1 = (datetime)ObjectGet(object,OBJPROP_TIME1);

   datetime t2 = (datetime)ObjectGet(object,OBJPROP_TIME2);



//?>;CG8< :>>@48=0BK 4;O :064>9 B>G:8

   ChartTimePriceToXY(0,0,t1,p1,ax,ay);

   ChartTimePriceToXY(0,0,t2,p1,bx,by);

   ChartTimePriceToXY(0,0,t2,p2,cx,cy);

   ChartTimePriceToXY(0,0,t1,p2,dx,dy);



// =094Q< :@09=85 :>>@48=0BK ?> x 8 y

   if(MathMin(ax,bx) < MathMin(cx,dx))

      x1=MathMin(ax,bx);//5A;8 ?>;CG8;>AL A@02=8BL <K =0H;8 <8=8<0;L=K9 x1

   else

      x1 = MathMin(ax,cx);//5A;8 A@02=8LBL =5 ?>;CG8;>AL 7=0G8B 1K;8 =0 >4=>9 (x) :>@48=0B5, ?>AB028< 4@3CN :>>@48=0BC 8 70?8H5< <8=8<C< 2 x1

      

   if(MathMax(ax,bx) > MathMax(cx,dx))

      x2=MathMax(ax,bx);

   else

      x2 = MathMax(ax,cx); //0=0;>38G=> 4;O >AB0;L=>3>

      

   if(MathMin(ay,by) < MathMin(cy,dy))

      y1=MathMin(ay,by);

   else

      y1 = MathMin(ay,cy); //0=0;>38G=> 4;O >AB0;L=>3>

      

   if(MathMax(ay,by) > MathMax(cy,dy))

      y2=MathMax(ay,by);

   else

      y2 = MathMax(ay,cy); //0=0;>38G=> 4;O >AB0;L=>3>





   //fat_maus  - MB> ?@8?CA: : <KH8=K< :>>@48=0B0< GB>1K =02545=85 A@010BK20;> GCBL @0=LH5 (=0?@8<5@ 5 ?8:A8;59 >B 3@0=8FK) 8;8 >AB028< 0 ?> C<>;G0=8N



//4>1028< MB> G8A;> ?8:A5;59 ?> 3@0=8F5 >1J5:B0

   x1=x1-fat_maus;

   x2=x2+fat_maus;

   y1=y1-fat_maus;

   y2=y2+fat_maus;



//A@02=8< :>>@48=0BK >1L5:B0 A ?>;>65=85< <KH8

//5A;8 >=0 =04 >1L5:B>B><, B> <KHL 2 <KH5;>2:5 25@=Q< cross = true



   if((mouse_x<x2 && mouse_x>x1)    // ?> (x) :>>@48=0B0< 2 7>=5 >1J5:B0

      &&(mouse_y<y2 && mouse_y>y1)) // ?> (y) :>>@48=0B0< B>65 2 7>=5 >1J5:B0

      cross = true; //<KHL =04 >1L5:B><



   return(cross);

  }

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

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