_TRO_Test





//+------------------------------------------------------------------+
//|                                                       linreg.mq4 |

#property indicator_chart_window
#property indicator_buffers 1


extern int LRPeriod=60;

double ind_buffer[], Slope_buffer[] ;
double Slope=0; 
   
int init()
  {

   return(0);
  }
  
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;
   for(i=limit; i>=0; i--) {
      ind_buffer[i]=linreg(LRPeriod,i);
      Slope_buffer[i]= Slope ;
      
   }
   
   
   return(Slope);
  }
//+------------------------------------------------------------------+

double linreg(int p,int i)
   {
   double SumY=0;
   double Sum1=0;

   double c;
   
   for (int x=0; x<=p-1;x++) {
      c=Close[x+i];
      SumY+=c;
      Sum1+=x*c; }
   double SumBars=p*(p-1)*0.5;
   double SumSqrBars=(p-1)*p*(2*p-1)/6;
	double Sum2=SumBars*SumY;
	double Num1=p*Sum1-Sum2;
	double Num2=SumBars*SumBars-p*SumSqrBars;
	if(Num2!=0) Slope=Num1/Num2;
	else Slope=0;
	double Intercept=(SumY-Slope*SumBars)/p;
	double linregval=Intercept+Slope*(p-1);
	return(linregval);
	}



Sample





Analysis



Market Information Used:

Series array that contains close prices for each bar


Indicator Curves created:


Indicators Used:



Custom Indicators Used:

Order Management characteristics:

Other Features: