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

[amibroker] Re: Net position sizing.



PureBytes Links

Trading Reference Links

Man,

This stuff has done my head in. I can't get it to work, but realise
it's not going to be a two liner.

Are there any other resources on the custom backtester, other than
those two links, or the "Houston2.pdf" that goes into more detail and
examples?

Adrian

--- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@xxx>
wrote:
>
> yeah well the code shows the idea ... can't garantee that the code
as it is posted works as it is intended :)  But I was able to use
similar code to construct a balanced system (same number of long and
short positions at all times) so maybe you find parts of the code useful,
> 
> rgds, Ed
> 
> 
> 
> 
> 
>   ----- Original Message ----- 
>   From: cipherscribe 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Wednesday, September 24, 2008 9:59 PM
>   Subject: [amibroker] Re: Net position sizing.
> 
> 
>   Wow! Thanks Ed.
> 
>   There's alot of learning in your code. Really appreciate you posting.
>   I'll send you an update once I digest it all... :-)
> 
>   --- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@>
>   wrote:
>   >
>   > maybe this code helps also:
>   > 
>   > 
>   >
>  
http://www.mail-archive.com/amibroker-beta@xxxxxxxxxxxxxxx/msg00262/equalLongShort001.afl
>   > 
>   > 
>   > 
>   > 
>   > 
>   > ----- Original Message ----- 
>   > From: cipherscribe 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Sent: Wednesday, September 24, 2008 9:10 PM
>   > Subject: [amibroker] Re: Net position sizing.
>   > 
>   > 
>   > Thanks Ed.
>   > 
>   > I love that exclamation mark!
>   > 
>   > I am using the following code, but it's not eliminating the trades
>   > above the param number. I tried using the default backtest mode
>   > (removed the "backtestRegularRawMulti" statement), and ran the code
>   > with a watchlist of symbols, but I still get more trades processed
>   > than that in my param field.
>   > 
>   > Any clues here on why this code may not be working?
>   > 
>   > One clue is when I set the parameter to zero, it works - no long
>   > trades are executed. But any number other than zero, and it
processes
>   > them all in the backtest.
>   > 
>   > _SECTION_BEGIN("Maximum buys");
>   > // Maximum buys in a period
>   > //-----------------------------
>   > SetCustomBacktestProc("");
>   > Num = Param("MaxBuys",4,0,9,1);
>   > MaxBuys = Num;
>   > 
>   > if( Status("action") == actionPortfolio ) {
>   > 
>   > bo = GetBacktesterObject();
>   > bo.PreProcess();
>   > 
>   > for( i = 0; i < BarCount; i++ ) {
>   > cntBuys = 0;
>   > for( sig= bo.GetFirstsignal(i); sig; sig = bo.GetNextsignal(i) ) {
>   > if( sig.Islong() ) {
>   > if( CntBuys > MaxBuys - 1 ) {
>   > sig.possize= 0;
>   > } else {
>   > cntBuys++;
>   > }
>   > }
>   > }
>   > bo.ProcessTradeSignals( i );
>   > }
>   > bo.PostProcess();
>   > }
>   > //-----------------------------
>   > _SECTION_END();
>   > 
>   > --- In amibroker@xxxxxxxxxxxxxxx, "Edward Pottasch" <empottasch@>
>   > wrote:
>   > >
>   > > if you are for instance looping through the trades like:
>   > > 
>   > > for( trade = bo.GetFirstTrade(); trade ; trade =
>   bo.GetNextTrade() ) {
>   > > 
>   > > then you can check: if (!trade.IsLong)
>   > > 
>   > > rgds,Ed
>   > > 
>   > > 
>   > > 
>   > > 
>   > > ----- Original Message ----- 
>   > > From: cipherscribe 
>   > > To: amibroker@xxxxxxxxxxxxxxx 
>   > > Sent: Wednesday, September 24, 2008 8:33 PM
>   > > Subject: [amibroker] Re: Net position sizing.
>   > > 
>   > > 
>   > > How do you identify a short signal in the preprocess? I see
only the
>   > > following signal object methods:
>   > > 
>   > > Methods:
>   > > 
>   > > * bool IsEntry()
>   > > 
>   > > True if this is entry signal, False otherwise
>   > > 
>   > > * bool IsExit()
>   > > 
>   > > True if this is exit signal, False otherwise
>   > > 
>   > > * bool IsLong()
>   > > 
>   > > True if this is long entry (buy) or long exit (sell) or scale-in
>   > > signal, False otherwise
>   > > 
>   > > * bool IsScale()
>   > > 
>   > > True if this is scale-in or scale-out signal, False otherwise 
>   > > 
>   > > Is there a IsShort() method?
>   > > 
>   > > Cheers,
>   > > 
>   > > Adrian
>   > > 
>   > > --- In amibroker@xxxxxxxxxxxxxxx, "cipherscribe"
>   > > <adrian.mollenhorst@> wrote:
>   > > >
>   > > > Thanks Thomasz and Ara,
>   > > > 
>   > > > I am using the "backtestRegularRawMulti" option, which gives me
>   > > > multiple signals.
>   > > > 
>   > > > Thanks for the hint to direct my attentions toward the custom
>   > > > backtester. I shall look into it and hopefully code what I am
>   > > looking for.
>   > > > 
>   > > > Cheers,
>   > > > 
>   > > > Adrian
>   > > > 
>   > > > 
>   > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@>
>   wrote:
>   > > > >
>   > > > > By default you can NOT have both LONG and SHORT pos on the
same
>   > > > symbol open at the same time.
>   > > > > 
>   > > > > The only way to have it is to use low-level custom backtester.
>   > > > > http://www.amibroker.com/guide/a_custombacktest.html
>   > > > > 
>   > > > > Best regards,
>   > > > > Tomasz Janeczko
>   > > > > amibroker.com
>   > > > > ----- Original Message ----- 
>   > > > > From: "cipherscribe" <adrian.mollenhorst@>
>   > > > > To: <amibroker@xxxxxxxxxxxxxxx>
>   > > > > Sent: Wednesday, September 24, 2008 5:17 PM
>   > > > > Subject: [amibroker] Net position sizing.
>   > > > > 
>   > > > > 
>   > > > > >I trade the ES Futures contract mechanically, and I want my
>   to be
>   > > able
>   > > > > > to backtest my system such that it has a maximum net
>   > position at any
>   > > > > > one time of abs(x) positions.
>   > > > > > 
>   > > > > > I can set the option to limit the number of Maximum Open
>   > Positions,
>   > > > > > but this doesn't help me when I am trading only 1
instrument. 
>   > > > > > 
>   > > > > > For example (Note I am using the backtest mode
>   > > > > > "backtestRegularRawMulti", so I take every raw signal my
>   equity
>   > > allows
>   > > > > > me.), the system can issue a buy, which will make me long.
>   > If the
>   > > > > > system issues a short, while I'm long, it will send a short
>   > order,
>   > > > > > which will make me effectively flat.
>   > > > > > 
>   > > > > > This will count as 2 open orders in the backtester, but in
>   > > reality, I
>   > > > > > have no positions open, and could take another abs(x) in
>   either
>   > > > > > direction before I hit my maximum limit of open
positions (x).
>   > > > > > 
>   > > > > > So if I had 2 longs open, I could accept up to 5 shorts,
if my
>   > > maximum
>   > > > > > open position(x) was abs(3).
>   > > > > > 
>   > > > > > This is different from exiting a position when a signal
in the
>   > > > > > opposing direction is triggerred, as in
>   > "ReverseSignalForcesExit",
>   > > > > > since that option cancels the existing order. I need both to
>   > remain
>   > > > > > open, remembered, and exited at my sell/cover trigger,
not the
>   > > > > > opposing short/buy signal.
>   > > > > > 
>   > > > > > What I need is for Amibroker to tabulate both long and short
>   > > positions
>   > > > > > distinctly, to count longs as positive, shorts as
>   > negatively, and to
>   > > > > > be able to set a maximum net position.
>   > > > > > 
>   > > > > > I can do this in reality with no problems - send orders
to IB
>   > > based on
>   > > > > > a maximum net position, but I'd like to be able to do it in
>   > > > > > backtester, so I can validate the system.
>   > > > > > 
>   > > > > > Any Ideas?
>   > > > > > 
>   > > > > > 
>   > > > > > ------------------------------------
>   > > > > > 
>   > > > > > 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
>   > > > > > Yahoo! Groups Links
>   > > > > > 
>   > > > > > 
>   > > > > >
>   > > > >
>   > > >
>   > >
>   >
>



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

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