[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Long and short but only together?



PureBytes Links

Trading Reference Links

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);






------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/