//+------------------------------------------------------------------+ //| LinearRegressionChannel.mq4 | //| dimicr | //| http://www.signalsbg.com | //| SignalsBG.com - development of trading tools for Metatrader | ////////////////////////////////////////////////////////////////////// #property copyright "Copyright © 2008 signalsbg.com" #property link "http://www.signalsbg.com" #property indicator_chart_window #property indicator_buffers 3 #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_color1 Gold #property indicator_color2 Aqua #property indicator_color3 OrangeRed extern bool UseClose = true; extern int barsToCount=50; double LR_line[]; double Sup_line[]; double Res_line[]; ////////////////////////////////////////////////////////////////////// int init() { //IndicatorShortName("LinearRegressionChannel:"+barsToCount); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,LR_line); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Sup_line); SetIndexEmptyValue(1,0.0); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,Res_line); SetIndexEmptyValue(2,0.0); return(0); } ////////////////////////////////////////////////////////////////////// int deinit() { return(0); } ////////////////////////////////////////////////////////////////////// int start() { // variables double a,b,c, sumy=0.0, sumx=0.0, sumxy=0.0, sumx2=0.0, h=0.0,l=0.0; int x; // calculate linear regression for(int i=0; i h) h = Close[x]-LR_line[x]; if(LR_line[x] - Close[x]> l) l = LR_line[x] - Close[x]; } // Use HIGH - LOW else for(x=0;x h) h = High[x]-LR_line[x]; if(LR_line[x] - Low[x]> l) l = LR_line[x] - Low[x]; } // Drawing support - resistance lines if (h>l) { for(x=0;x