I have cr_v1 in my charts and I deleted all of the other versions...Thank you for the detail and carefullness (I had to delete email links in the code below, which is not my work).
/*
----------------------------------------------------------------------
Indicator : cr_v1.mq4
Version : v1.02b
Author : ang/fifo/rjb
Copyright : based on work by
Date : 1-Feb-2007
Contact :
Notes : Plot DAILY curvirank on other timeframes with fib channel
----------------------------------------------------------------------
*/
#include <WinUser32.mqh>
#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 DodgerBlue
#property indicator_color2 DimGray
#property indicator_color3 DimGray
#property indicator_color4 DimGray
#property indicator_color5 DimGray
#property indicator_color6 DimGray
#property indicator_color7 DimGray
double buf1[];
double buf2[];
double buf3[];
double buf4[];
double buf5[];
double buf6[];
double buf7[];
extern int PriceSeriesOHLC_0123 = 0;
extern double BarPeriod = 299;
extern int Order = 2;
extern double FIB_1 = 0.618;
extern double FIB_2 = 0.213;
double ai[10,10],b[10],x[10],sx[20];
double sum;
int p,n,sName=-1,f=0;
double qq,mm,tt;
int ii,jj,kk,ll,nn;
int i=0;
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(0,buf1);
SetIndexStyle(1,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(1,buf2);
SetIndexStyle(2,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(2,buf3);
SetIndexStyle(3,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(3,buf4);
SetIndexStyle(4,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(4,buf5);
SetIndexStyle(5,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(5,buf6);
SetIndexStyle(6,DRAW_LINE,STYLE_DOT,1);
SetIndexBuffer(6,buf7);
if (sName == -1)
sName=TimeCurrent();
p=BarPeriod-1;
nn=Order+1;
return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
ObjectDelete("cr"+sName);
ObjectDelete( "crHI");
ObjectDelete( "crLO");
ObjectDelete( "crFIB1u");
ObjectDelete( "crFIB2u");
ObjectDelete( "crFIB1d");
ObjectDelete( "crFIB2d");
}
//+------------------------------------------------------------------+
int start()
{
int mi;
if (f==1)
p = iBarShift(Symbol(),Period(),ObjectGet("cr"+sName,OBJPROP_TIME1));
sx[1] = p+1;
SetIndexDrawBegin(0,Bars-p-1);
for ( mi=1;mi<=nn*2-2;mi++ )
{
sum=0;
for(n=i;n<=i+p;n++)
sum+=MathPow(n,mi);
sx[mi+1]=sum;
}
for ( mi=1;mi<=nn;mi++ )
{
sum=0.00000;
for(n=i;n<=i+p;n++)
{
if (mi==1)
sum+=GetAppliedPrice(PriceSeriesOHLC_0123,n);
else
sum+=GetAppliedPrice(PriceSeriesOHLC_0123,n)*MathPow(n,mi-1);
}
b[mi]=sum;
}
// Matrix
for(jj=1;jj<=nn;jj++)
for(ii=1; ii<=nn; ii++)
{
kk = ii+jj-1;
ai[ii,jj] = sx[kk];
}
//Gauss
for(kk=1; kk<=nn-1; kk++)
{
ll=0;
mm=0;
for(ii=kk; ii<=nn; ii++)
{
if (MathAbs(ai[ii,kk])>mm)
{
mm=MathAbs(ai[ii,kk]);
ll=ii;
}
}
if (ll==0)
{
MessageBox("xxx-1");
return(0);
}
if (ll!=kk)
{
for(jj=1; jj<=nn; jj++)
{
tt=ai[kk,jj];
ai[kk,jj]=ai[ll,jj];
ai[ll,jj]=tt;
}
tt=b[kk];
b[kk]=b[ll];
b[ll]=tt;
}
for(ii=kk+1;ii<=nn;ii++)
{
qq=ai[ii,kk]/ai[kk,kk];
for(jj=1;jj<=nn;jj++)
{
if (jj==kk)
ai[ii,jj]=0;
else
ai[ii,jj]=ai[ii,jj]-qq*ai[kk,jj];
}
b[ii]=b[ii]-qq*b[kk];
}
}
x[nn]= b[nn]/ai[nn,nn];
for(ii=nn-1;ii>=1;ii--)
{
tt=0;
for(jj=1;jj<=nn-ii;jj++)
{
tt = tt+ai[ii,ii+jj]*x[ii+jj];
x[ii] = (1/ai[ii,ii])*(b[ii]-tt);
}
}
// double hi = iHigh(Symbol(),0,iHighest(Symbol(),0,MODE_HIGH,p,0));
// double lo = iLow(Symbol(),0,iLowest(Symbol(),0,MODE_LOW,p,0));
double dHi=0;
double dLo=0;
int j;
for (n=i;n<=i+p;n++)
{
sum=0;
for(kk=1;kk<=Order;kk++)
sum += x[kk+1]*MathPow(n,kk);
buf1[n] = x[1]+sum;
// calc max hi & lo devation from cr-line
double hi = iHigh(Symbol(),0,n);
double lo = iLow(Symbol(),0,n);
if ( hi > buf1[n] )
{
j = (hi - buf1[n]) / Point;
dHi = MathMax(j,dHi);
}
if ( lo < buf1[n] )
{
j = (buf1[n] - lo) / Point;
dLo = MathMax(j,dLo);
}
}
// msg(""+dHi+":"+dLo);
// plot hi/lo channel
for ( n=0; n<p; n++ )
{
buf4[n] = buf1[n] + dHi * Point;
buf7[n] = buf1[n] - dLo * Point;
buf3[n] = buf1[n] + dHi * FIB_1 * Point;
buf6[n] = buf1[n] - dLo * FIB_1 * Point;
buf2[n] = buf1[n] + dHi * FIB_2 * Point;
buf5[n] = buf1[n] - dLo * FIB_2 * Point;
if ( n == 0 )
{
showLabel( "crHI", "Hi", buf4[n] );
showLabel( "crLO", "Lo", buf7[n] );
showLabel( "crFIB1u", "+"+DoubleToStr(100*FIB_1,1),buf3[n] );
showLabel( "crFIB1d", "-"+DoubleToStr(100*FIB_1,1),buf6[n] );
showLabel( "crFIB2u", "+"+DoubleToStr(100*FIB_2,1),buf2[n] );
showLabel( "crFIB2d", "-"+DoubleToStr(100*FIB_2,1),buf5[n] );
}
}
ObjectCreate("cr"+sName,OBJ_ARROW,0,Time[p],buf1[p]);
ObjectSet("cr"+sName,OBJPROP_ARROWCODE,159);
ObjectSet("cr"+sName,OBJPROP_TIME1,Time[p]);
ObjectSet("cr"+sName,OBJPROP_PRICE1,buf1[p]);
f=1;
return(0);
}
//+------------------------------------------------------------------+
double GetAppliedPrice(int nAppliedPrice, int nIndex)
{
double dPrice;
switch(nAppliedPrice)
{
case 0: dPrice=Open[nIndex]; break;
case 1: dPrice=High[nIndex]; break;
case 2: dPrice=Low[nIndex]; break;
case 3: dPrice=Close[nIndex]; break;
case 4: dPrice=(High[nIndex]+Low[nIndex])/2.0; break;
case 5: dPrice=(High[nIndex]+Low[nIndex]+Close[nIndex])/3.0; break;
case 6: dPrice=(High[nIndex]+Low[nIndex]+2*Close[nIndex])/4.0; break;
default: dPrice=0.0;
}
return(dPrice);
}
//+------------------------------------------------------------------+
void showLabel( string n, string x, double lvl )
{
int i = -2;
if ( ObjectMove(n,0,iTime(Symbol(),0,0),lvl+i*Point) == FALSE )
{
ObjectCreate(n,OBJ_TEXT,0,iTime(Symbol(),0,0),lvl+i*Point);
ObjectSetText(n, x, 8, "Tahoma", Gray);
}
}
//+------------------------------------------------------------------+
void msg( string m )
{
MessageBoxA(NULL ,m,"Trace",MB_OK);
}
//+------------------------------------------------------------------+
Quote from fifo:
Right click on the indicator and let me know its name to make sure we are talking about the same version...