Can Somebody please covert Amibroker formula to metastock

#1
Hi,

Below is the formula of volume for amibroker along with standard deviation bands.

I am not good with metastock coding. Can somebody please covert the formula for metastock.

help appreciated.

GraphXSpace = Param("Xspace", 10, 2, 20, 1);
// vol with std
LBP = Param("Look Back", 30, 0, 150,1 );
Mean = MA(ln(V),LBP);
StD = StDev(ln(V),LBP);
xp3 = exp(mean + 3*std); //3 band
xp2 = exp(mean + 2*std); //2 nd band
xp1 = exp(mean + 1*std); // 1st band
xm = exp(mean); // avg
xn1 = exp(mean - 1*std); // -1 band
xn2 = exp(mean - -2*std); //-2 band
Plot(xp3,"", colorCustom12 ,1|4096);
Plot(xp2,"", colorSeaGreen,1|4096);
Plot(xp1,"", colorRed,1|4096);
Plot(xm, "avg",colorBlack ,1|4096);
Plot(xn1,"",colorDarkGreen,1|4096);
Plot(xn2,"",colorBrown,1|4096);
Clr = IIf(V>Ref(V,-1),29,32);
Plot(V,"vol",Clr,2+4);
PcntInc = NumToStr((V-xm)/xm*100,2);


_SECTION_END();
 

KelvinHand

Well-Known Member
#2
Hi,

Below is the formula of volume for amibroker along with standard deviation bands.

I am not good with metastock coding. Can somebody please covert the formula for metastock.

help appreciated.

GraphXSpace = Param("Xspace", 10, 2, 20, 1);
// vol with std
LBP = Param("Look Back", 30, 0, 150,1 );
Mean = MA(ln(V),LBP);
StD = StDev(ln(V),LBP);
xp3 = exp(mean + 3*std); //3 band
xp2 = exp(mean + 2*std); //2 nd band
xp1 = exp(mean + 1*std); // 1st band
xm = exp(mean); // avg
xn1 = exp(mean - 1*std); // -1 band
xn2 = exp(mean - -2*std); //-2 band
Plot(xp3,"", colorCustom12 ,1|4096);
Plot(xp2,"", colorSeaGreen,1|4096);
Plot(xp1,"", colorRed,1|4096);
Plot(xm, "avg",colorBlack ,1|4096);
Plot(xn1,"",colorDarkGreen,1|4096);
Plot(xn2,"",colorBrown,1|4096);
Clr = IIf(V>Ref(V,-1),29,32);
Plot(V,"vol",Clr,2+4);
PcntInc = NumToStr((V-xm)/xm*100,2);


_SECTION_END();

Roughly as:
Code:
LBP := Input("Look Back", 0, 150,30 );
ln:= Log(V);
iMean:= Mov(ln,LBP, S);
istd:= Stdev(ln,LBP);
xp3:=Exp(imean + 3*istd); 
xp2:=Exp(imean + 2*istd); 
xp1:=Exp(imean + 1*istd); 
xm :=Exp(imean); 
xn1:=Exp(imean - 1*istd); 
xn2:=Exp(imean - 2*istd);

xp3;
xp2;
xp1;
xm;
xn1;
xn2;

V;
 
#3
Hi KelvinHand,

Thanks a lot for give the metastock version of the formula. I am basically trying to put trade guider style of volume histrogram.

Is it possible to have cloud function here in the formula?? I am not very sure whether metastock has cloud function or not?

Kindly guide about cloud function in the said formula if its there

thanks once again.

regds,
 
#4
Roughly as:
Code:
LBP := Input("Look Back", 0, 150,30 );
ln:= Log(V);
iMean:= Mov(ln,LBP, S);
istd:= Stdev(ln,LBP);
xp3:=Exp(imean + 3*istd); 
xp2:=Exp(imean + 2*istd); 
xp1:=Exp(imean + 1*istd); 
xm :=Exp(imean); 
xn1:=Exp(imean - 1*istd); 
xn2:=Exp(imean - 2*istd);

xp3;
xp2;
xp1;
xm;
xn1;
xn2;

V;
Hi,

Please help I am trying to write a commentary for the above formula.

I want to show if V> xp3 it should write Ultra High volume

