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

[amibroker] Re: Round lot size based on position size



PureBytes Links

Trading Reference Links

If you do not come up with any other solution, you can always alter 
the position size of each individual signal using custom backtester 
code.

Assuming that you are setting numbers of shares in the PostionSize 
calculation (as opposed to percentage of equity), something along the 
lines of the following (untested) code should work:

SetOption("UseCustomBacktestProc", True );

if (Status("action")== actionPortfolio) {
  bo = GetBacktesterObject();
  bo.PreProcess();

  for (bar = 0; bar < BarCount; bar++) {
    for (sig = bo.GetFirstSignal(bar); sig; sig = 
bo.GetNextSignal(bar)) {
      if (sig.IsEntry() && sig.PosSize > 100) {
        sig.PosSize = floor(sig.PosSize/100) * 100;
      }
    }

    bo.ProcessTradeSignals(bar);
  }

  bo.PostProcess();
}

Mike

--- In amibroker@xxxxxxxxxxxxxxx, Flávio Veloso <flavso@xxx> wrote:
>
> Hi all.
> 
> Is it possible to use different round lot sizes (e.g. by setting 
> RoundLotSize variable) depending on the number of shares that are 
going 
> to be bought/short?
> 
> Basically all I want is RoundLotSize = 100 for any position size 
that 
> results in more than 100 shares to be bought/short, and RoundLotSize 
= 1 
> for the rest.
> 
> For example:
> 
> Number of shares (based on PositionSize): 75
> Use RoundLotSize = 1
> Shares to buy = 75
> 
> Number of shares (based on PositionSize): 125
> Use RoundLotSize = 100
> Shares to buy = 100
> 
> Number of shares (based on PositionSize): 360
> Use RoundLotSize = 100
> Shares to buy = 300
> 
> Anyone doing this? If so, how?
> 
> Thanks in advance.
> 
> -- 
> Flávio
>


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

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

*********************
TO GET TECHNICAL 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

*********************************
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/