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

[amibroker] Re: How to force Backtester to Calculate Position Size on Open Price?



PureBytes Links

Trading Reference Links

Thanks, Mike. I sometimes use the detailed report. Just thought it
might be good to put the entry pos size column in the regular backtest
report - or at least provide the option to turn it on there if one wishes.



--- In amibroker@xxxxxxxxxxxxxxx, "Mike" <sfclimbers@xxx> wrote:
>
> Ozzy,
> 
> From AA Settings window, change to Report tab and then select 
> "Detailed log" for result list. It will show you full details of every 
> entry/exit including size.
> 
> Mike
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> wrote:
> >
> > I see. 
> > 
> > I might suggest that when doing the next update that will allow us 
> to
> > turn on/off select columns in the backtest report, that a column be
> > provided for "Entry Position Size" or something like that. 
> > 
> > I for one would find it useful to know how much cash was used to 
> enter
> > a position originally, at a glance, without having to hand calculate
> > it. Don't know if anyone else shares that desire.
> > 
> > Thanks again for answering questions like this. It's rare that the
> > designer of a major software product takes the time to interact with
> > customers in real time. 
> > 
> > Much appreciated!
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@> wrote:
> > >
> > > You need to remember that in your formula you are using FUTURES 
> mode.
> > > In futures mode you pay Margin Deposit, it can be independent
> > > from actual price. Therefore it may or may not relate to position 
> value.
> > > 
> > > Position Value is component of Equity. Equity by definition is 
> > > value of all open positions plus cash. Value of Position is the 
> money
> > > that you will get if you exited that particular position. That 
> includes
> > > money you paid (or margin deposit for futures) plus/minus 
> profit/loss
> > > minus exit commission (if any).
> > > 
> > > Best regards,
> > > Tomasz Janeczko
> > > amibroker.com
> > > ----- Original Message ----- 
> > > From: "ozzyapeman" <zoopfree@>
> > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > Sent: Thursday, January 22, 2009 1:34 AM
> > > Subject: [amibroker] Re: How to force Backtester to Calculate
> > Position Size on Open Price?
> > > 
> > > 
> > > > Tomasz, thank you for the clarification. I think I understand.
> > > > 
> > > > What you are saying is that, in the backtester report, the value 
> of
> > > > "Position Value" is NOT Position Size (i.e. total money used to 
> enter
> > > > the position) but rather the value of the position at the "End 
> of the
> > > > Day" (or in the case of intraday - "End of the Bar").
> > > > 
> > > > Is the above correct?
> > > > 
> > > > 
> > > > 
> > > > --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@> 
> wrote:
> > > >>
> > > >> No, your findings are incorrect.
> > > >> The fact that equity *chart* always displays closed equity does
> > not mean
> > > >> that close is used for position sizing calculations. It is NOT.
> > > >> Equity chart and pos sizing is independent because
> > > >> AmiBroker calculates equity several times inside bar (usually 3
> > > > times, at open,
> > > >> after handling exit signals and at close).
> > > >> 
> > > >> If "Use Previous Bar Equity for position sizing" option is set 
> to
> > False
> > > >> the backtester will:
> > > >> a) update equity using OPEN price of current bar
> > > >> b) close any positions that have exit signal on open 
> (evaluating
> > > > their value using OPEN price).
> > > >> c) enter new positions on equity calculated from open prices.
> > > >> 
> > > >> If "Use Previous Bar Equity for position sizing" option is set 
> to
> > True
> > > >> it will use previous bar close price instead for pos sizing.
> > > >> 
> > > >> But Equity chart will always show closed equity ("at the end of 
> the
> > > > day") by design (because it is usual
> > > >> accounting practice).
> > > >> 
> > > >> Best regards,
> > > >> Tomasz Janeczko
> > > >> amibroker.com
> > > >> ----- Original Message ----- 
> > > >> From: "ozzyapeman" <zoopfree@>
> > > >> To: <amibroker@xxxxxxxxxxxxxxx>
> > > >> Sent: Thursday, January 22, 2009 12:36 AM
> > > >> Subject: [amibroker] Re: How to force Backtester to Calculate
> > > > Position Size on Open Price?
> > > >> 
> > > >> 
> > > >> >I should note that for Entry prices, the backtester is 
> correctly
> > using
> > > >> > OPEN prices and for ApplyStop, it is correctly exiting at the 
> right
> > > >> > price point between LOW and HIGH.
> > > >> > 
> > > >> > It is only for the position values that the backtester is 
> using
> > CLOSE
> > > >> > prices to calculate, even though CLOSE is nowhere in my AA
> > settings or
> > > >> > AFL reserved variables or SetOptions.
> > > >> > 
> > > >> > 
> > > >> > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> 
> wrote:
> > > >> >>
> > > >> >> Tomasz,
> > > >> >> 
> > > >> >> Thanks for the reply, but I *did* read the manual and *did*
> > set the
> > > >> >> buyprice reserved variables, etc. (all to OPEN), and yet the
> > > >> >> backtester is still using CLOSE for position value 
> calculations.
> > > >> >> 
> > > >> >> Hence I posted the question.
> > > >> >> 
> > > >> >> So either this is a bug or there is some other setting which 
> is
> > > >> >> overriding both my AA settings and reserved variable 
> settings. I
> > > > can't
> > > >> >> seem to find any such setting error, so at this point I am
> > thinking
> > > >> >> it's a bug.
> > > >> >> 
> > > >> >> Is it?
> > > >> >> 
> > > >> >> 
> > > >> >> 
> > > >> >> --- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" 
> <groups@>
> > wrote:
> > > >> >> >
> > > >> >> > Hello,
> > > >> >> > 
> > > >> >> > When everything fails consult..... the manual:
> > > >> >> > 
> > > >> >> > http://www.amibroker.com/guide/h_backtest.html
> > > >> >> > 
> > > >> >> > Quote
> > > >> >> > 
> > > >> >> > "Controlling trade price
> > > >> >> > 
> > > >> >> > AmiBroker now provides 4 new reserved variables for
> > specifying the
> > > >> >> price at which buy, sell, short and cover orders are 
> executed. 
> > > >> >> > These arrays have the following names: buyprice, 
> sellprice,
> > > >> >> shortprice and coverprice.
> > > >> >> > 
> > > >> >> > The main application of these variables is controlling 
> trade
> > price:
> > > >> >> > 
> > > >> >> > BuyPrice = IIF( dayofweek() == 1, HIGH, CLOSE );
> > > >> >> > // on monday buy at high, otherwise buy on close
> > > >> >> > 
> > > >> >> > So you can write the following to simulate real stop-
> orders:
> > > >> >> > 
> > > >> >> > BuyStop = ... the formula for buy stop level;
> > > >> >> > SellStop = ... the formula for sell stop level;
> > > >> >> > 
> > > >> >> > // if anytime during the day prices rise above buystop 
> level
> > > >> >> (high>buystop)
> > > >> >> > // the buy order takes place (at buystop or low whichever 
> is
> > > > higher)
> > > >> >> > Buy = Cross( High, BuyStop );
> > > >> >> > 
> > > >> >> > // if anytime during the day prices fall below sellprice 
> level
> > > > ( low
> > > >> >> < sellstop )
> > > >> >> > // the sell order takes place (at sellstop or high 
> whichever is
> > > > lower)
> > > >> >> > Sell = Cross( SellPrice, SellStop);
> > > >> >> > 
> > > >> >> > BuyPrice = max( BuyStop, Low ); // make sure buy price not 
> less
> > > >> > than Low
> > > >> >> > SellPrice = min( SellStop, High ); // make sure sell price 
> not
> > > >> >> greater than High
> > > >> >> > 
> > > >> >> > Please note that AmiBroker presets buyprice, sellprice,
> > shortprice
> > > >> >> and coverprice array variables with the values defined in 
> system 
> > > >> >> > test settings window (shown below), so you can but don't 
> need to
> > > >> >> define them in your formula. If you don't define them 
> AmiBroker 
> > > >> >> > works as in the old versions.
> > > >> >> > 
> > > >> >> > During back-testing AmiBroker will check if the values you
> > assigned
> > > >> >> to buyprice, sellprice, shortprice, coverprice fit into 
> high-low 
> > > >> >> > range of given bar. If not, AmiBroker will adjust it to 
> high
> > price
> > > >> >> (if price array value is higher than high) or to the low 
> price 
> > > >> >> > (if price array value is lower than low)"
> > > >> >> > 
> > > >> >> > Best regards,
> > > >> >> > Tomasz Janeczko
> > > >> >> > amibroker.com
> > > >> >> > ----- Original Message ----- 
> > > >> >> > From: "ozzyapeman" <zoopfree@>
> > > >> >> > To: <amibroker@xxxxxxxxxxxxxxx>
> > > >> >> > Sent: Wednesday, January 21, 2009 10:46 PM
> > > >> >> > Subject: [amibroker] Re: How to force Backtester to 
> Calculate
> > > >> >> Position Size on Open Price?
> > > >> >> > 
> > > >> >> > 
> > > >> >> > > and here are all my other options set in the AFL.
> > > >> >> > >
> > > >> >> > > I can't see how any of them would force the backtester 
> to use
> > > > Close
> > > >> >> > > prices, but maybe one option does?
> > > >> >> > >
> > > >> >> > >
> > > >> >> > > SetBarsRequired( 10000, 0 );
> > > >> >> > > SetOption( "AccountMargin", 100 );
> > > >> >> > > SetOption( "ActivateStopsImmediately", True );
> > > >> >> > > SetOption( "AllowPositionShrinking", False );
> > > >> >> > > SetOption( "AllowSameBarExit", True );
> > > >> >> > > SetOption( "CommissionAmount", 3.00 );
> > > >> >> > > SetOption( "CommissionMode", 2 );
> > > >> >> > > SetOption( "FuturesMode", 1 );
> > > >> >> > > SetOption( "InitialEquity", 100000 );
> > > >> >> > > SetOption( "InterestRate", 0 );
> > > >> >> > > SetOption( "MaxOpenPositions", 1 );
> > > >> >> > > SetOption( "MinPosValue", 0 );
> > > >> >> > > SetOption( "MinShares", 1 );
> > > >> >> > > SetOption( "PriceBoundChecking", True );
> > > >> >> > > SetOption( "ReverseSignalForcesExit", False );
> > > >> >> > > SetOption( "UsePrevBarEquityForPosSizing", False );
> > > >> >> > > SetTradeDelays( 0, 0, 0, 0 );
> > > >> >> > > SetPositionSize( 1, spsShares );
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" 
> <zoopfree@>
> > wrote:
> > > >> >> > >>
> > > >> >> > >> Buyprices set in AFL formula are all Open:
> > > >> >> > >>
> > > >> >> > >> BuyPrice      = Open;
> > > >> >> > >> ShortPrice    = Open;
> > > >> >> > >> SellPrice     = Open;
> > > >> >> > >> CoverPrice    = Open;
> > > >> >> > >>
> > > >> >> > >> very wierd...
> > > >> >> > >>
> > > >> >> > >>
> > > >> >> > >> --- In amibroker@xxxxxxxxxxxxxxx, "Anthony Faragasso"
> > <ajf1111@>
> > > >> >> wrote:
> > > >> >> > >> >
> > > >> >> > >> > Is there anywhere in your code formula that you may 
> be
> > > >> > specifying a
> > > >> >> > >> different buyprice....because I believe the formula
> > > > overrides the
> > > >> >> > >> settings in the preference window..
> > > >> >> > >> >
> > > >> >> > >> > Anthony
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >   ----- Original Message ----- 
> > > >> >> > >> >   From: ozzyapeman
> > > >> >> > >> >   To: amibroker@xxxxxxxxxxxxxxx
> > > >> >> > >> >   Sent: Wednesday, January 21, 2009 3:41 PM
> > > >> >> > >> >   Subject: [amibroker] Re: How to force Backtester to
> > > > Calculate
> > > >> >> > >> Position Size on Open Price?
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >   I've always had the trade settings set to buyprice 
> Open.
> > > >> >> > >> >
> > > >> >> > >> >   Unfortunately, the backtester insists on using the
> > > > Close, and I
> > > >> >> > > can't
> > > >> >> > >> >   figure out why that is.
> > > >> >> > >> >
> > > >> >> > >> >   --- In amibroker@xxxxxxxxxxxxxxx, "gonzagags"
> > <gonzagags@>
> > > >> > wrote:
> > > >> >> > >> >   >
> > > >> >> > >> >   > Try in settings- trades, set in long trades 
> buyprice in
> > > >> > open..
> > > >> >> > >> >   >
> > > >> >> > >> >   >
> > > >> >> > >> >   > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman"
> > <zoopfree@>
> > > >> >> wrote:
> > > >> >> > >> >   > >
> > > >> >> > >> >   > > Hello, even though I have set Buyprice = Open; 
> I
> > noticed
> > > >> >> > > that the
> > > >> >> > >> >   > > backtester report is displaying position sizes 
> based
> > > > on the
> > > >> >> > >> Close of
> > > >> >> > >> >   > > the bar. On some trades this makes a huge 
> difference.
> > > >> >> > >> >   > >
> > > >> >> > >> >   > > I am backtesting Forex. And I imagine that when
> > trading
> > > >> >> on the
> > > >> >> > >> Open,
> > > >> >> > >> >   > a
> > > >> >> > >> >   > > broker like IB will use the dynamic price of 
> the
> > Open to
> > > >> >> > >> calculate
> > > >> >> > >> >   > the
> > > >> >> > >> >   > > exchange rate and position size, since the 
> Close
> > > > price is
> > > >> >> > > not yet
> > > >> >> > >> >   > > known at the time of the trade.
> > > >> >> > >> >   > >
> > > >> >> > >> >   > > So how do I force the backtester to mimic the
> > above, and
> > > >> >> > > calculate
> > > >> >> > >> >   > > position sizes based on Opens? Or is this not 
> even an
> > > >> > option?
> > > >> >> > >> >   > >
> > > >> >> > >> >   > > I looked up Setoption in the reference guide, 
> and
> > don't
> > > >> > seem
> > > >> >> > >> to see
> > > >> >> > >> >   > an
> > > >> >> > >> >   > > appropriate setting to switch.
> > > >> >> > >> >   > >
> > > >> >> > >> >   > > Any input appreciated.
> > > >> >> > >> >   > >
> > > >> >> > >> >   >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >>
> > > >> >> > >
> > > >> >>
> > > >> >
> > > >
> > --------------------------------------------------------------------
> ----------
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >
> > > >> >> > >> >   No virus found in this incoming message.
> > > >> >> > >> >   Checked by AVG - http://www.avg.com
> > > >> >> > >> >   Version: 8.0.176 / Virus Database: 270.10.10/1906 -
> > Release
> > > >> > Date:
> > > >> >> > >> 1/21/2009 7:07 AM
> > > >> >> > >> >
> > > >> >> > >>
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> > > ------------------------------------
> > > >> >> > >
> > > >> >> > > **** 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
> > > >> >> > >
> > > >> >> > >
> > > >> >> > >
> > > >> >> >
> > > >> >>
> > > >> > 
> > > >> > 
> > > >> > 
> > > >> > ------------------------------------
> > > >> > 
> > > >> > **** 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
> > > >> > 
> > > >> > 
> > > >> >
> > > >>
> > > > 
> > > > 
> > > > 
> > > > ------------------------------------
> > > > 
> > > > **** 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
> > > > 
> > > > 
> > > >
> > >
> >
>



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

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