I hv modified the indicator naming it xp3

b:= Log(V);
a:= Mov(b,30, S);
istd:= Stdev(a,30);
xp3:=Exp(a + 3*istd);
xp3;

In commentary i am writing the following

Volume = writeif(V> Fml( "xp3"),"Ultra High")

But the above is showing the following error :

Volume = (*ERROR*: Function did not return a value)

Kindly help.

Regds,

C
 

KelvinHand

Well-Known Member
#5
Hi,

Please help I am trying to write a commentary for the above formula.

I want to show if V> xp3 it should write Ultra High volume

I hv modified the indicator naming it xp3

b:= Log(V);
a:= Mov(b,30, S);
istd:= Stdev(a,30);
xp3:=Exp(a + 3*istd);
xp3;

In commentary i am writing the following

Volume = writeif(V> Fml( "xp3"),"Ultra High")

But the above is showing the following error :

Volume = (*ERROR*: Function did not return a value)

Kindly help.

Regds,

C

Amibroker can setup the style and width by programming.
Metastock required you to setup style and width manually. I don't think there is such thing as cloud in metastock.

In your above program,
Volume is predefine function, how can you assign to string, therefore you got the
Volume = (*ERROR*: Function did not return a value)

so omit the Volume =

writeif(V> Fml( "xp3"),"Ultra High")



My metastock crashed on my Window 7. so i cannot help. Already uninstall.
Google and search for Metastock, there are pdf and site with program that help for reference.

Beside, i know basic metastock but not expert on this language, it is very troublesome to do the coding.

Good Luck.
 
#6
Amibroker can setup the style and width by programming.
Metastock required you to setup style and width manually. I don't think there is such thing as cloud in metastock.

In your above program,
Volume is predefine function, how can you assign to string, therefore you got the
Volume = (*ERROR*: Function did not return a value)

so omit the Volume =

writeif(V> Fml( "xp3"),"Ultra High")



My metastock crashed on my Window 7. so i cannot help. Already uninstall.
Google and search for Metastock, there are pdf and site with program that help for reference.

Beside, i know basic metastock but not expert on this language, it is very troublesome to do the coding.

Good Luck.
thanks a lot for your guidance it worked well in metastock. i dont know abcd of coding in any of the charting software but thing is i have reached a stage where i have to code the things in metastock so reading it manual coding language and all.

apart from reading its the prompt help from ppl like u which shorten the learning curve and keep person on track.

thanks once again for help.

regds,
 
#7
Roughly as:
Code:
LBP := Input("Look Back", 0, 150,30 );
ln:= Log(V);
iMean:= Mov(ln,LBP, S);
istd:= Stdev(ln,LBP);
xp3:=Exp(imean + 3*istd); 
xp2:=Exp(imean + 2*istd); 
xp1:=Exp(imean + 1*istd); 
xm :=Exp(imean); 
xn1:=Exp(imean - 1*istd); 
xn2:=Exp(imean - 2*istd);

xp3;
xp2;
xp1;
xm;
xn1;
xn2;

V;
Hi,

This is working well with small price stocks but when i put the same to index chart of big value stock chart an error comes "overfalow in log function".

After googling wht i understood is this log function is asking metastock to do some mathematical calculation and when put on index chart as calculation becomes complex and high it shows the error.

Anyway to remove the error?

kindly help.

regds
 

KelvinHand

Well-Known Member
#8
Hi,

This is working well with small price stocks but when i put the same to index chart of big value stock chart an error comes "overfalow in log function".

After googling wht i understood is this log function is asking metastock to do some mathematical calculation and when put on index chart as calculation becomes complex and high it shows the error.

Anyway to remove the error?

kindly help.

regds
This is something to do with log function of volume
check out the volume size.

may be some division may help
 
#9
Hello, I am looking for some help to modify an AFL that I am using for my trading. Currently, it generates a buy/sell signal - in order to automate further I need some price monitoring and trade management built into the AFL - things like T1, SL. etc. Can some experts take this up as a paid assignment - though may not be a huge project. Please contact me at 0999 009 4400 if interested.
 

jsb2012

Active Member
#10
Re: Can Somebody please convert mq4 formula to afl

//+------------------------------------------------------------------+
//| 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)));
}
}