SetCustomBacktestProc( ""
);
if ( Status( "action" ) == actionPortfolio )
{
StaticVarSet( "Date_first_portfolio_bar", Status("rangefromdate") );
bo = GetBacktesterObject();
bo.PreProcess();
for ( bar =
0; bar < BarCount; bar++ )
{
...;
}
bo.PostProcess();
_TRACE( "Date of first bar:
"
+ StaticVarGet( "Date_first_portfolio_bar" ) );
}
Mike
--- In
amibroker@xxxxxxxxxps.com, "Markus Witzler" <funnybiz@xxx>
wrote:
>
> Hello,
>
> I need to retrieve the first
bar´s date (neither the first signal´s nor the first trade´s) and store it as
a static variable for computation of a custom metric (bo.addcustommetric)
in a later step.
>
> I figured it´s the following, but
supposedly, on can´t use datenum() in CBT? I only found properties for
retrieving bar´s date within signal or trade lists!
>
> Thanks
>
> Markus
>
> - - - - - - - -
>
>
SetCustomBacktestProc("");
>
> if (Status("action") ==
actionPortfolio)
>
> {
>
> bo =
GetBacktesterObject(); // Get backtester object
>
>
bo.PreProcess(); // Do pre-processing
>
>
bo.cash=bo.initialEquity=1000000;
>
> Heat=0.1;
>
> ATRmultiplier=5;
>
>
>
> for (i = 0;
i < BarCount; i++) // Loop through all bars
>
>
> { if
(i=0)
>
> StaticVarSet("Date_first_portfolio_bar",
DateNum(i));
>
> for (sig = bo.GetFirstSignal(i); sig; sig =
bo.GetNextSignal(i))
>
> ...
>