PureBytes Links
Trading Reference Links
|
Hi,
I am writing some AFL that outputs a Risk:Reward ratio for each trade
to an HTML file. I also output an overall Win:Loss ratio.
I am using the AFL code at the bottom of this email.
However, the code outputs trades and ratios correctly from 2001-mid
2006, then trails off at the end, round the 10/08/2006. This is
strange, as I have trades entering and exiting up to 2007. You can
see this HTML output here:
http://alexanderchambers.freewebspace.com/AdvancedTradeOutput.html
If anyone could try this code out and advise I'd be really grateful.
Alex
============
a = "<html><body><table border='1'><tr><td>Direction</td><td>In</
td><td>Out</td><td>Risk:Reward</td></tr>";
dtBuy = ValueWhen(Buy,DateTime());
dtSell= ValueWhen(Sell,DateTime());
rsk = ValueWhen(Buy,LongStopBuy) - ValueWhen(Buy, LongStop);
rwd = ValueWhen(Sell,SellPrice) - ValueWhen(Buy,BuyPrice);
rrwd = abs(rwd/rsk); //This is Risk:Reward ratio per trade: works
correctly
winr = IIf(sign(rwd)>=0,1,0); // This is overall number of Win
trades
for (i=1; i<BarCount; i++)
{
if (Sell[i]==1)
{
a = a + "<tr><td>BUY</td><td>"+DateTimeToStr(dtBuy[i])+"</
td><td>"+DateTimeToStr(dtSell[i])+"</td><td>"+rrwd[i]+"</td></tr>";
}
}
tradecnt = Cum(Sell); // total number of trades
a = a + "</table><br>Overall Risk:Reward = "+(Cum(rwd) / Cum(rsk));
a = a + "<br><br>Win:Loss Ratio = "+(Cum(winr) / tradecnt)+"</body></
html>";
fh = fopen("D:\AdvancedTradeOutput.html", "w");
if( fh )
{
fputs(a, fh);
}
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.441 / Virus Database: 268.18.3/693 - Release Date: 2/19/2007 5:01 PM
|