PreExecute() + PostExecute() Mothods
Author: kribel
Creation Date: 4/8/2013 6:43 AM
profile picture

kribel

#1
Hello all!

As far as I understand the Execute() method gets executed for every symbol in the selected portfolio.

I would like to print some information which does not change during the execution or is available after the execution. Is there a way to run something like PreExecute() and PostExecute() methods?

Many thanks,
Konstantin
profile picture

Eugene

#2
Hi Konstantin,

It's easier than you think. Please see this KB article, at the bottom ("A simpler approach"):

WealthScript Techniques | Executing some code only once
profile picture

kribel

#3
HI Eugene,

This article is very helpful!

Many thanks,
Konstantin
profile picture

Eugene

#4
Glad to have helped.
profile picture

kribel

#5
Hi Eugene,

I have been using the "simpler approach" for a long time. It did fulfill my requirements very good. Now run into a limitation and need some help with that.

What I currently have is:
CODE:
Please log in to see this code.


I need to initialize my object every time when I start a backtest, especially when I am playing around with my sliders. If I execute the strategy on a single symbol, which is not the first in the DataSet, then my Init-Method never gets called?

Is there a way determine whether the strategy is being executed on a single symbol or on a full DataSet?

Many thanks,
Konstantin
profile picture

Eugene

#6
Hi Konstantin,

QUOTE:
If I execute the strategy on a single symbol, which is not the first in the DataSet, then my Init-Method never gets called?

Yes.

QUOTE:
Is there a way determine whether the strategy is being executed on a single symbol or on a full DataSet?

Sure it's possible:

FAQ | Strategies and WealthScript > Is there a way to detect within my Strategy if it is executed in Multi-Symbol Backtest mode?
profile picture

kribel

#7
Hi Eugene,

thanks a lot! That helped!

Cheers,
Konstantin
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).