Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
CCI-OnArray_
//+------------------------------------------------------------------+
//| Custom CCI.mq4 |
//| Copyright © 2010, MetaQuotes Software Corp. |
//| http://codebase.mql4.com/ |
//| Made in Russia. Modification by Victor Lukashuk aka lukas1 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link "lukas1@ngs.ru"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Black
#property indicator_maximum 300
#property indicator_minimum -300
#property indicator_level1 -100
#property indicator_level2 0
#property indicator_level3 100
#property indicator_levelcolor LightSlateGray
//---- indicator parameters
extern int MA=6;
extern int mode =3;
/*MODE_SMA 0 Ïðîñòîå ñêîëüçÿùåå ñðåäíåå
MODE_EMA 1 Ýêñïîíåíöèàëüíîå ñêîëüçÿùåå ñðåäíåå
MODE_SMMA 2 Ñãëàæåííîå ñêîëüçÿùåå ñðåäíåå
MODE_LWMA 3 Ëèíåéíî-âçâåøåííîå ñêîëüçÿùåå ñðåäíåå */
extern int price=5;
/*PRICE_CLOSE 0 Öåíà çàêðûòèÿ
PRICE_OPEN 1 Öåíà îòêðûòèÿ
PRICE_HIGH 2 Ìàêñèìàëüíàÿ öåíà
PRICE_LOW 3 Ìèíèìàëüíàÿ öåíà
PRICE_MEDIAN 4 Ñðåäíÿÿ öåíà, (high+low)/2
PRICE_TYPICAL 5 Òèïè÷íàÿ öåíà, (high+low+close)/3
PRICE_WEIGHTED 6 Âçâåøåííàÿ öåíà çàêðûòèÿ, (high+low+close+close)/4 */
extern int CCI=14;
//---- indicator buffers
double Buf0[];
double Buf1[];
double Buf2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
if(MA<1) MA=1;
IndicatorDigits(1);
IndicatorBuffers(3);
//---- indicator buffers mapping
SetIndexBuffer(0,Buf0);
SetIndexBuffer(1,Buf1);
SetIndexBuffer(2,Buf2);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_LINE);
SetIndexDrawBegin(0,MA+CCI);
SetIndexDrawBegin(1,MA+CCI);
SetIndexDrawBegin(2,MA+CCI);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("CCI-OnArray (CCI("+CCI+"),Ma("+MA+") ) ");
SetIndexLabel(0,"CCI("+CCI+"),Ma("+MA+") \n");
SetIndexLabel(1,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence |
//+------------------------------------------------------------------+
int start()
{
int limit,i;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
if(counted_bars==0) limit--;
//---- MA counted in the last buffer
for(i=limit; i>=0; i--)
Buf2[i]=iMA(NULL,0,MA,0,mode,price,i);
//---- CCI counted in the free buffer
for(i=limit; i>=0; i--){
Buf0[i]=iCCIOnArray(Buf2,Bars,CCI,i);
Buf1[i]=iCCIOnArray(Buf2,Bars,CCI,i);
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---