PureBytes Links
Trading Reference Links
|
<font size=3
face="Times New Roman">Hello,
<font size=3
face="Times New Roman">
<font size=3
face="Times New Roman">I found useful
the code posted by Graham with the message 30344, so I have used a part of it
for testing and verify how “<font size=2 color=blue
face="Courier New">SetTradeDelay() function”
works.
<font size=3
face="Times New Roman">Well, starting
an exploration it give me a right buy and sell price in the "results"
window, but the backtesting don't give the same results: the buy and sell
prices don't correspond.
<font size=3
face="Times New Roman">This is the
code I used (tested on one single stock [BRCM], from 01/01/2003 to 31/01/2003):
<font size=2
face="Courier New">
<font size=1
color=green face="Courier New">//Filter= Buy=Cross(C,EMA(C,10)) OR
Cross(EMA(C,10),C);
<font size=1
color=darkred face="Courier New">Filter<font size=1
color=black face="Courier New">= <font size=1
color=darkred face="Courier New">Buy<font size=1
color=black face="Courier New">=<font size=1 color=blue
face="Courier New">DayOfWeek<span
lang=EN-GB >()==<font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New"> <font size=1
color=darkred face="Courier New">OR<font size=1
color=black face="Courier New"> <font size=1
color=darkred face="Courier New">Sell<font size=1
color=black face="Courier New">=<font size=1 color=blue
face="Courier New">DayOfWeek<span
lang=EN-GB >()==<font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=black face="Courier New">
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">O<font size=1
color=black face="Courier New">,<font size=1
color=fuchsia face="Courier New">"Open"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">C<font size=1
color=black face="Courier New">,<font size=1
color=fuchsia face="Courier New">"Close"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">O<font size=1
color=black face="Courier New">,<font size=1
color=fuchsia face="Courier New">"Buy"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">C<font size=1
color=black face="Courier New">,<font size=1
color=fuchsia face="Courier New">"Sell"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<font size=1
color=black face="Courier New">
<font size=1
color=green face="Courier New">//DELAY manual setting
<font size=1
color=black face="Courier New">Buy_Delay = <font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=black face="Courier New">Sell_Delay = <font
size=1 color="#ff6820" face="Courier New">2<font
size=1 color=black face="Courier New">;
<font size=1
color=black face="Courier New">Short_Delay = <font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=black face="Courier New">Cover_Delay = <font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=blue face="Courier New">SetTradeDelays<font size=1
color=black face="Courier New">(Buy_Delay, Sell_Delay, Short_Delay,
Cover_Delay);
<font size=1
color=black face="Courier New">
<font size=1
color=green face="Courier New">//Buy=Cross(C,EMA(C,10));
<font size=1
color=green face="Courier New">//Sell=Cross(EMA(C,10),C);
<font size=1
color=darkred face="Courier New">Buy<font size=1
color=black face="Courier New">=<font size=1 color=blue
face="Courier New">DayOfWeek<span
lang=EN-GB >()==<font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=darkred face="Courier New">Sell<font size=1
color=black face="Courier New">=<font size=1 color=blue
face="Courier New">DayOfWeek<span
lang=EN-GB >()==<font
size=1 color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">;
<font size=1
color=black face="Courier New">
<font size=1
color=darkred face="Courier New">BuyPrice<font size=1
color=black face="Courier New"> = <font size=1
color=blue face="Courier New">Ref<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">O<font size=1
color=black face="Courier New">,Buy_Delay);
<font size=1
color=darkred face="Courier New">SellPrice<font size=1
color=black face="Courier New"> = <font size=1
color=blue face="Courier New">Ref<font size=1
color=black face="Courier New">(<font size=1
color=darkred face="Courier New">C<font size=1
color=black face="Courier New">,Sell_Delay);
<font size=1
color=black face="Courier New">
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(Buy_Delay,<font size=1
color=fuchsia face="Courier New">"Buy Delay"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.0<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1 color=blue
face="Courier New">IIf<span
lang=EN-GB >(<font
size=1 color=darkred face="Courier New">Buy<font size=1
color=black face="Courier New">==<font size=1
color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">,<font size=1
color=darkred face="Courier New">BuyPrice<font size=1
color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">0<font
size=1 color=black face="Courier New">),<font size=1
color=fuchsia face="Courier New">"Delayed Buy Price"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(Sell_Delay,<font size=1
color=fuchsia face="Courier New">"Sell Delay"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.0<font
size=1 color=black face="Courier New">);
<font size=1
color=blue face="Courier New">AddColumn<font size=1
color=black face="Courier New">(<font size=1 color=blue
face="Courier New">IIf<span
lang=EN-GB >(<font
size=1 color=darkred face="Courier New">Sell<font size=1
color=black face="Courier New">==<font size=1
color="#ff6820" face="Courier New">1<font
size=1 color=black face="Courier New">,<font size=1
color=darkred face="Courier New">SellPrice<font size=1
color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">0<font
size=1 color=black face="Courier New">),<font size=1
color=fuchsia face="Courier New">"Delayed Sell Price"<font
size=1 color=black face="Courier New">,<font size=1
color="#ff6820" face="Courier New">1.2<font
size=1 color=black face="Courier New">);
<span
lang=EN-GB >
<span
lang=EN-GB >
<font size=3
face="Times New Roman">Then, if I
change these conditions
<span
lang=EN-GB >
<span
lang=EN-GB >
Buy = DayOfWeek()==1;
<span
lang=EN-GB >
Sell= DayOfWeek()==1;
<span
lang=EN-GB >
<font size=3
face="Times New Roman">with these
ones
<span
lang=EN-GB >
<span
lang=EN-GB >
Buy=Cross(C,EMA(C,10));
<span
lang=EN-GB >
Sell=Cross(EMA(C,10),C);
<span
lang=EN-GB >
<font size=3
face="Times New Roman">both the exploration
and the backtesting seem to work.
<font size=3
face="Times New Roman">What I'm doing
wrong ?
<font size=3
face="Times New Roman">
<font size=3
face="Times New Roman">Thanks for
your valuable help.
<font size=3
face="Times New Roman">
<font size=3
face="Times New Roman">Best <span
lang=EN-GB>Regards
<font size=3
face="Times New Roman">Antonio
Yahoo! Groups Sponsor
ADVERTISEMENT
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.
Attachment:
02 backtesting results.JPG
Description: JPEG image
Attachment:
Attachment:
Description: "Description: JPEG image"
Attachment:
Description: "01 exploration results.JPG"
|