This should work... OneOfEach = iif( Bu1 and Sh1, 1, 0 );
Buy = Bu1 and OneOfEach; Short = Sh1 and OneOfEach; Joe --- In [email protected], "felixbraendli" <felixbraen...@...> wrote: > > Okey hello everyone... i think it should be a simple problem... perhaps > someone can help me... > > i have the following options > > SetOption("MaxOpenLong",1); > SetOption("MaxOpenShort",1); > > and i have two arrays filled from rules... > > par example: > > buy = 100100011110000111111 > short= 000000001010000011000 > > now i want to hold (max.) two stocks... one "buying" and the other > "shorting". These two stocks should be entered at the same day/bar.(portfolio > backtesting) > > par example: > > 1.1.1997 one buy and 1.1.1997 one short > > that means that i want to buy a stock from the portfolio only, when there is > a stock to short from the same portfolio at the same day/bar. > (Naturally i use Positionscore to find the best buy signal when there are > more than one buy signals at one day). > > System is as follows: > > BuyPrice=ShortPrice=O; > SellPrice=CoverPrice=O; > > SetTradeDelays(1,1,1,1); > > SetOption("initialEquity",50000); > SetOption("AllowSameBarExit",1); > SetOption("SeparateLongShortRank", True ); > SetOption("MaxOpenLong",2); > SetOption("MaxOpenShort",2); > SetOption("CommissionMode",1); > SetOption("CommissionAmount",0.1); > > PositionSize=-50; > PositionScore=100-RSI(); > > ap1=50; > ad1=6; > dmi1 = abs(PDI(ad1)-MDI(ad1))/(PDI(ad1)+MDI(ad1))*100; > Bu1 = Cross(dmi1,ap1) AND PDI(ad1)>MDI(ad1); > Sell=0; > > ap=3;//Optimize("Grenze",2,0,80,1);//20 > ad=6;//Optimize("length",60,1,100,5);//66 > ac=2; > Sh1=Cross(EMA(C,ad),EMA(C,ap)) AND EMA(C,ad*ac)>EMA(C,ap*ac); > Cover = 0; > > Buy = Bu1; > Short = sh1; > > ApplyStop(3,1,5); >
