PureBytes Links
Trading Reference Links
|
Hello Peter,
I would like to answer your questions to
the best of my knowledge which is to provide you with a tiny program that may
well illustrate most of your questions:
// We want to abbreviate the simple moving average function for the sake of
better readability:
MA45 = <FONT face="Courier New" color=#800080
size=1>MA<FONT face="Courier New" color=#00008b
size=1>(<FONT face="Courier New" color=#ff6820
size=1>close,
45<FONT
face="Courier New" color=#00008b size=1>);<FONT face="Courier New"
color=#ff6820 size=1>
buy =
Cross<FONT
face="Courier New" color=#00008b size=1>(<FONT face="Courier New"
color=#ff6820 size=1>close<FONT face="Courier New" color=#00008b
size=1>, MA45);
sell =
Cross<FONT
face="Courier New" color=#00008b size=1>(MA45, <FONT
face="Courier New" color=#ff6820 size=1>close<FONT face="Courier New"
color=#00008b size=1>);
// For the precursor versions no. 3.59 of AmiBroker the capabilities were
limited to only a forward-reversal system such as this one!
// Note that you should remove the comments to activate the following two
statements:
// short = sell;
// cover = buy;<FONT face="Courier New" color=#00008b
size=1>
// As of AmiBroker version no. 3.59 there have been different short-cover
conditions possible such as these ones:<FONT face="Courier New"
color=#ff6820 size=1>
short =
Cross<FONT
face="Courier New" color=#00008b size=1>(<FONT face="Courier New"
color=#800080 size=1>MA<FONT face="Courier New" color=#00008b
size=1>(<FONT face="Courier New" color=#ff6820
size=1>close,
50<FONT
face="Courier New" color=#00008b size=1>), <FONT face="Courier New"
color=#ff6820 size=1>close<FONT face="Courier New" color=#00008b
size=1>);
cover =
Cross<FONT
face="Courier New" color=#00008b size=1>(<FONT face="Courier New"
color=#ff6820 size=1>close<FONT face="Courier New" color=#00008b
size=1>, <FONT face="Courier New" color=#800080
size=1>MA<FONT face="Courier New" color=#00008b
size=1>(<FONT face="Courier New" color=#ff6820
size=1>close,
40<FONT
face="Courier New" color=#00008b size=1>));
Try this code by copying it into the
Automatic Analyzer window and then activate the button named
Backtest.
The "backtester" in AmiBroker - as it is
commonly referred to by the people in this forum -, simply treats a <FONT
color=#008000>buy signal just like its counterpart,
which is a short signal. The
buy event is finally closed with a
sell event, whereas a <FONT
color=#ff00ff>short order is closed by invoking a <FONT
color=#800080>buyCover event. In order to put it in plain words,
you can initiate a position by either a buy or short entry signal, but you
terminate that position by invoking a sell or buyCover signal! That's the way
the backtester operates. The profit or loss is calculated by taking the
difference of either (sellPrice - buyPrice) * numberPositions to calculate a
long position, or by computing (coverPrice - shortPrice) * numberPositions that
is valid for a short position.
Just experiment for a while with the aforementioned sample code and you may
also tackle another indicator for initiating your entry and exit
positions!
By the way, in reality, the maximum profit for a long position is
unlimited, whereas the highest profit you can make in a short position is
100% but not more: A stock may rise forever when you are long, but a
stock can become worthless and therefore, you earn 100% maximum profit when
being short.
Best regards,
Udo
P.S.: For the sake of clarity and
simplicity, I omitted any commissions here!
<BLOCKQUOTE
>
-----Ursprüngliche Nachricht-----
<DIV
>Von:
peter j
An: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Gesendet: Mittwoch, den 30. April 2003
21:41 Uhr
Betreff: [amibroker] how is the profit
for shorts calculated?
This is about my tenth attempt to post this, i hope the other
posts dont appear.
Hi members.
I have a question about short trades.
Is the profit basically worked out similar to a long profit.
e.g. the buy to sell value
In a short trade could the profit be worked out in reverse (
not in reference to ami, will be used for a spread sheet)
e.g. If the short was $10.00 and the cover was $5,
could i reverse these and say that there was a %100 profit.
or are there oddities when working out the profit of a short
trade.
Peter.
Do you Yahoo!?<A
href="">The New
Yahoo! Search - Faster. Easier. Bingo. Send
BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to
suggest@xxxxxxxxxxxxx-----------------------------------------Post
AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check
group FAQ at: <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the <A
href="">Yahoo! Terms of Service.
Yahoo! Groups Sponsor
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|