Thankyou - that worked, in fact the previous code worked too. Before it was solved with the looping, I'd implemented an nbar stop in the settings and forgot to remove it.
That's a useful function I'd not seen before, thanks. Cheers, Rich --- In [email protected], Grant Noble <[EMAIL PROTECTED]> wrote: > > Um.. try using exRemSpan instead of exRem and drop the loop code. Just an idea. G > > foxblade2000invest wrote: > > I'm trying to optimise with the folowing code. When I look at the > > results, the winning and losing average bars (which should be fixed) > > does not correspond at all with the "length" parameter, which should > > govern it? > > > > The code is as follows; > > > > PB=Optimize("PB",0.99,0.97,0.998,0.002); > > Length=Optimize("Length",12,3,15,1); > > > > Cond1=Ref(C,-1)<PB*Ref(C,-2); > > Cond2=C>Ref(C,-1); > > > > > > Buy = Cond1 AND Cond2; > > Sell = False; > > inTrade = False; > > bcnt = 0; > > > > for (i = 0; i < BarCount; i++) > > { if (inTrade) > > { > > Buy[i] = False; > > } > > if (++bcnt == Length) > > {inTrade = False; > > Sell[i] = True; > > }else > > { > > if (Buy[i]) > > {inTrade = True;bcnt = 0; > > } > > }} > > > > Buy=ExRem(Buy,Sell); > > Sell=ExRem(Sell,Buy); > > > > Can anyone help? > > > > Thanks, > > Rich > > > > > > ------------------------------------ > > > > Please note that this group is for discussion between users only. > > > > To get support from AmiBroker please send an e-mail directly to > > SUPPORT {at} amibroker.com > > > > For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG: > > http://www.amibroker.com/devlog/ > > > > For other support material please check also: > > http://www.amibroker.com/support.html > > Yahoo! Groups Links > > > > > > > > > > ------------------------------------------------------------------------ > > > > > > No virus found in this incoming message. > > Checked by AVG. > > Version: 8.0.100 / Virus Database: 270.3.0/1505 - Release Date: 6/16/2008 7:20 AM >
