CCI Color Level - MetaTrader 5 Script | Forex Indicator Download - MT4/MT5 Resources




The indicator looks like this:

This visual effect uses three types of graphic structures:

UP and DOWN levels will be immediately displayed in the indicator subwindow:

The DRAW_HISTOGRAM2 style is based on two indicator buffers, that's why we see two Level UP values and two Level Down values in the data window:

These values correspond to the indicator buffer from 0 to 4 (inclusive).
In EA trading, we use to create indicator handle customization :
//--- input parameters Input integer Inp_CCI_ma_period = 14 ; // Average period Enter double Inp_CCI_LevelUP = 90 ; // upgrade Enter double Inp_CCI_LevelDOWN =- 90 ; // Level down //--- Integer Processing_iCustom; // Variable for storing iCustom indicator handle //+------------------------------------------------------------------+ //|Expert initialization function | //+------------------------------------------------------------------+ Integer initialization () { //--- Create a handle to the iCCI indicator handle_i custom = custom ( symbol (), period (), "CCI color level" ,Inp_CCI_ma_period,Inp_CCI_LevelUP,Inp_CCI_LevelDOWN); //--- if handle is not created if (handle_iCustom== INVALID_HANDLE ) { //--- Inform of failure and output error code printing format ( "Unable to create handle of iCCI indicator for symbol %s/%s, error code %d" , symbol (), Enumeration to string ( period ()), getLastError ()); //--- The indicator stops returning early ( initialization failed ); } //--- return ( initialization successful ); }
It is assumed here that the CCI color level indicator is located in [data folder]\MQL5\Indicators\.
How to get the indicator value (valid only for buffers 0, 2 and 4):
//+------------------------------------------------------------------+ //|Expert check function | //+------------------------------------------------------------------+ Blank check () { //--- 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:" + double to string (upgrade, 2 ) + "\n" + "CCI#0:" + double to string (CCI, 2 )+ "\n" + "Lelev DOWN#0:" + double to string (level down, 2 ); comment (text); }
In the screenshot above, the mouse is pointed at the bar with index 0, the "Data Window" with indicator data is also shown, and the EA's information about buffers 0, 2 and 4 is displayed on the chart.
Attachment download
📎 test_cci_color_levels.mq5 (3.65 KB)
📎 cci_color_levels.mq5 (16.7 KB)
Source: MQL5 #19704
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •