Hello developers,
I have MTF CCI indicato. I need one modification. I want to add color fill option between the levels. i.e. I want to fill blue color between +100 to -100.
Can someone help me in this regard?
Thanks.
You can post it as a job in Freelance.
Hello developers,
I have MTF CCI indicato. I need one modification. I want to add color fill option between the levels. i.e. I want to fill blue color between +100 to -100.
Can someone help me in this regard?
Thanks.
I added 12 codes to CCI.mq5, but it didn't fill it. It became like the image below.
Someone, please give me some advice to fix it.
//+------------------------------------------------------------------+ //| CCI.mq5 | //| Copyright 2009-2017, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "2009-2017, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property description "Commodity Channel Index" #include <MovingAverages.mqh> //--- #property indicator_separate_window #property indicator_buffers 6 //@@@@@ It was 4. #property indicator_plots 2 //@@@@@ It was 1. #property indicator_type1 DRAW_LINE #property indicator_color1 LightSeaGreen #property indicator_level1 -100.0 #property indicator_level2 100.0 #property indicator_applied_price PRICE_TYPICAL #property indicator_type2 DRAW_FILLING //@@@@@ Added. #property indicator_color2 Blue //@@@@@ Added. //--- input parametrs input int InpCCIPeriod=14; // Period //--- global variable int ExtCCIPeriod; input double NoTradeZoneDown = -100.0; //@@@@@ Added. input double NoTradeZoneUp = 100.0; //@@@@@ Added. //---- indicator buffer double ExtSPBuffer[]; double ExtDBuffer[]; double ExtMBuffer[]; double ExtCCIBuffer[]; double ExtTZDownBuffer[]; //@@@@@ Added. double ExtTZUpBuffer[]; //@@@@@ Added. //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- check for input value of period if(InpCCIPeriod<=0) { ExtCCIPeriod=14; printf("Incorrect value for input variable InpCCIPeriod=%d. Indicator will use value=%d for calculations.",InpCCIPeriod,ExtCCIPeriod); } else ExtCCIPeriod=InpCCIPeriod; //--- define buffers SetIndexBuffer(0,ExtCCIBuffer); SetIndexBuffer(1,ExtDBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(2,ExtMBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(3,ExtSPBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(4,ExtTZDownBuffer,INDICATOR_CALCULATIONS); //@@@@@ Added. SetIndexBuffer(5,ExtTZUpBuffer,INDICATOR_CALCULATIONS); //@@@@@ Added. //--- indicator name IndicatorSetString(INDICATOR_SHORTNAME,"CCI("+string(ExtCCIPeriod)+")"); //--- indexes draw begin settings PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtCCIPeriod-1); //--- number of digits of indicator value IndicatorSetInteger(INDICATOR_DIGITS,2); //---- OnInit done } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- variables int i,j; double dTmp,dMul=0.015/ExtCCIPeriod; //--- start calculation int StartCalcPosition=(ExtCCIPeriod-1)+begin; //--- check for bars count if(rates_total<StartCalcPosition) return(0); //--- correct draw begin if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartCalcPosition+(ExtCCIPeriod-1)); //--- calculate position int pos=prev_calculated-1; if(pos<StartCalcPosition) pos=StartCalcPosition; //--- main cycle for(i=pos;i<rates_total && !IsStopped();i++) { //--- SMA on price buffer ExtSPBuffer[i]=SimpleMA(i,ExtCCIPeriod,price); //--- calculate D dTmp=0.0; for(j=0;j<ExtCCIPeriod;j++) dTmp+=MathAbs(price[i-j]-ExtSPBuffer[i]); ExtDBuffer[i]=dTmp*dMul; //--- calculate M ExtMBuffer[i]=price[i]-ExtSPBuffer[i]; //--- calculate CCI if(ExtDBuffer[i]!=0.0) ExtCCIBuffer[i]=ExtMBuffer[i]/ExtDBuffer[i]; else ExtCCIBuffer[i]=0.0; ExtTZDownBuffer[i] = NoTradeZoneDown; //@@@@@ Added. ExtTZUpBuffer [i] = NoTradeZoneUp; //@@@@@ Added. //--- } //---- OnCalculate done. Return new prev_calculated. return(rates_total); } //+------------------------------------------------------------------+
#property indicator_separate_window #property indicator_buffers 6 //@@@@@ It was 4. #property indicator_plots 2 //@@@@@ It was 1. #property indicator_type1 DRAW_FILLING //#property indicator_type1 DRAW_LINE #property indicator_color1 clrBlue //#property indicator_color1 LightSeaGreen #property indicator_type2 DRAW_LINE #property indicator_color2 clrLightSeaGreen #property indicator_level1 -100.0 #property indicator_level2 100.0 #property indicator_applied_price PRICE_TYPICAL //#property indicator_type2 DRAW_FILLING //@@@@@ Added. //#property indicator_color2 Blue //@@@@@ Added.
SetIndexBuffer(0,ExtTZUpBuffer,INDICATOR_DATA); //SetIndexBuffer(0,ExtCCIBuffer); SetIndexBuffer(1,ExtTZDownBuffer,INDICATOR_CALCULATIONS); //SetIndexBuffer(1,ExtDBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(2,ExtCCIBuffer,INDICATOR_DATA); //SetIndexBuffer(2,ExtMBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(3,ExtDBuffer,INDICATOR_CALCULATIONS); //SetIndexBuffer(3,ExtSPBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(4,ExtMBuffer,INDICATOR_CALCULATIONS); //SetIndexBuffer(4,ExtTZDownBuffer,INDICATOR_CALCULATIONS); //@@@@@ Added. SetIndexBuffer(5,ExtSPBuffer,INDICATOR_CALCULATIONS); //SetIndexBuffer(5,ExtTZUpBuffer,INDICATOR_CALCULATIONS); //@@@@@ Added.
ありがとうございます。
Thanks to your correct codes, I was able to learn the usage of INDICATOR_DATA and INDICATOR_CALCULATIONS.
I hope our posts will help N_G.
#property copyright "2009-2017, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property description "Commodity Channel Index" #include <MovingAverages.mqh> //--- #property indicator_separate_window #property indicator_buffers 6 //@@@@@ It was 4. #property indicator_plots 2 //@@@@@ It was 1. #property indicator_type1 DRAW_FILLING //@@@@@ correct code #property indicator_color1 clrBlue //@@@@@ correct code #property indicator_type2 DRAW_LINE //@@@@@ correct code #property indicator_color2 clrLightSeaGreen //@@@@@ correct code #property indicator_level1 -100.0 #property indicator_level2 100.0 #property indicator_applied_price PRICE_TYPICAL //--- input parametrs input int InpCCIPeriod=14; // Period //--- global variable int ExtCCIPeriod; input double NoTradeZoneDown = -100.0; //@@@@@ correct code input double NoTradeZoneUp = 100.0; //@@@@@ correct code //---- indicator buffer double ExtSPBuffer[]; double ExtDBuffer[]; double ExtMBuffer[]; double ExtCCIBuffer[]; double ExtTZDownBuffer[]; //@@@@@ correct code double ExtTZUpBuffer[]; //@@@@@ correct code //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- check for input value of period if(InpCCIPeriod<=0) { ExtCCIPeriod=14; printf("Incorrect value for input variable InpCCIPeriod=%d. Indicator will use value=%d for calculations.",InpCCIPeriod,ExtCCIPeriod); } else ExtCCIPeriod=InpCCIPeriod; //--- define buffers SetIndexBuffer(0,ExtTZUpBuffer,INDICATOR_DATA); //@@@@@ correct code SetIndexBuffer(1,ExtTZDownBuffer,INDICATOR_CALCULATIONS); //@@@@@ correct code SetIndexBuffer(2,ExtCCIBuffer,INDICATOR_DATA); //@@@@@ correct code SetIndexBuffer(3,ExtDBuffer,INDICATOR_CALCULATIONS); //@@@@@ correct code SetIndexBuffer(4,ExtMBuffer,INDICATOR_CALCULATIONS); //@@@@@ correct code SetIndexBuffer(5,ExtSPBuffer,INDICATOR_CALCULATIONS); //@@@@@ correct code //--- indicator name IndicatorSetString(INDICATOR_SHORTNAME,"CCI("+string(ExtCCIPeriod)+")"); //--- indexes draw begin settings PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ExtCCIPeriod-1); //--- number of digits of indicator value IndicatorSetInteger(INDICATOR_DIGITS,2); //---- OnInit done } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //--- variables int i,j; double dTmp,dMul=0.015/ExtCCIPeriod; //--- start calculation int StartCalcPosition=(ExtCCIPeriod-1)+begin; //--- check for bars count if(rates_total<StartCalcPosition) return(0); //--- correct draw begin if(begin>0) PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,StartCalcPosition+(ExtCCIPeriod-1)); //--- calculate position int pos=prev_calculated-1; if(pos<StartCalcPosition) pos=StartCalcPosition; //--- main cycle for(i=pos;i<rates_total && !IsStopped();i++) { //--- SMA on price buffer ExtSPBuffer[i]=SimpleMA(i,ExtCCIPeriod,price); //--- calculate D dTmp=0.0; for(j=0;j<ExtCCIPeriod;j++) dTmp+=MathAbs(price[i-j]-ExtSPBuffer[i]); ExtDBuffer[i]=dTmp*dMul; //--- calculate M ExtMBuffer[i]=price[i]-ExtSPBuffer[i]; //--- calculate CCI if(ExtDBuffer[i]!=0.0) ExtCCIBuffer[i]=ExtMBuffer[i]/ExtDBuffer[i]; else ExtCCIBuffer[i]=0.0; ExtTZDownBuffer[i] = NoTradeZoneDown; //@@@@@ correct code ExtTZUpBuffer [i] = NoTradeZoneUp; //@@@@@ correct code //--- } //---- OnCalculate done. Return new prev_calculated. return(rates_total); }
ありがとうございます。
Thanks to your correct codes, I was able to learn the usage of INDICATOR_DATA and INDICATOR_CALCULATIONS.
I hope our posts will help N_G.
I have MTF CCI for mt4 :( which is purchased version. So .mq4 file is not available. Am I screwed?
Most of purchased versions are ".ex4 files" that can't be modified and can't be displayed on MetaEditor.
If it was a ".mq4 file", you could ask the following link for advice to modify as you like.
Most of purchased versions are ".ex4 files" that can't be modified and can't be displayed on MetaEditor.
If it was a ".mq4 file", you could ask the following link for advice to modify as you like.
ありがとうございます。
Thanks to your correct codes, I was able to learn the usage of INDICATOR_DATA and INDICATOR_CALCULATIONS.
I hope our posts will help N_G.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello developers,
I have MTF CCI indicato. I need one modification. I want to add color fill option between the levels. i.e. I want to fill blue color between +100 to -100.
Can someone help me in this regard?
Thanks.