GP, Thanks. I was afraid it would involve something similar to your suggestion.
Will take it from there, and make something work. Thanks agin, David --- In [email protected], "gp_sydney" <[EMAIL PROTECTED]> wrote: > > Yes, the backtester object maintains the state internally of which > signal is the next one, so both loops are affecting the same state > variable. > > For the outer loop you need to keep your own count of how many signals > it's processed and after the inner loop has finished, do another get > first followed by the current count of get next until the state is > back to where it needs to be for the next pass of the outer loop. > > There are a few ways to do this, but one would be something like this: > > sig = bo.GetFirstSignal(bar); > count = 1; > while (sig) > { > ... inner loop here ... > > sig = bo.GetFirstSignal(bar); > cnt = count++; > while (sig && cnt--) sig = bo.GetNextSignal(bar); > } > > I haven't tried this code though, so there may be issues in it. > > Note also that the way you have it, the outer loop will terminate at > the very first signal that's not an entry. If you only want to skip > non-entries rather than terminate the loop at the first one, put the > IsEntry test inside the loop in an IF statement, not as part of the > loop condition. Similarly for the inner loop with the symbol match test. > > Regards, > GP > > > --- In [email protected], "david.weilmuenster" > <dweilmuenster95125@> wrote: > > > > Hi, > > > > Is it possible to use nested loops of Signals in Custom BackTester? > > > > What I have in mind is something like: > > > > for ( sig = bo.GetFirstSignal(bar); sig AND sig.isentry; > > sig=bo.GetNextSignal(bar)) > > { > > ... > > > > for ( compsig = bo.GetFirstSignal(bar); compsig AND compsig.symbol != > > sig.symbol; compsig=bo.GetNextSignal(bar)) > > { > > > > .... > > > > } > > } > > > > But, what seems to happen is that the inner loop is processed only > > once, for the first signal identified in the outer loop. Am guessing > > that bo.getnextsignal(bar) needs to be "reset" somehow at end of > > inner loop, but don't see how to do it. > > > > > > Thanks in advance for help, > > > > David > > San Jose, CA > > >
