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

The indicator looks like this:

CCI Color Levels

Three types of graphical constructions were used for this visual effect:

CCI Color Levels Draw


Indicator Input

  • Averaging period - indicator averaging period;
  • Level UP - the UP level value;
  • Level DOWN - the DOWN level value.

The UP and DOWN levels will be immediately shown in the indicator sub-window:

CCI Color Levels Inputs


How to Access Indicator Data in an Expert Advisor

The DRAW_HISTOGRAM2 style is based on two indicator buffers, that is why we see two Level UP values and two Level Down values in Data Window:

Test CCI Color Levels.png

These values correspond to indicator buffers from 0 to 4 inclusive.

In the Expert Advisor, we create an indicator handle using iCustom:

//--- input parameters
input int      Inp_CCI_ma_period = 14;    // Averaging period 
input double   Inp_CCI_LevelUP   = 90;    // Level UP
input double   Inp_CCI_LevelDOWN =-90;    // Level DOWN
//---
int            handle_iCustom;            // variable for storing the handle of the iCustom indicator 
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create handle of the indicator iCCI
   handle_iCustom=iCustom(Symbol(),Period(),"CCI Color Levels",Inp_CCI_ma_period,Inp_CCI_LevelUP,Inp_CCI_LevelDOWN);
//--- if the handle is not created 
   if(handle_iCustom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code 
      PrintFormat("Failed to create handle of the iCCI indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early 
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }

It is assumed here that the CCI Color Levels indicator is located in [data folder]\MQL5\Indicators\.

How indicator values are obtained (only buffers 0, 2 and 4 are significant):

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double level_up   = iCustomGet(handle_iCustom,0,0);   // buffer #0 -> BufferUpHigh
   double cci        = iCustomGet(handle_iCustom,2,0);   // buffer #2 -> BufferCCI
   double level_down = iCustomGet(handle_iCustom,4,0);   // buffer #4 -> BufferDownLow
   string text="Lelev UP #0: "+DoubleToString(level_up,2)+"\n"+
               "CCI #0: "+DoubleToString(cci,2)+"\n"+
               "Lelev DOWN #0: "+DoubleToString(level_down,2);
   Comment(text);
  }

In the above screenshot, the mouse points to a bar with index 0, "Data Window" with the indicator data is also shown, and EA's information about buffers 0, 2 and 4 is displayed on the chart.

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

EasyAndFastGUI library for creating graphical interfaces EasyAndFastGUI library for creating graphical interfaces

The EasyAndFastGUI library allows creating graphical interfaces for custom MQL programs.

VR Orders History MT5 Lite VR Orders History MT5 Lite

VR Orders History MT5 Lite - a script for downloading trading history in the CSV format.

ZigZagEvgeTrofi ver. 1 ZigZagEvgeTrofi ver. 1

A trading system based on the ZigZag indicator.

SAR index based on MA SAR index based on MA

The SAR indicator calculated based on the iMA (Moving Average, MA) indicator values.