Yes, this is feasible. But, it will be complicated.

- You can set your Buy logic to just: Buy = Condition1 AND Condition2;

- The only way to know if you have open positions is to write custom backtest 
code and check the open positions list at each bar.

- In your custom backtest loop, if you don't already have the number of open 
positions desired, then for each signal you would have to use SetForeign using 
the symbol of the Signal in order to calculate Condition3. If Condition3 was 
not true, then set the PosSize property of the Signal to 0 to cancel the Signal 
entirely (since it neither met Condition 3 nor did you have the requisite 
number of open positions).

- In your main script, you would have to set a PositionScore. Otherwise, your 
custom backtester logic will have an alphabetic order bias.

Custom backtest:
http://www.amibroker.com/guide/a_custombacktest.html
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

SetForeign:
http://www.amibroker.com/guide/afl/afl_view.php?id=247

PositionScore:
http://www.amibroker.com/guide/h_portfolio.html


Mike

--- In [email protected], "nunopires2001" <nunopires2...@...> wrote:
>
> Thanks for your reply Mike,
> 
> I will try to explain in deeper detail my purpose.
> 
> Imagine the following code:
> 
> SetOption("MaxOpenPositions", 10 );
> Condition1=Close > MA(C,200);
> Condition2=MA(C,10)>MA(C,200);
> Condition3=Close > MA(C,5);
> 
> I want to implement the following logic:
> Buy=Iif(Condition1==1 AND Condition2==2 AND (Condition3==1 OR 
> OpenPositions<5),1,0);
> 
> This is feasable?
> 
> Thanks
> --- In [email protected], "Mike" <sfclimbers@> wrote:
> >
> > 1. You'll have to define "less restrictive" before anyone can know if what 
> > you want is possible.
> > 
> > 2. You will almost certainly have to write custom backtesting code in order 
> > to keep track of the number of open positions such that you may apply your 
> > "less restrictive" logic.
> > 
> > http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/
> > 
> > Mike
> > 
> > --- In [email protected], "nunopires2001" <nunopires2001@> wrote:
> > >
> > > Hi,
> > > 
> > > Anyone can point me in the right direction?
> > > 
> > > --- In [email protected], "nunopires2001" <nunopires2001@> wrote:
> > > >
> > > > Hi,
> > > > 
> > > > I am testing a trading system setting max open positions = 10.
> > > > 
> > > > I would like to add some conditions, based on currently number of open 
> > > > positions.
> > > > Lets say, if I have less than 5 open positions I will make my buy 
> > > > conditions less restrictive.
> > > > 
> > > > Is this possible to do with Amibroker?
> > > > 
> > > > Thanks
> > > >
> > >
> >
>


Reply via email to