Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
FX Sniper's Ergodic_CCI_BB
//+------------------------------------------------------------------+
//| Louw Coetzer aka FX Sniper |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Fx Sniper."
#property link "http://www.dunno.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Blue
#property indicator_color2 White
#property indicator_color3 White
#property indicator_color4 Yellow
#property indicator_color5 Lime
#property indicator_color6 Red
extern int CCI_period=14;
extern int Bollinger_period=50;
extern int Bollinger_deviation = 2;
extern int Bollinger_shift = 0;
//---- indicator buffers
double MainCCI[];
double BUpper[];
double BLower[];
double BMain[];
double cciHup[];
double cciHdn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(8);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(3,DRAW_LINE,STYLE_DOT,1);
SetIndexStyle(4,DRAW_HISTOGRAM,0,1);
SetIndexStyle(5,DRAW_HISTOGRAM,0,1);
SetIndexBuffer(0,MainCCI);
SetIndexLabel(0,"CCI Indicator");
SetIndexBuffer(1,BUpper);
SetIndexBuffer(2,BLower);
SetIndexBuffer(3,BMain);
SetIndexLabel(3,"Bollinger Median Line");
SetIndexBuffer(4,cciHup);
SetIndexBuffer(5,cciHdn);
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("FX Sniper CCI with Bollinger Bands ");
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Calculations |
//+------------------------------------------------------------------+
int start()
{
int limit;
int i;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- main loop
for(i=0; i<Bars; i++)
{
MainCCI[i]= iCCI(NULL,0,CCI_period,PRICE_TYPICAL,i);
}
//---- done
for(i=0; i<Bars; i++)
{
BLower[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_LOWER,i);
BUpper[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_UPPER,i);
BMain[i] = iBandsOnArray(MainCCI,0,Bollinger_period,Bollinger_deviation,Bollinger_shift,MODE_MAIN,i);
}
for(i=0; i<Bars; i++)
{
if (MainCCI[i] >= 0 )
cciHup[i] = MainCCI[i];
else
cciHup[i] = 0;
}
for(i=0; i<Bars; i++)
{
if (MainCCI[i] < 0 )
cciHdn[i] = MainCCI[i];
else
cciHdn[i]=0;
}
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
---