//+------------------------------------------------------------------+ //| to_ind_Adjustable_Trading_Bands .mq4 | //| * | //| * | //+------------------------------------------------------------------+ #property copyright "http://dmffx.com" #property link "http://dmffx.com" #property indicator_chart_window #property indicator_buffers 3 #property indicator_color1 DodgerBlue #property indicator_color2 Red #property indicator_color3 Khaki //---- input parameters extern int ATRPeriod=5; // Период определения максимума/минимума цены extern double ATRFactor=1.5; // Коээфициент уровня коррекции максимума/минимума цены значением ATR extern int ATRHLPeriod=5; // Период ATR корректирующего значения максимума/минимума цены extern int HLPeriod=34; // Период определения максимума/минимума цены откорректированной по ATR //---- buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double LLV_Pl_ATR[]; double HHV_Mn_ATR[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexBuffer(3,LLV_Pl_ATR); SetIndexBuffer(4,HHV_Mn_ATR); SetIndexLabel(0,"ATB Upper"); SetIndexLabel(1,"ATB Lower"); SetIndexLabel(2,"ATB Central"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit=Bars-IndicatorCounted(); for(int i=limit-1;i>=0;i--){ LLV_Pl_ATR[i]=Low[Lowest(NULL,0,MODE_LOW,ATRPeriod,i)]+ATRFactor*iATR(NULL,0,ATRHLPeriod,i); HHV_Mn_ATR[i]=High[Highest(NULL,0,MODE_HIGH,ATRPeriod,i)]-ATRFactor*iATR(NULL,0,ATRHLPeriod,i); } for(i=limit-1;i>=0;i--){ ExtMapBuffer1[i]=LLV_Pl_ATR[ArrayMaximum(LLV_Pl_ATR,HLPeriod,i)]; ExtMapBuffer2[i]=HHV_Mn_ATR[ArrayMinimum(HHV_Mn_ATR,HLPeriod,i)]; ExtMapBuffer3[i]=(ExtMapBuffer1[i]+ExtMapBuffer2[i])/2; } //---- //---- return(0); } //+------------------------------------------------------------------+