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

RE: [amibroker] Auto trading position size



PureBytes Links

Trading Reference Links

You need to closely read the doc on "SetPositionSize"
 

SETPOSITIONSIZE
- set trade size

Trading system toolbox
(AFL 2.70)


SYNTAX SetPositionSize( size, method )
RETURNS ARRAY
FUNCTION This function allows to control trade (position) size in four different ways, depending on 'method' parameter.

Parameters:

size (ARRAY) defines desired trade size

method (ARRAY) defines how 'size' is interpreted

  • spsValue (=1) - dollar value of size (as in previous versions)
  • spsPercentOfEquity (=2) - size expressed as percent of portfolio-level equity (size must be from ..100 (for regular accounts) or .1000 for margin accounts)
  • spsShares (=4) - size expressed in shares/contracts (size must be > 0 )
  • spsPercentOfPosition (=3) - size expressed as percent of currently open position (for SCALING IN and SCALING OUT ONLY)
  • spsNoChange (=0) - don't change previously set size for given bar

New SetPositionSize function automatically encodes new methods of expressing position size into old "positionsize" variable as follows:

  • values below -2000 encode share count,
  • values between -2000 and -1000 encode % of current position
  • values between -1000 and 0 encode % of portfolio equity
  • values above 0 encode dollar value

Although it is possible to assign these values directly to old-style PositionSize variable, new code should use SetPositionSize function for clarity.

See where it says:
 
  • values between -2000 and -1000 encode % of current position
  • values between -1000 and 0 encode % of portfolio equity
  •  
    d
     


    From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of professor77747
    Sent: Tuesday, February 21, 2006 6:08 PM
    To: amibroker@xxxxxxxxxxxxxxx
    Subject: [amibroker] Auto trading position size

    Is it possible to auto trade using a percentage of my account balance
    instead of a fixed number of shares?

    For instance, could I use sometime like this?

    PositionSize= -25;

             ibc.PlaceOrder( Name(), "Buy", "PositionSize", "MKT", 0,
    0, "GTC", True );

    I know that the Parameter calls for quantity, but I would like to
    order in 100 share increments using up to 1/4 of my account balance
    including the stocks already purchased for each order. However, it
    would only purchase 4 stocks and the other orders would not be placed.
    So that is I had a $10000 balance, each order would use $2500. If a
    stock costs $20, the order would be for 100, if another stock cost $10
    the order would be for 200, and if another stock costs $30 the order
    would not be placed. If I had already purchased 3 stocks, only the
    first order would be placed. Is this possible?


    Thanks,
    Tom







    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 other support material please check also:
    http://www.amibroker.com/support.html





    SPONSORED LINKS
    Investment management software Real estate investment software Investment property software
    Software support Real estate investment analysis software Investment software


    YAHOO! GROUPS LINKS