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

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



PureBytes Links

Trading Reference Links

Hi Mike.

Thanks for your reply.

Unfortunately I'm setting PositionSize as percent of current equity 
(based on my stop), and I think that's the problem.

I guess that if we knew the number of shares in advance, we could take 
care of the issue in simple AFL:

	RoundLotSize = IIf(shares >= 100, 100, 1);

Perhaps there is some way to get position size value *in dollars* using 
the custom backtester? If yes, then we could just divide the dollar 
value by the close to get the approximate number of shares. Do you know 
if it is possible do that that?

Mike escreveu:
> 
> 
> 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 <mailto:amibroker%40yahoogroups.com>, 
> 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
>  >
> 
> 


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