無料でロボットをダウンロードする方法を見る
Twitter上で私たちを見つけてください。
私たちのファンページに参加してください
興味深いスクリプト?
それではリンクにそれを投稿してください。-
他の人にそれを評価してもらいます
記事を気に入りましたか?MetaTrader 5ターミナルの中でそれを試してみてください。
ライブラリ

Capture MouseEvents on Chart - MetaTrader 4のためのライブラリ

ビュー:
15813
評価:
(16)
パブリッシュ済み:
2009.01.05 07:22
アップデート済み:
2016.11.22 07:32
cfunctions.zip (856.75 KB)
\MQL4\Include\
このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動

Author:

Russell

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


Code:

//+------------------------------------------------------------------+
//|                                                    mousetest.mq4 |
//|                                Copyright © 2008, Berkers Trading |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Berkers Trading"
#property link      "http://www.metaquotes.net"

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

int init(){
   Print(MT4_cfunctions_version());
   Comment("+-----------------+\n",
           " | Mail Report  |\n",
           "+-----------------+");
   
   return(0);
}

int deinit(){
   return(0);
}

int start(){
   eventPoller();
}

int startStrategy(){
   Print("Run Strat");
   return(0);
}

bool eventPoller(){
   
   int iCoords[2], iCoordsPrevious[2],hWin,liKS;
   hWin = WindowHandle( Symbol(), Period()); 
   static double ldBid, ldPollTime;
   int liTC, liCompareTime;
   
   Print("Start Polling Mouse");
   while(1==1){
      RefreshRates();
      if (Bid != ldBid){
         startStrategy();
      }
      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 {
         Sleep(90);
      }
      Sleep(10);     
   }
}

Heads-up:

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