Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
CCI_TriggerBars
//+------------------------------------------------------------------+
//| CCITrigger |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, GideonSmolders."
#property link ""
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Olive
#property indicator_color2 FireBrick
#property indicator_color3 DarkKhaki
#property indicator_maximum 1
#property indicator_minimum 0
//---- indicator buffers
string signal;
double BUYtrend[];
double SELLtrend[];
double NEUTRAL[];
double cci_open[];
double cci_close[];
double TriggerCCI[];
double MainCCI[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
IndicatorBuffers(7);
//---- drawing settings
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_HISTOGRAM);
SetIndexBuffer(3,cci_open);
SetIndexLabel(3,"CCIopen");
SetIndexBuffer(4,cci_close);
SetIndexLabel(4,"CCIclose");
SetIndexBuffer(5,TriggerCCI);
SetIndexLabel(5,"Trigger CCI");
SetIndexBuffer(6,MainCCI);
SetIndexLabel(6,"Main Line");
SetIndexBuffer(0,BUYtrend);
SetIndexLabel(0,"BUY");
SetIndexBuffer(1,SELLtrend);
SetIndexLabel(1,"SELL");
SetIndexBuffer(2,NEUTRAL);
SetIndexLabel(2,"NEUTRAL");
//---- name for DataWindow and indicator subwindow label
//---- 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
//---- done
for(i=0; i <= Bars; i++)
{
cci_open[i]= iCCI(Symbol(),60,7,PRICE_OPEN,i);
}
for(i=0; i <= Bars; i++)
{
cci_close[i] = iCCI(Symbol(),60,7,PRICE_CLOSE,i);
}
for(i=0; i <= Bars; i++)
{
TriggerCCI[i]= iMAOnArray(cci_open,0,5,0,MODE_SMMA,i);
}
for(i=0; i <= Bars; i++)
{
MainCCI[i]= iMAOnArray(cci_open,0,5,1,MODE_LWMA,i);
}
for(i=0; i<=Bars; i--)
{
if(MainCCI[i] > TriggerCCI[i] /*&& cci_open[i]<MainCCI[i] && cci_close[i]<MainCCI[i] && cci_close[i]<cci_open[i]*/)
{ signal = "SELL";
BUYtrend[i] = 0;
SELLtrend[i] = 1;
NEUTRAL[i] = 0 ;}
if (MainCCI[i] < TriggerCCI[i] /*&& cci_open[i]>MainCCI[i] && cci_close[i]>MainCCI[i] && cci_close[i]>cci_open[i]*/)
{signal = "BUY";
BUYtrend[i] = 1;
SELLtrend[i] = 0;
NEUTRAL[i] = 0 ;}
else
{signal = "NEUTRAL";
BUYtrend[i] = 0;
SELLtrend[i] = 0;
NEUTRAL[i] = 1 ;}
IndicatorShortName("CCITrigger: "+signal);
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
---