How to access from and to dates from parameters

How do I access the from and to dates from the parameters
image

EIther direcly in the backtest procedure or in the analysis AFL and pass it to the backtester.

I tried this in the AFL

bi = barIndex();
lastBar   = LastValue( ValueWhen( Status( "LastBarInRange" ),  bi ) );
dt = DateTime();
lastDate = dt[lastBar];
StaticVarSet( "lastDate", lastDate );

but it appears that will differ depending on what bars are available for each aymbol. I want the actual dates selected in the parameters as shown. I'm sure there is a direct way to do that but can't find it.

Cheers,
Gary.

See Status() function in manual.

from_date = Status("rangefromdate");
to_date = Status("rangetodate");
1 Like

Thanks for the quick reply.
My apologies, I missed that in the doco.

image

in AFL

lastDate = Status("rangetodate");
_TRACE("in AFL - toDate " + DateTimeFormat( "%Y%m%d", lastDate ));
StaticVarSet( "lastDate", lastDate );

in backtester

lastDate = StaticVarGet( "lastDate" );
_TRACE("in backtester - lastDate " + DateTimeFormat( "%Y%m%d", lastDate ));

_trace output does not match..
image

I think the formatting is the problem, but.....I want 20210310

Status("rangetodate") returns datenum.

DateTimeFormat() converts datetime to string.

So you need to convert your 'lastdate' variable from datenum to datetime.

See:


1 Like

Fantastic,
I added to my AFL
lastDate = DateTimeConvert( 2, lastDate );

Now my _trace output is
image

Many thanks all,
I will spend somtime re-reading all the date doco...a lot to remember.

Cheers,
Gary

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.