BubbleAndDrops

Author: Maxaxa Angry Hunter
0 Views
0 Downloads
0 Favorites
BubbleAndDrops
//+------------------------------------------------------------------+
//|                                               Bubbles&Drops.mq4  |
//|                                              Maxaxa Angry Hunter |
//|                                                        mg@dsr.ru |
//+------------------------------------------------------------------+
#property copyright "Maxaxa Angry Hunter"
#property link      "mg@dsr.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Orange
#property indicator_color2 Red

extern int historyDeep=100;      // Êîëè÷åñòâî áàðîâ â èñòîðèè
extern int future=50;            // Ñêîëüêî áàðîâ ïîêàçûâàåì ïîñëå ãðàôèêà

double Buffer[],temp[],fut[];
int timeLen=0,divider=10000;

int init()
  {
//---- indicators
   IndicatorBuffers(2);
   SetIndexBuffer(1,Buffer);
   SetIndexBuffer(0,fut);

   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);

   SetIndexShift(1,0);
   SetIndexShift(0,future);

   return(0);
  }
int deinit()
  {
  }

int start()
  {
  if (Digits==5) divider=100000;
  if (Digits==4) divider=10000;
  
  if (ArraySize(Time)!=timeLen) {
     historyDeep++;
  }
  timeLen=ArraySize(Time);

   ArrayInitialize(Buffer,Open[historyDeep]);
   ArrayInitialize(fut,Open[historyDeep]);

for (int j=0;j<historyDeep;j++) {
      splash(historyDeep-j);

      for (int i=0;i<=historyDeep-j;i++) {
         Buffer[historyDeep-j-i]=Buffer[historyDeep-j-i]+temp[i];
      }
      for (i=0;i<=future+1;i++) {
         fut[future-i]=fut[future-i]+temp[historyDeep-j+i];
      }
      for (i=future;i<(historyDeep+future);i++) {
         fut[i]=Buffer[i-future];
      }
}
      fut[0]=fut[1];

   return(0);
  }

double splash(int length) {
ArrayResize(temp,length+future);
ArrayInitialize(temp,0.0);
   double ampl=MathRound((Open[length]-Close[length])*divider); //
   if (ampl!=0) {
      for (int i=0;i<=(length+future);i++) {
          temp[i]=attenuation(ampl,(i+1))/divider; 
      }
   } else {
      for (i=0;i<=(length+future);i++) {
          temp[i]=0; 
      }
   }
      return;
}

double attenuation (double a,double x) { 
if (a!=0) {
	if (a<0) return ( (MathAbs(a)-100/(x)*MathSin(x/100*MathAbs(a)))); // sin(exp(cos($x)));
	if (a>0) return (-(MathAbs(a)-100/(x)*MathSin(x/100*MathAbs(a)))); // sin(exp(cos($x)));
}
}

Comments