당사 팬 페이지에 가입하십시오
Clock - MetaTrader 5용 라이브러리
- 조회수:
- 8452
- 평가:
- 게시됨:
- 2018.01.22 09:39
- 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동
The library (Clock.mqh) allows creating analog clocks as graphical resources.
Features
The use of the library is shown in the following source code:
// MQL4&5-code // An example of a cross-platform Expert Advisor, which creates an analog clock on the chart #property strict #include <fxsaber\Clock.mqh> // https://www.mql5.com/en/code/19388 const string ObjName = __FILE__; // The name of the Bitmap object to display the clock const string ResourceName = "::" + ObjName; // The name of the resource where the clock will be formed // Creating the clock from the settings of the corresponding INI file CLOCK Clock("Clocks\\Clock01\\Clock01.INI", ResourceName); void OnINIt() { // Creating a graphical object for displaying the clock ObjectCreate(0, ObjName, OBJ_BITMAP_LABEL, 0, 0, 0); // Specifying the name of the resource where the clock is located ObjectSetString(0, ObjName, OBJPROP_BMPFILE, 0, ResourceName); // Adding the possibility to select the object to drag it with the mouse ObjectSetInteger(0, ObjName, OBJPROP_SELECTABLE, true); // Enabling the second timer to update the clock EventSetTimer(1); } void OnTimer() { // Setting the current time on the clock Clock.SetTime(TimeLocal()); // Refreshing the chart to make changes visible ChartRedraw(); }
The following clock appears on the chart after refresh:
Indicator
The attached cross-platform Clock.mq5 indicator enables the immediate "out of the box" use of the clock.
The indicator implements an interactive change of skins: clock versions (unpack the ZIP archive) are switched using the UP/DOWN keys on the keyboard.
Features
- Raster (not vector) clock;
- Hour hands move without smoothing;
- The library can be used in MetaTrader 4/5.
How the clock is formed
The originals of clock are taken from the web by searching for flash clock (swf files are available in the ZIP), which are convenient because they contain required graphical representations of clock face, hands, etc. You can use any other sources. For example, you can find ready vector files or draw them yourself.
INI files (see examples) set the parameters of clock formation layer by layer. The below settings can be edited in any text editor
ImageName = ClockFace.bmp BoundX = 0 // the X coordinate of the zero point inside the bmp image (layer) BoundY = 0 // the Y coordinate of the zero point inside the bmp image (layer) X = 0 // the X coordinate of the zero point inside the image being formed of layers Y = 0 // the Y coordinate of the zero point inside the image being formed of layers Rotate = 0 // Speed of rotation A = 100% // The value of the Alpha channel used R = 100% // The value of the Red channel used G = 100% // The value of the Green channel used B = 100% // The value of the Blue channel used
The lower the position of a layer description in the list, the higher it is than previously described layers. There is no special limitation on the number of layers.
This image construction method allows using the library for forming any static/dynamic objects, not only the clock. To provide the clock dynamics, we only needed to set rotation. However, other types of movement (such as shift, scaling, etc.) can be added to the code in just a few lines. The attached source code provides an example of how to implement this approach when describing images.
As for the clock, the layer-by-layer operation allowed us to implement shadows of hands and illumination (as is done in flash clocks).
If you want to make the dial transparent, you should set the Alpha channel in the corresponding INI file less than 100%:
At the time of publication, there were no analog clocks in the Market. I've found this variant in the Code Base.
The new feature of this library is LAYER::Rotate used for rotation. Probably, this function will lead to the creation of third-party solutions based on dynamic graphical resources similar to the clock.
MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/19388
The Expert Advisor is based on Bill Williams' strategy.
KI_signals_v2A trend indicator, which receives trade signals from the XMACD histogram.
The Expert Advisor tracks positions of all symbols with all magic numbers. If a position has been open for "Waiting for seconds" and its profit has reached "Take Profit" points, the EA closes the position. If the profit has not reached "Take Profit" points, the EA moves the take profit level.
DtmAn oscillator in the DRAW_FILLING style, using digital filters.