Hi
I've been reading the answers, and I am afraid I have not enough Ami knowledge 
to use some of them
So, I'm going to be dare , like daredevil, and post some code, to see if is 
there any kind person who finish the code.
This way, there will be a working  sample to combine two systems in this 
thread.. :-)

So, I just to want to mix (combine) two simple systems, over a stocks 
portfolio, and EOD bars.
The systems are two; one is a cross averages system, and the other, a mean 
reversion system.
One use the variable 'BUY1' and the other, 'BUY2'.
I think that buying is easy. The problem is selling.
If I have bought  a stock using the first condition, I have to sell it using 
one sell ' 'A' condition.
If I have bought using the second condition, the sell condition have to be 
another one, obviously. it is the sell 'B' variable.
I think that the only manner to do it is using the customize backtester.

Also, I have another problem: the PositionScore should be different if I buy 
the first system or the second system. I have used the iif command, but I am 
not sure if it's possible to use that way..

The code is:
//*********************************************************
posQty=Param("Posiciones simultaneas",10,1,20,1);
CapMinimo=Param("Cap minimo",2,1,200,5);
SetOption("InitialEquity", 100000 ); 
SetOption("AllowPositionShrinking", True ); 
SetOption("MaxOpenPositions", PosQty );
SetOption ("accountmargin",100);
PositionSize = -100/(posqty); 

SetTradeDelays(1,1,1,1);

//---------------------------TREND SYSTEM------------
//FIRST SYSTEM
Buy=Sell=False;
Buy1= Cross(MA(C,15),MA(C,70));
BuyPrice1=Open;
SellA= Cross(MA(C,50),MA(C,15));
SellPriceA=Open;

//---------------------------PULLBACK-------------
//SECOND SYSTEM
Buy2=False;
Buy2= L<BBandBot( Open, 15, 2 )*0.95;
BuyPrice2=Open*1;
SellB= Ref(Buy,-2);
SellPriceB=Open;

Buy=IIf(Buy1,True,IIf(Buy2,True,False)); 
BuyPrice=Open;

//wrong commands--> the bar is not the buy bar..
//Sell=IIf(Buy1,SellA,IIf(Buy2,Sellb,False));//if Buy1 true, buy=true and if 
not and buy2=true, buy=true

//CUSTOM BACKTEST INTERFACE
// ...
// ...
//
PositionScore=IIf(systemUsed,100-Ref(StochK(15,3),-1),(Ref(C,-5)/Ref(C,-1)));

Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy);
PlotShapes(IIf(Buy,shapeUpArrow,shapeNone),colorBlue,0,L,-15);
PlotShapes(IIf(Buy,shapeHollowSquare,shapeNone),colorBlue,0,BuyPrice,0);
PlotShapes(IIf(Sell,shapeDownArrow,shapeNone),colorRed,0,H,-15);
PlotShapes(IIf(Sell,shapeHollowSquare,shapeNone),colorRed,0,SellPrice,0);
//*********************************************************

The 'systemUsed' should be a variable that identify the system used to apply 
the correct positionscore

And the sell conditions have to be managed in Custom Backtest..



Anyone has an idea?

Thanks a lot




Reply via email to