//+------------------------------------------------------------------+ //| Correlation.mq4 | //| Безбородов Алексей | //| AlexeiBv@ya.ru | //+------------------------------------------------------------------+ #property copyright "Безбородов Алексей" #property link "AlexeiBv@ya.ru" //---- #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Silver //---- extern string OtherChart="EURUSD"; extern int n=20; extern bool UseOpen=true; extern bool UseClose=false; extern bool UseHigh=false; extern bool UseLow=false; extern int CalcBars=400; //---- double Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators string short_name; //---- 1 additional buffer used for counting. IndicatorBuffers(1); IndicatorDigits(Digits); //---- indicator line SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,Buffer); // SetIndexBuffer(1,TempBuffer); //---- name for DataWindow and indicator subwindow label short_name="Correlation("+n+")"; IndicatorShortName(short_name); SetIndexLabel(0,short_name); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { // Print("True "+true+" false "+false ); int i,k,counted_bars=IndicatorCounted(); double sx,sy,x,y,cor1,cor2,cor3; //---- if(Bars<=n) return(0); //---- int limit=Bars-counted_bars; if(counted_bars>0) limit++; for(i=0; i