거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Facebook에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
라이브러리

Capture MouseEvents on Chart - MetaTrader 4용 라이브러리

조회수:
16130
평가:
(16)
게시됨:
2009.01.05 07:22
업데이트됨:
2016.11.22 07:32
cfunctions.zip (856.75 KB)
\MQL4\Include\
WinUser32.mqh (26.24 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

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.