PureBytes Links
Trading Reference Links
|
Hello,
Equity(1) emulates delays also therefore delays will affect
the results.
You have to remember that Equity() function is
backtester-in-a-box.
It uses EXACTLY the same code as Backtest button
uses.
Therefore it reacts on ALL backtester settings.
I suggest to use backtest to backtest and explore to
explore.
If you really want to use Exploration mode with
Equity(1)
I suggest to set all built-in delays to ZERO and manage delays
from
the code using just REF() function:
Buy = Ref( Buy, -1 ); // one bar delay
This will be easier for you to understand and exploration
with
Equity(1) will work like exploration without
Equity(1).
(because delays would not affect the signals)
Best regards,Tomasz
Janeczkoamibroker.com
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
<A title=jcasavant@xxxxxxxxxxxx
href="">Jayson
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Tuesday, March 18, 2003 6:18
PM
Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!
<SPAN
class=001380717-18032003>Dale,
<SPAN
class=001380717-18032003>
The
devil is always in the details! Adding the equity line does indeed change the
results of the exploration. I think perhaps the (partial) answer is
found in Help...
<SPAN
class=001380717-18032003>
from
help.......
<SPAN
class=001380717-18032003>
SYNTAX
equity(
Flags = 0, RangeType = -1, From = 0, To = 0
)
RETURNS
ARRAY
FUNCTION
Returns Equity line based on
buy/sell/short/cover rules, buy/sell/short/coverprice arrays, all apply
stops, and all other back tester settings. Flags - defines the
behavior of Equity function
0 : (default) Equity works as in 3.98 - just
calculates the equity array1 : works as 0 but additionally
updates buy/sell/short/cover arrays so all redundant signals are
removed exactly as it is done internally by the back tester plus all
exits by stops are applied so it is now possible to visualize
ApplyStop() stops.<FONT
size=2>
It
certainly appears that equity(1) also emulates the backrest results for the
delay=1 as well since changing the setting in AA to delay=0 and running the
code with equity(1) returns the expected result.
<SPAN
class=001380717-18032003> <FONT face=Arial
color=#0000ff size=2>Jayson
<FONT face=Tahoma
size=2>-----Original Message-----From: dingo
[mailto:dingo@xxxxxxxxxx]Sent: Tuesday, March 18, 2003 11:51
AMTo: amibroker@xxxxxxxxxxxxxxxSubject: RE: [amibroker]
Re: Code challenge - gurus on your toes!
<SPAN
>Thanks for taking
the time to try this!
<SPAN
>
<SPAN
>Now change your
formula by adding E = Equity(1); to it so that it looks
like:
<SPAN
>
<SPAN
>Buy<FONT
face="Courier New" color=black size=1><SPAN
>=<FONT
face="Courier New" color=blue size=1><SPAN
>Cross<FONT
face="Courier New" color=black size=1><SPAN
>(<SPAN
>C,<FONT face="Courier New"
color=blue size=1><SPAN
>MA<FONT
face="Courier New" color=black size=1><SPAN
>(<SPAN
>C,<FONT face="Courier New"
color=fuchsia size=1><SPAN
>50<FONT
face="Courier New" color=black size=1><SPAN
>));
<SPAN
>Sell<FONT
face="Courier New" color=black size=1><SPAN
>=<FONT
face="Courier New" color=blue size=1><SPAN
>Cross<FONT
face="Courier New" color=black size=1><SPAN
>(<FONT
face="Courier New" color=blue size=1><SPAN
>MA<FONT
face="Courier New" color=black size=1><SPAN
>(<SPAN
>C,<FONT face="Courier New"
color=fuchsia size=1><SPAN
>50<FONT
face="Courier New" color=black size=1><SPAN
>),<SPAN
>C);
<SPAN
>Filter<FONT
face="Courier New" color=black size=1><SPAN
>=<SPAN
>Buy <SPAN
>OR <SPAN
>Sell;
<SPAN
>
<SPAN
>E =
<SPAN
>Equity<FONT
face="Courier New" color=black size=1><SPAN
>(<FONT
face="Courier New" color=fuchsia size=1><SPAN
>1<FONT
face="Courier New" color=black size=1><SPAN
>);
<SPAN
>
<SPAN
>AddColumn<FONT
face="Courier New" color=black size=1><SPAN
>(<SPAN
>Buy,<FONT
face="Courier New" color=fuchsia size=1><SPAN
>"Buy"<FONT
face="Courier New" color=black size=1><SPAN
>);
<SPAN
>AddColumn<FONT
face="Courier New" color=black size=1><SPAN
>(<SPAN
>Sell,<FONT
face="Courier New" color=fuchsia size=1><SPAN
>"sell"<FONT
face="Courier New" color=black size=1><SPAN
>);
<SPAN
>
<SPAN
>and rather than use
the “Range Setting” of “n last days” change that to “from” and put in the
range “1/1/2003 – 2/28/2003” (to simulate the actual running on the night of
the 28th) and then try it.
<SPAN
>
<SPAN
>I’ve been adding
that equity statement to my formula because I’m using applystop and thought it
is the recommended method. When I do this you see what
happens.
<SPAN
>
<SPAN
>If you use E =
Equity(0); then it reverts back to what you see with the original
formula.
<SPAN
>
<SPAN
>d
<SPAN
>
<SPAN
>-----Original
Message-----From: Jayson
[mailto:jcasavant@xxxxxxxxxxxx] <SPAN
>Sent: Tuesday, March 18, 2003 11:24
AMTo:
amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!
<FONT face="Times New Roman"
size=3>
<FONT face=Arial color=blue
size=2><SPAN
>Dale,
<FONT face=Arial color=blue
size=2>take a
very simple system....
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
color=black size=3><SPAN
>
<FONT face=Arial color=blue
size=2><SPAN
>Buy<FONT
face=Arial color=blue><SPAN
>=Cross(C,MA(C,50));
<FONT face=Arial
color=blue size=2><SPAN
>Sell<FONT
face=Arial color=black size=2><SPAN
>=Cross(MA(<SPAN
>C<FONT face=Arial
color=black>,50),<SPAN
>C<FONT face=Arial
color=blue><SPAN
>);
<FONT face=Arial color=blue
size=2><SPAN
>Filter<FONT
face=Arial color=blue>=Buy OR
Sell;
<FONT face=Arial color=black
size=2><SPAN
>AddColumn<FONT
color=#282828 size=2><SPAN
>(<FONT color=black
size=2><SPAN
>Buy<FONT
face=Arial color=#282828 size=2><SPAN
>,<FONT
face=Arial color=fuchsia size=2><SPAN
>"Buy"<FONT
face=Arial color=#282828 size=2><SPAN
>);
<FONT face=Arial color=blue
size=2><SPAN
>AddColumn<FONT
face=Arial color=#282828 size=2><SPAN
>(<FONT
face=Arial color=black size=2><SPAN
>Sell<FONT
face=Arial color=#282828 size=2><SPAN
>,<FONT
face=Arial color=fuchsia size=2><SPAN
>"sell"<FONT
face=Arial color=#282828 size=2><SPAN
>);
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=#282828
size=2>run
the back test on CSCO then click actual trades.
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=#282828
size=2><IMG
height=269 src="gif00149.gif" width=297
align=baseline border=0>
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=blue
size=2>Here you
see the actual cross over occurred on 2/28 (circled) the trade arrow in back
test shows the following day 3/3 (delay=1)
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=blue
size=2><IMG
height=606 src="gif00150.gif" width=744
align=baseline border=0>
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=blue
size=2>To find
this trade the previous night you would run the same code in AA as an
exploration.......
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=blue
size=2><IMG
height=252 src="gif00151.gif" width=592
align=baseline border=0>
<FONT face="Times New Roman"
color=blue size=3><SPAN
>
<FONT face=Arial color=blue
size=2>As you
see the explore correctly identifies the 2/28 buy as well as the 3/3 sell
ahead of the trade arrows generated by the back test. If you are looking at
EOD on 2/28 you would place the buy order that evening as a market order. This
would execute on the 3/3 open (for better or worse).
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
size=3>
<FONT face=Arial color=blue
size=2><SPAN
>Jayson
<P class=MsoNormal
><FONT
face=Tahoma size=2><SPAN
>-----Original
Message-----From: dingo
[mailto:dingo@xxxxxxxxxx]<SPAN
>Sent: Tuesday, March 18, 2003 10:10
AMTo:
amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!
<FONT face=Tahoma color=blue
size=2>The
point about using Amibroker to trade the open on the next day was
this:
<FONT face=Tahoma color=blue
size=2><SPAN
>
<FONT face=Tahoma color=blue
size=2>Take a
simple system you have in your files and run a back test on it for a date
range of your choice. (be sure and have your settings = delay = 1,
open). Look down the trade list and pick any date where a position is
taken and write that date down. Now pretend that you are processing your
data (assuming you are using EOD data) on the night BEFORE the date you wrote
down – trying to see what trades, if any, you will have to set up for the next
day. Now run a Scan or Explore and tell me if you see any evidence of a
trade for the next day? What do you do to know that you need to put in
an order?
<FONT face=Tahoma color=blue
size=2><SPAN
>
<FONT face=Tahoma color=blue
size=2><SPAN
>d
<FONT face=Tahoma color=blue
size=2><SPAN
>
<SPAN
>-----Original
Message-----From: phsst
[mailto:phsst@xxxxxxxxx] <SPAN
>Sent: Tuesday, March 18, 2003 12:32
AMTo:
amibroker@xxxxxxxxxxxxxxx<SPAN
>Subject: [amibroker] Re: Code challenge -
gurus on your toes!
<FONT face="Times New Roman"
size=3>
<P class=MsoNormal
><FONT
face="Courier New" size=2><Dale, you have
probably forgotten more about system design than I<FONT
face="Courier New" size=2><SPAN
><FONT
face="Courier New">know but for what it is worth I do use delay=1 and
Price=Open forevaluation and back
testing in AA, although in practice I seldom<FONT
face="Courier New">actual buy the open. I have been burned too many times by
this ficklemarket. Instead I wait
30 minutes to let the dust settle. Interday I<FONT
face="Courier New">plot actual signals based on high or low.
(delay=o)>I don't target
to trade Mkt OPEN either... but prefer to trade Limit<FONT
face="Courier New">or Stop orders based upon previous days price action.
In the case of Buy Limit
orders, I usually determine the Limit price<FONT
face="Courier New">from previous days Close, and to my surprise, I very often
get actualexecutions at OPEN the
following day which are significantly less than<FONT
face="Courier New">previous days close (my limit order) and have experienced
positivetrading system outcomes
as a result (my primary trading system is a<FONT
face="Courier New">pullback system). Also, when this occurs it is not unusual
for theOPEN to be the low for the
day!You can setup your
backtest's for this condition, and depending upon<FONT
face="Courier New">your trading system you will observe backtest results that
mirror whatI have encountered in
actual trades.Logically, I
thought that MM's would look at limit orders at open
andtake them out before gapping
down, but that has not been my actual<FONT
face="Courier New">trading experience with these orders (either NYSE or
NASD).My point is that while
you may not want to trade the OPEN with market<FONT
face="Courier New">orders... the OPEN is not necessarily your enemy either...
it can beyour friend when your
trading system picks out pullbacks that are<FONT
face="Courier New">close enough to exhaustion gaps which can be exploited
using Limit orders.And as far
as using Amibroker to signal trades with delay = 1
andPrice = Open on the evening
before the trade... here is a code snipet<FONT
face="Courier New">that should come close:<FONT
face="Courier New">(b is the boolean BUY trigger
variable)b = BUY CONDITION
SETUPPctRisk = C - (L - 0.1) /
C;TargetPrice =
HHV(C,10);PctGain = (TargetPrice
- C) / C;b = b AND PctGain >=
0.12; // At least 12% Profit
potentialBuyPrice =
Min(Ref(C,-1),O); // Lessor of Previous Close or Todays
openb = b AND BuyPrice >
L;Buy =
b;That should do it, if I
have not mis-understood what you are asking for.<FONT
face="Courier New">OR simply code BuyPrice = O;<FONT
face="Courier New">Phsst---
In amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx>
wrote:>
Dale,>
> Often I just guess
<G>>
> Help defines an array
as....> What is an
Array?>
> An array is simply a list
(or row) of values. In some books it may be<FONT
face="Courier New">> referred to as a vector. Each numbered row of values
in the example> represents an
individual array. Amibroker has stored in its database
6> arrays for each stock. One
for opening price, one for the low price,<FONT
face="Courier New">one for>
the high price, one for the closing price and one for volume
(seethe
rows> labeled 1-5 below) and
one for open interest. These can be<FONT
face="Courier New">referenced in AFL<FONT
face="Courier New">> as open, low, high, close, volume, openint or o, l, h,
c, v, oi.>
> If you are referencing one
of the 6 arrays or making calculations<FONT
face="Courier New">based on>
them then it is an array. In your example you used Status
todetermine
what> AB was doing (Scan,
Explore etc) Since this state is not stored nor<FONT
face="Courier New">> calculated from the six arrays you must use
lastvalue() .>
> " One more thing: Do you use
Amibroker to signal trades with delay =<FONT
face="Courier New">1 and>
Price = Open? On the evening before the trade do you use plots
totell
you> to trade the next morning
or do you use some formula in the AA and run a<FONT
face="Courier New">> Scan or Explore to tell you?"<FONT
face="Courier New">> >
Dale, you have probably forgotten more about system design than
Iknow
but> for what it is worth I do
use delay=1 and Price=Open for evaluation<FONT
face="Courier New">and back>
testing in AA, although in practice I seldom actual buy the open. I
have> been burned too many
times by this fickle market. Instead I wait 30<FONT
face="Courier New">minutes> to
let the dust settle. Interday I plot actual signals based on
highor
low.>
(delay=o)>
>
Regards,>
>
jayson>
> <FONT
face="Courier New">> >
> <FONT
face="Courier New">> >
>
Jayson> -----Original
Message-----> From: dingo
[mailto:dingo@xxxx]> Sent:
Monday, March 17, 2003 4:23 PM<FONT
face="Courier New">> To: amibroker@xxxxxxxxxxxxxxx<FONT
face="Courier New">> Subject: RE: [amibroker] Code challenge - gurus on
your toes!>
> <FONT
face="Courier New">> Have I tried it? NO but looks like that is the magic
answer!!!>
> <FONT
face="Courier New">> > I
get totally wrapped around the axle to this day on what is
anarray
and> what is not an
array.>
> <FONT
face="Courier New">> > If
you have the time could you explain how this works at
theindividual
bar> level? If not I
understand and really appreciate this!! It just<FONT
face="Courier New">might help>
the little light go on in my head (yea, right!).<FONT
face="Courier New">> >
> <FONT
face="Courier New">> One more thing: Do you use Amibroker to signal trades
with delay = 1 and> Price =
Open? On the evening before the trade do you use plots
totell
you> to trade the next morning
or do you use some formula in the AA and run a<FONT
face="Courier New">> Scan or Explore to tell you?<FONT
face="Courier New">> >
> <FONT
face="Courier New">> Thanks Jason! You are great to be here help us
as much as you do!>
> <FONT
face="Courier New">> >
d> <FONT
face="Courier New">> >
> -----Original
Message-----> From: Jayson
[mailto:jcasavant@xxxx]> Sent:
Monday, March 17, 2003 3:56 PM<FONT
face="Courier New">> To: amibroker@xxxxxxxxxxxxxxx<FONT
face="Courier New">> Subject: RE: [amibroker] Code challenge - gurus on
your toes!>
> <FONT
face="Courier New">> > Dale
have you tried lastvalue(tmpdelay)<FONT
face="Courier New">> >
> <FONT
face="Courier New">> >
> tmpDelay =
IIf(Status("action") == 5, 1, 0);<FONT
face="Courier New">> >
tmpdelay=LastValue(tmpdelay);>
> <FONT
face="Courier New">> > I
think this needs to be a fixed number..<FONT
face="Courier New">> >
> <FONT
face="Courier New">> Jayson<FONT
face="Courier New">> >
-----Original Message----->
From: dingo [mailto:dingo@xxxx]<FONT
face="Courier New">> Sent: Monday, March 17, 2003 3:41
PM> To:
_amibroker_yahoo> Subject:
[amibroker] Code challenge - gurus on your toes!<FONT
face="Courier New">> > I'm
trying to write some AFL code that will change the trade delays
and> trade prices based solely
on whether the code is being run in the back<FONT
face="Courier New">> tester/optimizer or not.<FONT
face="Courier New">> >
Here's a feeble attempt that doesn't work:<FONT
face="Courier New">> >
tmpDelay = IIf(Status("action") == 5, 1, 0);<FONT
face="Courier New">> tmpPrice = IIf(Status("action") == 5, Open,
Close);>
> SetTradeDelays(tmpDelay,
tmpDelay, tmpDelay, tmpDelay);<FONT
face="Courier New">> BuyPrice = SellPrice = ShortPrice = CoverPrice =
tmpPrice;>
> Lets see if you can solve
this one! (Use of vbScript is permissable)<FONT
face="Courier New">> >
d> <FONT
face="Courier New">> >
> Send BUG REPORTS to
bugs@xxxx> Send SUGGESTIONS to
suggest@xxxx>
-----------------------------------------<FONT
face="Courier New">> Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx> (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">>
--------------------------------------------<FONT
face="Courier New">> Check group FAQ at:<FONT
face="Courier New">> <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face="Courier New">> > Your
use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.>
> <FONT
face="Courier New">> >
> Send BUG REPORTS to
bugs@xxxx> Send SUGGESTIONS to
suggest@xxxx>
-----------------------------------------<FONT
face="Courier New">> Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx> (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">>
--------------------------------------------<FONT
face="Courier New">> Check group FAQ at:<FONT
face="Courier New">> <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face="Courier New">> > Your
use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.>
> <FONT
face="Courier New">> >
<FONT
face="Courier New">> Yahoo! Groups
Sponsor<FONT
face="Courier New">>
ADVERTISEMENT>
> <FONT
face="Courier New">> >
> Send BUG REPORTS to
bugs@xxxx> Send SUGGESTIONS to
suggest@xxxx>
-----------------------------------------<FONT
face="Courier New">> Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx> (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">>
--------------------------------------------<FONT
face="Courier New">> Check group FAQ at:<FONT
face="Courier New">> <A
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html<FONT
face="Courier New">> > Your
use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.
<FONT face="Courier New"
size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">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.
<FONT face="Times New Roman"
size=3>
<FONT face="Times New Roman"
size=3><FONT
face="Courier New" size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">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. <FONT
face="Courier New" size=2>Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<SPAN
><FONT
face="Courier New">Send SUGGESTIONS to
suggest@xxxxxxxxxxxxx<FONT
face="Courier New">-----------------------------------------<FONT
face="Courier New">Post AmiQuote-related messages ONLY to:
amiquote@xxxxxxxxxxxxxxx (Web
page: <A
href="">http://groups.yahoo.com/group/amiquote/messages/)<FONT
face="Courier New">--------------------------------------------<FONT
face="Courier New">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.
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.
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
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:
Description: ""
Attachment:
Description: ""
Attachment:
Description: ""
|