Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

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

author EAcpu | 6 reads | 0 comments |

CCI Color Levels - indicator for MetaTrader 5

CCI Color Levels - indicator for MetaTrader 5

CCI Color Levels - indicator for MetaTrader 5

CCI Color Levels - indicator for MetaTrader 5

The indicator looks like this:

CCI Color Levels - indicator for MetaTrader 5

This visual effect uses three types of graphic structures:

CCI Color Levels - indicator for MetaTrader 5

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

CCI Color Levels - indicator for MetaTrader 5

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:

CCI Color Levels - indicator for MetaTrader 5

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

Verification code Refresh