Can Somebody please covert Amibroker formula to metastock

jsb2012

Active Member
#11
//+------------------------------------------------------------------+
//| Bubbles&Drops.mq4 |
//| Maxaxa Angry Hunter |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Maxaxa Angry Hunter"
#property link "[email protected]"

#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;
}
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=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=attenuation(ampl,(i+1))/divider;
}
} else {
for (i=0;i<=(length+future);i++) {
temp=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)));
}
}
 

jsb2012

Active Member
#12
//+------------------------------------------------------------------+
//| Bubbles&Drops.mq4 |
//| Maxaxa Angry Hunter |
//| [email protected] |
//+------------------------------------------------------------------+
#property copyright "Maxaxa Angry Hunter"
#property link "[email protected]"

#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;
}
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=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=attenuation(ampl,(i+1))/divider;
}
} else {
for (i=0;i<=(length+future);i++) {
temp=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)));
}
}