거래 로봇을 무료로 다운로드 하는 법을 시청해보세요
당사를 Telegram에서 찾아주십시오!
당사 팬 페이지에 가입하십시오
스크립트가 흥미로우신가요?
그렇다면 링크 to it -
하셔서 다른 이들이 평가할 수 있도록 해보세요
스크립트가 마음에 드시나요? MetaTrader 5 터미널에서 시도해보십시오
조회수:
5902
평가:
(26)
게시됨:
2012.01.05 13:09
업데이트됨:
2016.11.22 07:32
\MQL5\Include\ \MQL5\Indicators\
chartinfo.mq5 (6.32 KB) 조회
MQL5 프리랜스 이 코드를 기반으로 한 로봇이나 지표가 필요하신가요? 프리랜스로 주문하세요 프리랜스로 이동

When using text graphics in the indicators it is often necessary to implement the possibility to change their font type in the indicator input parameters.

The most obvious solution in such a case is to enter a font name manually as a line in the input parameters but it is not very convenient and is prone to errors. More efficient method is to use the custom variables based on enumerations and drop-down menu lists. Presented function module is designed to solve this task.

One example is enough to be able to work with the library. Suppose we have the indicator (ChartInfo_Old.mq5) that displays a text label in one corner of the chart. Here are its input parameters:

//+----------------------------------------------+
//| Indicator input parameters                   |
//+----------------------------------------------+
input string Text="Real";                           // Text label contents
input color  TextColor=Red;                        // Text label color
input int    FontSize=24;                          // Font size
input type_font FontType=Font7;                   // Font type
input ENUM_BASE_CORNER  WhatCorner=CORNER_LEFT_LOWER; // Location corner
input uint Y_=1;                                  // Vertical location

With such a code the indicator input parameters window will have the following look:

ChartInfo_Old 1.00

To free the indicator user from the necessity to manually enter a font name we should insert some changes to the code:

1. Add the contents of the GetFontName.mqh file before the declaration of the indicator input parameters with the help of the #include directive:

//+----------------------------------------------+
// type_font enumeration description             |
// CFontName class description                   | 
//+----------------------------------------------+ 
#include <GetFontName.mqh>

2. Replace the line of the FontType input parameter:

input string FontType="Courier New"; // Font type

with the line

input type_font FontType=Font7; // Font type

Thus, we have changed a bit the meaning of the variable usage. The meaning of the previous variable must be realized in the new string variable that is to be declared at the global level

string sFontType;

Then the FontType variable in the indicator code must be replaced with sFontType. This must be done only in one place:

   SetTLabel(0,"Info_Label",0,WhatCorner,ENUM_ANCHOR_POINT(2*WhatCorner),5,Y_,Text,TextColor,sFontType,FontSize);

Now, sFontType variable must be initialized in the OnInit() block. That can be done with only a couple of code lines:

   CFontName FONT; 
   sFontType=FONT.GetFontName(FontType);

Revised ChartInfo.mq5 indicator can be compiled after that.

Now you can see the changes in the indicator input parameters window:

ChartInfo 1.00

Working with fonts in the indicator input parameters has become much more convenient.

MetaQuotes Ltd에서 러시아어로 번역함.
원본 코드: https://www.mql5.com/ru/code/644

XdinMA XdinMA

The moving average, calculated by using the simplest algebraic combination of two other moving averages with different periods. Smoothing algorithms can be selected out of ten possible versions.

IncERDOnArray IncERDOnArray

CERDOnArray class is designed to calculate the Efficiency Ratio (ER) used in the Adaptive Moving Average (AMA) considering price movement direction. When the price is moving upwards the indicator has positive values, when it is moving downwards, - negative ones.

IncCMOOnArray IncCMOOnArray

CMOOnArray class is designed for calculation of CMO (Chande Momentum Oscillator) values on indicator buffers. The example of use of the CMOOnArray class is presented.

X2MA_HTF_Signal X2MA_HTF_Signal

X2MA_HTF_Signal displays trend directions from three last bars of the X2MA indicator as three graphical objects, colors of which determine a trend direction.