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

Re: [amibroker] sigscalein positionsize problem



PureBytes Links

Trading Reference Links

hi,
 
I didn't look at your code in detail but I can give an example of code I have written for scaling out 3 contracts for future trading.
 
Using the following setings:
 
SetOption("CommissionMode", 3);
SetOption("CommissionAmount", 2.40);
SetOption("FuturesMode",True);
NumContracts = 3;
 
you can then tell the backtester to enter 3 contracts on an extry signal using:
 
SetPositionSize( 3, spsShares );
 
then when you scale out from this position of 3 contracts, 1 contract at a time you use:
 
SetPositionSize( 1, spsShares * ( Buy == sigScaleOut OR Short == sigScaleOut ) );
I assume a similar construction can be used when scaling in. See the help for SetPositionSize,
 
rgds, Ed
 
 
 
 
----- Original Message -----
Sent: Tuesday, October 16, 2007 3:05 AM
Subject: [amibroker] sigscalein positionsize problem

Hi to all,

may I ask for your help with the following code.

The positionsize does not behave as it should.
I am trying to buy "100" at first occurence of buy
signal and when scalein condition appears (drawdown),
I want to buy "100000", but backtester does set
positionsize sometimes right and sometimes not,
e.g. it buys "100000", even if it´s the first occurence
of buy signal, or buys "100", even if it´s a scalein
signal. But sometime backtester does it correct. I
just don´t get it. Initial equity in backtestersettings
is 1,000,000, so this should be no problem.

Thanks for any help finding what is wrong with the code.

Regards
robert

******************************************************************

Plot(Close,"",colorwhite,132);

Buy = Buycondition;
Sell = C<0;

ApplyStop(stopTypeProfit,stopModePoint,0.0030,1,False,1);
ApplyStop(stopTypeLoss,stopModePoint,0.0080,1,False,1);

e = Equity(1);

PyramidThreshold = 0.1;
PcntProfit = 100*(e-ValueWhen(Buy,e))/ValueWhen(Buy,e);
InTrade = Flip(Buy,Sell);
DoScaleIn = ExRem(InTrade AND PcntProfit<-PyramidThreshold,Sell);
Buy = Buy + sigScaleIn * DoScaleIn;

PositionSize = IIf(DoScaleIn,100000,100);

******************************************************************

__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

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

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___