Works fine for me. I've added a simple trading system to your code (as
well as a date to your Trace output).
Running it against the AmiBroker trial version database with a watchlist
of (AA, CAT, ^DJI) works fine. Note that trades are never taken for ^DJI
since there is insufficient equity (initial equity set to 10,000).
_SECTION_BEGIN( "Money Manager: Percent Volatility" );
systemMMVolatilityPercent = Param( "Percent", 2, 0.1, 10, 0.1 );
systemMMVolatilityATR = Param( "ATR Period", 20, 1, 250, 1 );
_SECTION_END();

StaticVarSet( "MyAtr" + Name( ), ATR( systemMMVolatilityATR ) );

fast =  MA( Close, 5 );
slow = MA( Close, 50 );
Buy = Cross( fast, slow );
Sell = Cross( slow, fast );
SetPositionSize( 2, spsPercentOfEquity );

SetCustomBacktestProc( "" );

if ( Status( "action" ) == actionPortfolio )
{
     bo = GetBacktesterObject();
     bo.PreProcess();
     dates = DateTime();

      for ( bar = 0; bar < BarCount; bar++ )
     {
         for ( sig = bo.GetFirstSignal( bar ); sig; sig =
bo.GetNextSignal( bar ) )
         {
             if ( sig.IsEntry() )
             {
                 CurrentEquity = bo.Equity;
                 Test = StaticVarGet( "MyAtr" + sig.Symbol );
                 _TRACE( NumToStr( dates[bar], formatDatetime ) + " " +
sig.symbol + " " + NumToStr( Test[bar] ) + " " + " " + NumToStr( bar )
);
// units = CurrentEquity * ( systemMMVolatilityPercent / 100 ) /
Test[bar];
// sig.PosSize = sig.Price * units;
             }
         }

         bo.ProcessTradeSignals( bar );
     }

     bo.PostProcess();
}
Mike
--- In amibroker@yahoogroups.com, "rise_t575" <ris...@...> wrote:
>
> Thank you Mike.
>
> My knowledge of the custom backtester is still pretty limited (my
first
> try), although I have been readining everything I could get my hands
on.
>
> Now the ticker symbols the _TRACE window is giving me are completely
> different (exclusive) than the ticker symbols that come up in the
> backtesting window.
>
> Could someone look over the code & tell me what is wrong here?
>
> Thanks in advance!
>
>
> _SECTION_BEGIN( "Money Manager: Percent Volatility" );
> systemMMVolatilityPercent = Param( "Percent", 2, 0.1, 10, 0.1 );
> systemMMVolatilityATR = Param( "ATR Period", 20, 1, 250, 1 );
> _SECTION_END();
>
> StaticVarSet( "MyAtr"+Name( ), ATR(systemMMVolatilityATR) );
>
> SetCustomBacktestProc("");
>
> if ( Status( "action" ) == actionPortfolio )
> {
>      bo = GetBacktesterObject();
>      bo.PreProcess();
>
>      for ( bar = 0; bar < BarCount; bar++ )
>      {
>          for ( sig = bo.GetFirstSignal( bar ); sig; sig =
> bo.GetNextSignal( bar ) )
>          {
>              if(sig.IsEntry())
>              {
>                  CurrentEquity = bo.Equity;
>                  Test = StaticVarGet( "MyAtr"+sig.Symbol);
>                  _TRACE(sig.symbol + " " + NumToStr(Test[bar])+" " + "
"
> + NumToStr(bar));
> //                units = CurrentEquity * ( systemMMVolatilityPercent
/
> 100 ) / Test[bar];
> //                sig.PosSize = sig.Price * units;
>              }
>          }
>          bo.ProcessTradeSignals( bar );
>      }
>      bo.PostProcess();
>

Reply via email to