Schau, wie man Roboter kostenlos herunterladen kann

Interessantes Skript?
Veröffentliche einen Link auf das Skript, damit die anderen ihn auch nutzen können

Hat Ihnen das Skript gefallen?
Bewerten Sie es im Terminal MetaTrader 5


Capture MouseEvents on Chart - Bibliothek für den MetaTrader 4

Russell | German English Español Português 日本語 Русский

Stimmen: 14
2009.01.05 07:22
2016.11.22 07:32 (856.75 KB)



The some functions in the cfunctions.dll ( attached ) are wrappers for two user32.dll functions. With those in combination with the extension of WinUser32.mqh will enable you to read the mouseevents on the chart. After which it becomes easy the attach some action to it. In the example I created a button on chart, which will print "right away" ones pressed. It can take some time before the message prints for two reasons.

  • Bid has changed -> Strategy take highest "interupt".
  • Polling is at low rate; polling rate becomes smaller after a each period of mouse inactivity.

In the example I mainly focussed on not slowing down the trading strategy (on price action).


//|                                                    mousetest.mq4 |
//|                                Copyright © 2008, Berkers Trading |
//|                               |
#property copyright "Copyright © 2008, Berkers Trading"
#property link      ""

#include <WinUser32.mqh> //adjusted!!
#include <cfunctions_v1.0.1.mqh>

int init(){
           " | Mail Report  |\n",

int deinit(){

int start(){

int startStrategy(){
   Print("Run Strat");

bool eventPoller(){
   int iCoords[2], iCoordsPrevious[2],hWin,liKS;
   hWin = WindowHandle( Symbol(), Period()); 
   static double ldBid, ldPollTime;
   int liTC, liCompareTime;
   Print("Start Polling Mouse");
      if (Bid != ldBid){
      ldBid = Bid;
      liTC = TimeCurrent();
      if (liTC > liCompareTime){
         MT4_ScreenToClient(hWin, iCoords);        
         if (iCoords[0] > 0 && iCoords[0] < 170 && iCoords[1] > 0 && iCoords[1] < 50){
            liKS = GetAsyncKeyState(VK_LBUTTON);
           // Print(iCoords[0]," ",iCoords[1]," ",hWin," ",liKS);
            if (liKS != 0){
               Print("right away!");
         //mouse inactive
         if (iCoordsPrevious[0] == iCoords[0] && iCoordsPrevious[1] == iCoords[1]){ 
            if(ldPollTime < 10){
               ldPollTime+= 0.01;
         } else {
            ldPollTime = 0;
         liCompareTime = liTC+MathRound(ldPollTime);
         iCoordsPrevious[0] = iCoords[0];
         iCoordsPrevious[1] = iCoords[1];
      } else {


  • WinUser32 had some adjustments.
  • eventPoller() is by no means developed; it and example, it works for me
  • polling is frequention is lowered if the mouse is inactive ( can take up to 10 secs) before it comes responsive
  • c++ source + dll avaible in zip ( cfunctions.dll -> libraries )
Extrapolator Extrapolator

Extrapolator is a result of my long-term research in the area of the Timeseries Forecasting.

Burg Extrapolator Burg Extrapolator

The EA uses the method of Burg's linear prediction that was taken from my indicator Extrapolator.mq4.

Volatility Indicator Volatility Indicator

Judging by the code of indicator, it calculates the difference between the maximum maximums and minimum minimums of prices of the candlesticks for the last 20 bars (parameter). The result is displayed in points.

Multy_MA Multy_MA

An indicator of group moving. It shows the difference between two MAs in a separate window.