Miscellaneous
0
Views
0
Downloads
0
Favorites
FX_Snipers_Ergodic_CCI_Trigger_Alert_Fast_
//+------------------------------------------------------------------+
//| Louw Coetzer aka FX Sniper |
//| Copyright © 2004, MetaQuotes Software Corp. |
//| http://www.metaquotes.net/ |
//| FX Sniper's Ergodic CCI & Trigger
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, Fx Sniper."
#property link "http://www.dunno.net/"
//+------------------------------------------------------------------+
//| FX_Sniper's_Ergodic_CCI_&_Trigger_Alert_Fast by mladen |
//+------------------------------------------------------------------+
//2008fxtsd
#property copyright "mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_width1 2
//
//
//
//
//
extern int pq = 2;
extern int pr = 10;
extern int ps = 5;
extern int trigger = 3;
extern bool alertsOn = false;
extern bool alertsMessage = true;
extern bool alertsSound = false;
extern bool alertsEmail = false;
double ErgoCCI[];
double MainCCI[];
double buffer[][8];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0,ErgoCCI); SetIndexLabel(0,"Ergodic CCI");
SetIndexBuffer(1,MainCCI); SetIndexLabel(1,"Trigger Line");
return(0);
}
//
//
//
//
//
#define mtm 0
#define absmtm 1
#define var1 2
#define var2 3
#define var2a 4
#define var2b 5
#define var2c 6
#define var2d 7
//
//
//
//
//
int start()
{
int i,r,limit,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if (ArrayRange(buffer,0) != Bars) ArrayResize(buffer,Bars);
//
//
//
//
//
double alphaPq = 2.0/(1.0+pq);
double alphaPr = 2.0/(1.0+pr);
double alphaPs = 2.0/(1.0+ps);
double alphaTrigger = 2.0/(1.0+trigger);
for(i=limit,r=Bars-limit-1; i >=0; i--,r++)
{
buffer[r][mtm] = Close[i]-Close[i+1];
buffer[r][absmtm] = MathAbs(buffer[r][mtm]);
buffer[r][var1] = buffer[r-1][var1] + alphaPq*(buffer[r][mtm] -buffer[r-1][var1]);
buffer[r][var2] = buffer[r-1][var2] + alphaPr*(buffer[r][var1] -buffer[r-1][var2]);
buffer[r][var2a] = buffer[r-1][var2a] + alphaPq*(buffer[r][absmtm]-buffer[r-1][var2a]);
buffer[r][var2b] = buffer[r-1][var2b] + alphaPr*(buffer[r][var2a] -buffer[r-1][var2b]);
buffer[r][var2c] = buffer[r-1][var2c] + alphaPs*(buffer[r][var2] -buffer[r-1][var2c]);
buffer[r][var2d] = buffer[r-1][var2d] + alphaPs*(buffer[r][var2b] -buffer[r-1][var2d]);
if (buffer[r][var2d]!=0)
ErgoCCI[i] = (500*buffer[r][var2c]/buffer[r][var2d]);
else ErgoCCI[i] = 0;
MainCCI[i] = MainCCI[i+1] + alphaTrigger*(ErgoCCI[i]-MainCCI[i+1]);
}
if (alertsOn)
{
if(MainCCI[1] <= ErgoCCI[1] && MainCCI[0] > ErgoCCI[0]) doAlert("short");
if(MainCCI[1] >= ErgoCCI[1] && MainCCI[0] < ErgoCCI[0]) doAlert("long");
}
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
void doAlert(string doWhat)
{
static string previousAlert="nothing";
static datetime previousTime;
string message;
if (previousAlert != doWhat || previousTime != Time[0]) {
previousAlert = doWhat;
previousTime = Time[0];
//
//
//
//
//
message = StringConcatenate(Symbol()," M",Period()," at ",TimeToStr(TimeLocal(),TIME_SECONDS)," ergodic ",doWhat);
if (alertsMessage) Alert(message);
if (alertsEmail) SendMail(StringConcatenate(Symbol()," ergodic crossing"),message);
if (alertsSound) PlaySound("alert2.wav");
}
}
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
---