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

ChartEvent Test Example - MetaTrader 4용 expert

조회수:
19802
평가:
(14)
게시됨:
2017.05.11 10:36
이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

The "Test_ChartEvent.mq4" Expert Advisor is an example demonstrating the various types of ChartEvent: keyboard keys events, mouse click & move events, custom events. You can press the 'H' key for help and press the 'M' key to enter the MOUSE_MOVE event mode.

The source code works both in MetaTrader 4 and MetaTrader 5.


Function Prototype

  • bool Obj_Create()
  • bool Obj_Delete()
  • bool Obj_Move(int hSens,int vSens) - moves an object.
  • void Print_Info() - prints information about the objects.
  • int MouseMove(int aXX,int aYY,string sState) - handles the mouse move event.


Global Variables

  • int gChartNo=0
  • int gSubWinNo=0
  • string gsObj_Name_selected="" - the name of currently selected object.


Custom Events

Three types of custom events are defined:

  • #define cMyEvent_1 0
  • #define cMyEvent_2 1
  • #define cMyEvent_3_broadcast 2


OnTimer() Function

This function creates the custom ChartEvent periodically. And the function randomly generates these three custom events (cMyEvent_1, cMyEvent_2 and cMyEvent_3_broadcast). In particular, the cMyEvent_3_broadcast event is generated for all open chart windows.


Example of class

Class "CObjectMan" is created to handle the functionality for objects on a chart. Two instances (variables) of the class are declared: gObjectMan1 and gObjectMan2.

The names of the Graphic Objects linked to these two instances are respectively: "Green Button" and "Yellow Button".


Event Processing

void OnChartEvent():

The "CHARTEVENT_KEYDOWN" events:

  1. 4 directional keys (arrows) or the 4 directional keys on the digital panel to move the selected object.
  2. 'H': print the Help information (in expert log window).
  3. 'I': print the positions information of two Objects.
  4. 'M': active the MOUSE_MOVE event.


Custom Events

Print information about these events. Especially for the MyEvent_3_broadcast event.


Object Events

  • CHARTEVENT_OBJECT_CHANGE, CHARTEVENT_OBJECT_DRAG, CHARTEVENT_OBJECT_DELETE - print the corresponding object's name.
  • CHARTEVENT_OBJECT_CLICK - print the name of object being clicked, select its name for moving by the direction keys.


Mouse Events

  • CHARTEVENT_CLICK - print the clicked bar's information: the prices (open, close) and the bar time.
  • CHARTEVENT_MOUSE_MOVE (see: CHART_EVENT_MOUSE_MOVE) - print the information of the covered interval: number of bars, price variation.

ChartEvent Test Example


Demonstration

You can perform the following tests:

  • Click on one of the two objects (Buttons) to select and use the arrow keys to move the selected object.
  • Click on graphic bar and see the information of the bar in the log tab (message).
  • Press the 'M' key to enter the MOUSE_MOVE event mode. Press Ctrl+F to show the crosshair, then perform a drag'n'drop operation. If you do not see the log message, please change the input parameter: "iLogLevel".
TrailingStop TrailingStop

Trailing stop allows you to automatically protect the profits with your positions. It adjusts itself according to the current market rate and the amount of pips you give it to trail behind.

Currency Strength EA Currency Strength EA

This EA opens Buy or Sell trades in strongest or weakest pair. It cannot be backtested. Kindly use it on Demo account first & use it on your own risk.

Tipu MACD Tipu MACD

Tipu MACD is one the popular indicators in the Market. The original code for Tipu MACD is modified by removing compatibility with Tipu Panel. This version of Tipu MACD is open for everyone who is interested in developing an Expert Advisor.

Binary Options Simulated Trading Indicator for MT4 Binary Options Simulated Trading Indicator for MT4

This is a binary options simulated trading indicator on MetaTrader 4 client, novice traders can use to practice trading strategies, program interface have simplified Chinese and English.