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

Re: [amibroker] gain / loss from trades on last bar?



PureBytes Links

Trading Reference Links


Steve,
 
1. Total net profit reported by AmiBroker INCLUDES 
open position profit/loss.
(you may see this using this very simple code: <FONT 
face="Courier New" size=1>
Buy=<FONT 
face="Courier New" color=#0000ff size=1>Cum<FONT face="Courier New" 
size=1>(1<FONT 
face="Courier New" size=1>)==<FONT face="Courier New" color=#0000ff 
size=1>LastValue(<FONT 
face="Courier New" color=#0000ff size=1>Cum<FONT face="Courier New" 
size=1>(1<FONT 
face="Courier New" size=1>))-<FONT face="Courier New" color=#ff00ff 
size=1>10;
Sell=0<FONT 
face="Courier New" size=1>;
)
(this will 
generate one open long pos)
<FONT 
face="Courier New" size=1>The ONLY difference is that 
the profit/loss of open position is calculated so that only ENTRY commission 
istaken. That's why you get the difference of your commission size if you 
are closing your open position from thecode - then also an EXIT commission 
is included and this amounts for the difference.<FONT 
face="Courier New" size=1>
 
2. Yes in case of reversal commission is taken to close 
existing pos and another one to open a reverse pos.
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
----- Original Message ----- 
<DIV 
>From: 
Steve Dugas 

To: <A title=amibroker@xxxxxxxxxx 
href="">amibroker@xxxxxxxxxxxxxxx 
Sent: Monday, April 22, 2002 6:45 
AM
Subject: [amibroker] gain / loss from 
trades on last bar?

Hi Tomasz and all,
 
I was backtesting a system. I decided that I wanted to 
close out any open position on the last bar of the test so that 
total profit and other report statistics would reflect the most current 
status. So I added the following "OR" condition to my sell and cover 
statements:
 
sell /cover = (original condition) OR Ref(Cum(1),1)== 
LastValue(Cum(1));
 
(Since the system trades on a 1 day delay, I had to trigger 
the signal on the next-to-last bar by looking forward 1 bar)
 
Now the backtester closes out my position on 
the final day, but the gain/loss from that final trade is not 
reflected in many of the items on the report.
Here is one example:
 
<FONT 
size=2>                              
original test         same test 
with open position closed out on last bar
<FONT 
size=2>                              
----------------         
----------------------------------------------------------------------
open position       
-270                                
0     ($270 difference)
total net profit     
-2534                        
-2544     (only $10 difference)
 
The $10 difference in total profit is because I had my 
commisions set to $10 per trade, so this is the commision for the additional 
trade on the last bar. When I changed my commision to $5 per trade to test it, 
the difference changed to $5. Did I find a bug, or is it 
because of the way I did this? Do you know of any workaround? Thank 
you!
 
Steve
 
PS - I noticed one other thing that I havent seen anyone 
mention yet, and I thought it might be useful to mention for people that pay 
points for commisions. The system I was testing is a reversal system (always 
in the market). So if I am long, it sells and then goes short at the same 
time. If I am short, it covers and buys at the same time. The 
backtester charges 2 commisions each time this happens, which makes 
sense because technically I am doing 2 trades, but I think 
that given this situation in real life, this could often be done for the price 
of one commision (i.e. - I am long 1000 shares, I get a signal to reverse 
positions, so I put in one order to sell 2000 shares). I suppose 
it depends on how your broker operates - I believe that my broker, in 
this situation, would automatically sell my 1000 shares and then short another 
1000. Anyway, I just thought people should be aware  - in this type 
of system, if you pay points, you may get more realistic results if 
you enter only half your true commision in the settings, in order to 
compensate. Your 
use of Yahoo! Groups is subject to the <A 
href="">Yahoo! Terms of Service.