Ed -
I was able to take a quick look this morning. Here's a
couple of quick thoughts and a question -
1. What you've coded is more
akin to the CBT in that it loops through the bars with state machine logic. It
looks like the "i" loop cans until it finds a Buy, then the "j" loop
implements the scaling over the next bars until it is done with a trade, then
it reverts to the "i" loop where "j" left off.
2. Since state machines
like this have serial dependencies, you are probably right that you have to
loop.
3. But, there is some optimization that can be done. First there
looks to be some code that can be moved out of the "j" loop and executed once
per Buy signal. This yields some worthwhile savings.
The execution
still looks fairly lengthy, so let's see there is a trick that can be used to
affect a quick improvement. I need to the ask the following to see -
1.
How many bars are being loaded in the tickers that you are scanning - IOW,
with SetBarsRequired(sbrall,sbrall), what is the BarCount
?
2. What is approximately the longest Buy cycle - IOW, approximately
how many bars between Buys taken ?
When I run the change that I'm
thinking about on EOD data with 18 years of history and only a couple of years
displayed at a time, I get very significant speedups (3x+). If your use has
similarities, then there is something interesting that we can do.
--
Bruce
--- In amibroker@xxxxxxxxxps.com,
"Edward Pottasch" <empottasch@...> wrote:
>
>
Bruce,
>
> in the chart below I show what I mean. Upper chart is
the "valuewhen" version, lower part I scale out until the cycle is finished.
It is only 1 part of the scaling In/Out program, and I omitted multiple levels
and scaling in but it clearly shows what I mean with a cycle. I attached the
code. I do not believe it can be simplyfied,
>
> rgds, Ed
>
>
>
>
> ----- Original Message -----
>
From: Bruce
> To: amibroker@xxxxxxxxxps.com
> Sent: Tuesday, December 29, 2009 9:34 PM
> Subject: [amibroker]
Re: ABTool / multidimensional arrays
>
>
>
>
>
> Ed -
>
> I'd have to see the specific code for
scale in/out to be able to tell. As I mentioned, I was just optimizing the
posted code. But, I generally tell people that 95% of loops can be replaced
with array logic. There are a few things (say the 5%) that I've run into that
require looping. Nested looping, though, should be avoided at all costs, and a
way can usually be found around it.
>
> You're right about
ValueWhen. I used AMA2 on purpose, though, because it has some other important
uses in portfolio mixes that I plan to show some examples of soon, and thought
it would be good to mention it.
>
> Anyway, sounds like your
moving along now.
>
> -- Bruce
>
> --- In amibroker@xxxxxxxxxps.com,
"Edward Pottasch" <empottasch@> wrote:
>