PureBytes Links
Trading Reference Links
|
Hi members
I am trying to write a profit formula in the explorer using
vbscript.
The formula below is only in AFL which gives the profit result,
but the start equity for every trade is the same e.g. $10000.
I have tried to use vbscript to try to get the startequity to
change dependant on the previous trade, similar to the AA profit
result, but havn't had any luck.
The above buy condition is only for testing the formula to compare
it to the AA result, as what i want to do is to get the result if i
bought when the high crosses a price level ( not including a gap up
when the low is higher than this level) from a previous true
condition and have the actual profit worked out from that price, So
it wont be the l,O,C,H.
I have not been able to figure out how to do this in VBscript.
Would any members know how to code a profit formula in VBscript .
comm=50;//dollarcommision
comper=0;percentcommision
startequityy=10000;
delayy=0;//buydelay
sdelayy=0;//selldelay
Buyarray=O;
Sellarray=C;
Buycond=Cross(C,MA(C,20))AND V >0;//buycondition
Sellcond=Cross(MA(C,20),C)AND V >0;//sellcondition
Buy2= Buycond ;
Buy2 = ExRemSpan(Buy2 ,delayy );
Buy2=Ref( Buy2,-delayy );
Sell2=Sellcond;
Sell2= ExRemSpan(Sell2,sdelayy );
Sell2=Ref(Sell2,-sdelayy);
Buy2=ExRem(Buy2,Sell2);
Sell2=ExRem(Sell2,Buy2);
Buyvalue=ValueWhen(Buy2,Buyarray ,1);
Sellvalue=ValueWhen(Sell2,Sellarray,1);
trades=Cum(IIf(Buy2,1,0));
buyDate= ValueWhen(Buy2,DateNum(),1);
Buy2a= IIf(Sell2 AND trades>1,0,1)AND Buy2;
Sell=Sell2 AND trades >0;
Commtype=IIf(Comm>0,ValueWhen(Comm,Comm,1),IIf
(Comper>0,startequityy/100*Comper,0));
equityaftercomm=ValueWhen(Buy2a,startequityy-Commtype,1);
remainequity=ValueWhen(Sell,(( equityaftercomm) / buyValue) *
sellvalue - commtype,1);
profitt=remainequity-startequityy;
Filter= Sell AND trades>0;
AddColumn(ValueWhen(Sell,IIf(Sell ,buyDate,0),1),"buydaate",1);
AddColumn(IIf(Sell,ValueWhen(Sell,DateNum(),1),0),"selldaate",1);
AddColumn(IIf(Sell,ValueWhen(Buy2a,Buyvalue,1),0),"buyprice",1.4);
AddColumn(IIf(Sell,ValueWhen(Sell,sellvalue,1),0),"sellprice",1.4);
AddColumn(trades,"trades",1);
AddColumn(Commtype ,"Commtype ");
AddColumn(equityaftercomm ,"equityaftercomm ");
AddColumn(remainequity ,"remainequity ");
AddColumn(profitt ,"profitt ");
Plot(ValueWhen(Buycond,Close,1),"",4,4);
Plot(C,"",1,64);
Plot(MA(C,20),"",6,4);
Buy=Buycond;
Sell=Sellcond;
Thanks peter.
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
|