#property indicator_buffers 1 #property indicator_color1 Red
extern int MaxPer = 500; //Maximal period analysed extern int MinPer = 1; //Minimal period analysed extern int bar2update = 1; //Nombre de barres entre chaque update
double FlatBuf[]; //Flattened close price buffer
int LastUpdate=0; string ShName="";
//+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,FlatBuf); //Correct if needed MinPer and MaxPer if(MinPer<2) MinPer=2; if(MaxPer<MinPer) MaxPer=MinPer; //Correct if needed Bar2Update if(bar2update<0) bar2update=1;
//---- name for DataWindow and indicator subwindow label ShName=" 1111("+MinPer+" to "+MaxPer+" Periods)"; IndicatorShortName(ShName); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { //Check Enough Bars if(Bars<3*MaxPer) { Print(" Not Enough bars! - you need 3*MaxPer -> " + DoubleToStr(3*MaxPer,0)); return(0); } else IndicatorShortName(ShName); //Check bar2update if(bar2update<1) bar2update=1; //Check Update needed if(Time[0]-LastUpdate>=bar2update*Period()*60) { LastUpdate=Time[0]; //--- Call main function ComputeIt(1); } //---- return(0); } //+------------------------------------------------------------------+ int ComputeIt(int x) { int i; int k; double a; double b; //---- Set flatBuf to 0 for(i=0;i<=3*MaxPer+2;i++) { FlatBuf=0; }