Hello Alex,

I only have a minute and can't go into your code fully,

On the off chance it helps.

I was debugging today and found the cause of my challenge was 
ValueWhen - it only looks back so far - the number bars lookback is 
limited - at least in my code anyway.

Plot this and scroll any chart with a few hundred bars to see what I 
mean.

V = ValueWhen((BarIndex() == 0),C, 1);

Plot(V,"BarIndex0Close",1,1);

After so many bars from bar0 the value returned is {Empty}.

It might be your problem.

Regards,

BrianB2.

--- In [email protected], "dralexchambers" 
<[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> I am writing some AFL that outputs a Risk:Reward ratio for each 
trade
> to an HTML file.
> 
> I am using the AFL code at the bottom of this email.
> 
> The code outputs trades and ratios correctly from 2001-27/09/2005, 
> but then trails off. 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
> 
> ===========================================================
> 
> dtBuy = ValueWhen(Buy,DateTime());     // Date of buy
> dtSell= ValueWhen(Sell,DateTime());    // Date of sell
> 
> rskL = IIf(Sell, (ValueWhen(Buy,LongStopBuy) - 
> ValueWhen(Buy,LongStop)), 0); 
> rwdaL = IIf(Sell,(SellPrice-ValueWhen(Buy,BuyPrice)),0);
> rrwdL = 0;
> rrwdL = rwdaL / rskL;     // This is the Risk:Reward ratio - works 
> fine   
> 
> a = "<html><body><table border='1'><tr><td>Direction</td><td>In</
> td><td>Out</td><td>Risk:Reward</td></tr>";
> 
> for (i=1; i<BarCount; i++)
> {
> if (Sell[i])
>       {       
>               a = a + "<tr><td>BUY</td><td>"+DateTimeToStr(dtBuy[i])
+"</
> td><td>"+DateTimeToStr(dtSell[i])+"</td><td>"+rrwdL[i]+"</td></tr>";
> 
>       }
> }
>


Reply via email to