Hi,

This comes up every year or so...

http://finance.groups.yahoo.com/group/amibroker/message/147538

Mike

--- In [email protected], "nunopires2001" <nunopires2...@...> wrote:
>
> Thanks.
> 
> In fact does not help.
> Basically what I need is:
> If positions open = 4 (max is 5)
> then
> ONLY buy if Rule1==1 AND rank ==1
> 
> Any hints?
> 
> Thanks again.
> 
> --- In [email protected], "j0etr4der" <j0etr4der@> wrote:
> >
> > PositionScore uses the current bar by default. Which is looking forward.  
> > So...
> > 
> > PositionScore = Ref( ROC( Close, 40 ), - 1 );
> > 
> > You can confirm this for yourself by looking at the individual trades using 
> > the Detail Log report.
> > 
> > Don't think this answers your question, but using the Detail Log report 
> > might help.
> > 
> > --- In [email protected], "nunopires2001" <nunopires2001@> wrote:
> > >
> > > Imagine this simple system:
> > > 
> > > Rule: Stock's close is above MA(50)
> > > If rule is fulfilled, send a limit order, 2% below yesterday close.
> > > 
> > > AFL Code:
> > > /*******************************************************************
> > > //Stock above MA
> > > Rule1=Ref(Close,-1)>MA(Ref(Close,-1),50);
> > > //Stock drops 2%
> > > Rule2=Iif(Low<0.98*Ref(Close,-1),1,0);
> > > 
> > > Buy=Iif(Rule1==1 AND Rule2==1,1,0);
> > > //Buyprice can be 2% below yesterday close, or even  better.
> > > BuyPrice=Iif(Open<0.98*Ref(Close,-1),Open,0.98*Ref(Close,-1));
> > > 
> > > SetOption("MaxOpenPositions", 5 ); // no more than 5 positions
> > > PositionScore=ROC(C,40);
> > > /*******************************************************************
> > > 
> > > 
> > > As you can imagine, this simple system will trigger lots of buy signals 
> > > every day. Without PositionScoring, I guess Amibroker choose the stocks 
> > > by alphabetically order? 
> > > 
> > > So, to solve this question, i thought in a simple ranking filter.
> > > Lets say: PositionScore=ROC(C,40);
> > > 
> > > 
> > > But, now there is my problem. If i apply PositionScore to the system 
> > > above, system will be forward-looking.
> > > The rank is applied to every stocks dropping 3%, and the ones with better 
> > > rank are chosen.
> > > 
> > > In real life, if I already have 4 open positions, only the stock with 
> > > highest rank should be considered.
> > > 
> > > Anyone can help?
> > > 
> > > Probably my explanation wasn't clear, this isn't easy to explain. Ask me 
> > > any questions, if that was the case.
> > > 
> > > Many thanks!
> > >
> >
>


Reply via email to