//+------------------------------------------------------------------+
//|                 NonLinearRegression_StdDev_Channels_StopLoss.mq4 |
//|                                                      Version 1.0 |
//|------------------------------------------------------------------|
//|                    Copyright © 2011, Mr.WT && ANG3110 && kradio5 |
//|                                           http://www.wcs-sth.ru/ |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2011, Mr.WT && ANG3110 && kradio5"
#property link      "http://www.wcs-sth.ru/"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Aqua
#property indicator_color2 OrangeRed
//+------------------------------------------------------------------+
#import  "NLR_Mix_Library.ex4"
void     Deinit();
void     Create_SDC(int a, color& b[], double c, double d, double e);
void     Create_NLR(color& c[], double d, double e, int f, int g, bool h, bool i, bool j, double& a[], double& b[]);
#import
//+------------------------------------------------------------------+
extern bool    _NLR_Is_Visible = true;
extern bool    _NLR_Risk_Zone_Is_Visible = true;
extern bool    _NLR_Use_Fixed_Date = false;
extern string  _NLR_Fixed_Date = "2011.01.01 00:00";
extern int     _NLR_Period = 300;
extern int     _NLR_Regression_Degree = 3;
extern bool    _NLR_Center_Line = true;
extern double  _NLR_Deviation_Fibo_Coef = 2;
extern color   _NLR_Color_Up = Goldenrod;
extern color   _NLR_Color_Down = SkyBlue;
extern string  _______________________________ = "______________________________";
extern bool    _SDC_Is_Visible = true;
extern double  _SDC_Fibo_C1 = 0.62;
extern double  _SDC_Fibo_C2 = 1.0;
extern double  _SDC_Fibo_C3 = 1.62;
extern color   _SDC_Color = DodgerBlue;
extern string  ______________________________ = "______________________________";
extern bool    _Stop_Loss_Is_Visible = true;
extern double  _Stop_Loss_Fibo_Coef = 2.62;
//+------------------------------------------------------------------+
int _C_P;
double Support[];
double Resist[];
//+------------------------------------------------------------------+
int init() {
   Deinit();
   _C_P = -12345;
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexLabel(0,"CLOSE BUY WARNING");
   SetIndexLabel(1,"CLOSE SELL WARNING");
   SetIndexBuffer(0,Support);
   SetIndexBuffer(1,Resist);
   return(0);
}
//+------------------------------------------------------------------+
int deinit() {
   Deinit();
   return(0);
}
//+------------------------------------------------------------------+
int start() {
   int i_c = IndicatorCounted();
   if ( i_c < 0 || i_c == _C_P ) return(0);
   if ( i_c > 0 ) _C_P = i_c;
   Deinit();
   color _Color[2];
   if ( _NLR_Use_Fixed_Date ) {
      datetime _time = StrToTime(_NLR_Fixed_Date);
      _NLR_Period = iBarShift(NULL, 0, _time, false);
   }
//+------------------------------------------------------------------+
   if ( _SDC_Is_Visible ) {
      _Color[0] = _SDC_Color;
      Create_SDC(_NLR_Period, _Color, _SDC_Fibo_C1, _SDC_Fibo_C2, _SDC_Fibo_C3);
   }

   if ( _NLR_Is_Visible ) {
      _Color[0] = _NLR_Color_Up;
      _Color[1] = _NLR_Color_Down;
   } else {
      _Color[0] = EMPTY;
      _Color[1] = EMPTY;
   }

   if ( _NLR_Is_Visible || _Stop_Loss_Is_Visible ) {
      Create_NLR(_Color, _NLR_Deviation_Fibo_Coef, _Stop_Loss_Fibo_Coef, _NLR_Period, _NLR_Regression_Degree,
                  _NLR_Risk_Zone_Is_Visible, _Stop_Loss_Is_Visible, _NLR_Center_Line, Support, Resist);
   }
//+------------------------------------------------------------------+
   return(0);
}
//+------------------------------------------------------------------+


