Portfolio backtester - instructions for all symbols

Questions about MultiCharts and user contributed studies.
moses
Posts: 54
Joined: 16 Nov 2012
Has thanked: 34 times
Been thanked: 7 times

Portfolio backtester - instructions for all symbols

Postby moses » 22 Mar 2013

Hi all,

I'm trying to find a way to do the following but I am stuck - any ideas?

I need to devise some code to backtest in my portfolio-level strategy (daily bars for many equity symbols at the same time):

if somecondition = true then
do not trade any of the symbols for the next 20 days

Thanks for any ideas!

moses

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Portfolio backtester - instructions for all symbols

Postby JoshM » 25 Mar 2013

I'm trying to find a way to do the following but I am stuck - any ideas?

I need to devise some code to backtest in my portfolio-level strategy (daily bars for many equity symbols at the same time):

if somecondition = true then
do not trade any of the symbols for the next 20 days

Thanks for any ideas!
Perhaps something like this?

Code: Select all

if (someCondition = True) and (daysPassed < 20) then
#return;

// Other strategy code here
This way, as long as both conditions are true, all the code that follows after it (including your order submitting) won't be executed.

moses
Posts: 54
Joined: 16 Nov 2012
Has thanked: 34 times
Been thanked: 7 times

Re: Portfolio backtester - instructions for all symbols

Postby moses » 26 Mar 2013

Josh, I can't seem to find a reserved word 'daysPassed'..?

Help!?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Portfolio backtester - instructions for all symbols

Postby JoshM » 03 Apr 2013

Josh, I can't seem to find a reserved word 'daysPassed'..?
Help!?
Well, you asked for a way to not trade any of the symbols (which the #return keyword will do), not for a way to calculate the number of days passed. Also note that I said "something like this", meaning that my answer was not a copy-paste solution but would also require some thought on your part.

Similarly, to calculate the number of days passed, you can code something like this:

Code: Select all

Variables:
dateOfEntry(0),
daysPassed(0);

dateOfEntry = ELDateToDateTime(EntryDate(1));
daysPassed = ELDateToDateTime(Date) - dateOfEntry;
Also see the Wiki category Date and time routines.


Return to “MultiCharts”