PureBytes Links
Trading Reference Links
|
Hi,
If you are planning to trade more than a single stock, your approach will not work. The Equity() function is equivalent to running a backtest using the current symbol as the one and only symbol in a watchlist.
In other words; Equity() does not support portfolio management and thus will not give the correct portfolio equity when trading more than the current symbol.
If you plan to trade more than a single symbol and still want to tweak position size based on equity, then write custom backtester logic to change the PosSize property of the Signal objects. See the custom backtester document by gp_sydney in the files section of this forum to learn how to write custom backtester code.
Mike
--- In amibroker@xxxxxxxxxxxxxxx, "lucianomt" <lucianomt@xxx> wrote:
>
> I am trying to write a code extensively without using the built-in AB
> features such as trailing stops and position sizes. So far I was able
> to put in the entries and exits but am having some trouble with the
> trade size which uses the current equity curve. This is the current code
> (ignore the strategy itself, as it is just random):
>
> priceatbuy = 0;
> for(i=0; i<20; i++)
> {
> Buy[i] = 0;
> Sell[i] = 0;
> }
> for(i=20; i<BarCount; i++)
> {
> if( priceatbuy == 0 & BuyPrice[i] > entryLevel[i] )
> {
> Buy[i] = 1;
> BuyPrice[i] = Max(entryLevel[i], Low[i]);
> priceatbuy = BuyPrice[i];
> }
> else
> Buy[i] = 0;
>
> if( priceatbuy > 0 & SellPrice[i] < exitLevel[i] )
> {
> Sell[i] = 1;
> SellPrice[i] = Min(exitLevel[i], High[i]);
> priceatbuy = 0;
> }
> else
> Sell[i] = 0;
> }
>
> Now I want to buy shares equal to 50% of current equity (updated daily,
> not initial equity). I tried adding the following line into the FOR
> statement but that didn't work:
> SetPositionSize( equity()*0.5/priceatbuy, spsShares );
>
> Any suggestions? I know that SetPositionSize(-50, spsPercentofEquity )
> would do the job, but I would like to be able to tweak the number of
> shares manually. Thanks!
>
------------------------------------
**** 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/
|