Parts of that code look familiar ;)

If volume is in terms of round lots i.e. 100's then that could be a 
problem.

--- In [email protected], "egregory99" <[EMAIL PROTECTED]> 
wrote:
>
> I'm trying to count the number of trades taken with 60 day vol. 
over 
> and under 500,000. It is not counting right. The volume for over 
> 500,000 always shows 0. Thanks for the help.
> 
> 
> SetCustomBacktestProc("");
> 
> if( Status("action") == actionPortfolio ) 
> { 
>     bo = GetBacktesterObject(); 
> 
>     bo.Backtest(); // run default backtest procedure 
> 
>    SumMAE = 0; 
>    NumTrades = 0;
>    SumMFE = 0; 
>    NumTrades2 = 0;
> StaticVarSet("Counter1", 0); 
> StaticVarSet("Counter2", 0); 
> 
>    // iterate through closed trades first 
>    for( trade = bo.GetFirstTrade(); trade; trade = bo.GetNextTrade
> () ) 
>    { 
>       // here we sum up maximum adverse excursions
>        SumMAE = SumMAE + trade.GetMAE();
>        NumTrades++; 
>        SumMFE = SumMFE + trade.GetMFE();
>        NumTrades2++;
> 
> Counter1 = StaticVarGet("Counter1"); 
> Counter2 = StaticVarGet("Counter2"); 
> V60 = MA(V, 60); 
> BI = BarIndex(); 
> LVBI = LastValue(BI); 
> if (V60[LVBI] > 500000) 
>     Counter1 = Counter1 + 1; 
> else 
>     Counter2 = Counter2 + 1; 
> StaticVarSet("Counter1", Counter1); 
> StaticVarSet("Counter2", Counter2);
>    } 
> 
>    // iterate through eventually still open positions 
>    for( trade = bo.GetFirstOpenPos(); trade; trade = 
bo.GetNextOpenPos
> () ) 
>    { 
>        SumMAE = SumMAE + trade.GetMAE();
>        NumTrades++; 
>        SumMFE = SumMFE + trade.GetMFE();
>        NumTrades2++;
> 
>    } 
>    averageMAE = SumMAE / NumTrades; 
>    bo.AddCustomMetric( "Avg. adverse excursion", averageMAE ); 
>    averageMFE = SumMFE / NumTrades2; 
>    bo.AddCustomMetric( "Avg. favorable excursion", averageMFE );
> 
> bo.AddCustomMetric( "Volume > 500,000", Counter1 );
> bo.AddCustomMetric( "Volume < 500,000", Counter2 );
> }
>


Reply via email to