//+------------------------------------------------------------------+ //| Chaikin.mq4 | //| Copyright © 2005, GuRu | //| vip6967@bk.ru | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, GuRu" #property link "vip6967@bk.ru" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red //---- input parameters extern int nPeriod=11; extern int screen=1; //---- buffers double ChaikinBuff1[]; double ChaikinBuff2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ChaikinBuff1); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ChaikinBuff2); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int BeginBars=0; int shift=0; int i=0; double ich=0; double ich1=0; int counted_bars=IndicatorCounted(); //---- TODO: add your code here BeginBars=Bars-nPeriod-1; if (screen==2) { BeginBars=150; } shift=BeginBars; while (shift>0) { ich1=((Close[shift+1]-Low[shift+1])-(High[shift+1]-Close[shift+1])) /(High[shift+1]-Low[shift+1])*Volume[shift+1]; ich=((Close[shift]-Low[shift])-(High[shift]-Close[shift])) /(High[shift]-Close[shift])*Volume[shift]; ich=ich+ich1; ChaikinBuff2[shift]=ich; ich1=0; i=shift+nPeriod; while (i>0) { ich=ChaikinBuff2[i]; ich1=ich1+ich; i--; } ich1=ich1/nPeriod; ChaikinBuff1[shift]=ich1; shift--; } //---- return(0); } //+------------------------------------------------------------------+