당사 팬 페이지에 가입하십시오
- 조회수:
- 16130
- 평가:
- 게시됨:
- 2009.01.05 07:22
- 업데이트됨:
- 2016.11.22 07:32
-
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
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](https://c.mql5.com/i/code/indicator.png)
Extrapolator is a result of my long-term research in the area of the Timeseries Forecasting.
![Burg Extrapolator](https://c.mql5.com/i/code/expert.png)
The EA uses the method of Burg's linear prediction that was taken from my indicator Extrapolator.mq4.
![Volatility Indicator](https://c.mql5.com/i/code/indicator.png)
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](https://c.mql5.com/i/code/indicator.png)
An indicator of group moving. It shows the difference between two MAs in a separate window.