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

RE: [amibroker] Re: Code challenge - gurus on your toes!



PureBytes Links

Trading Reference Links










Yes, that’s why I’ve been
batting my head against wall!

 

If you’re trying to develop an
automated system (as I am) and you want Amibroker to give you a signal the night
before the trade is to take place then you have to futz around with the tradedelays
like you helped me get straight yesterday.  Do you think that is the best
solution?

 

Perhaps I should use the equity(0) in the
backtester, scan, explore and just use the status code test to change that to
equity(1) when the formula is used in the indicator? That way I wouldn’t
have to mess with the tradedelays? 

 

d

 

<span
>-----Original Message-----
From: Jayson
[mailto:jcasavant@xxxxxxxxxxxx] 
Sent: Tuesday, March 18, 2003
12:18 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!

<span
> 



<span
>Dale,





<span
> 





<span
>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
> 





<span
>from help.......





<span
> 





<table class=MsoNormalTable border=0 cellspacing=4 cellpadding=0 width="100%"
 >
 
  
  <span
  >SYNTAX<span
  > 
  
  
  <span
  >equity( Flags
  = 0, RangeType = -1, <span
  >From = 0, To = 0 ) 
  
 
 
  
  <span
  >RETURNS
  
  
  <span
  >ARRAY 
  
 
 
  
  <span
  >FUNCTION<span
  > 
  
  
  <span
  >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
  
  <span
  >0<span
  > : (default) Equity works as in 3.98 - just
  calculates the equity array
  1 : 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.
  
  
 






<span
>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
> 



<span
>Jayson 

-----Original
Message-----
From: dingo
[mailto:dingo@xxxxxxxxxx]
Sent: Tuesday, March 18, 2003
11:51 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!

<font size=2 color=blue
face=Tahoma>Thanks
for taking the time to try this!

<font size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>Now
change your formula by adding E = Equity(1); to it so that it looks like:

<font size=2 color=blue
face=Tahoma> 

<font size=1 color=black
face="Courier New">Buy<font size=1 color=black
face="Courier New">=<span
>Cross<font
size=1 color=black face="Courier New">(C,<font
size=1 color=blue face="Courier New">MA<font size=1 color=black
face="Courier New">(C,<font
size=1 color=fuchsia face="Courier New">50<font size=1
color=black face="Courier New">));

<font size=1 color=black
face="Courier New">Sell<font size=1 color=black
face="Courier New">=<span
>Cross<font
size=1 color=black face="Courier New">(<font size=1 color=blue
face="Courier New">MA<span
>(<span
>C,<font size=1 color=fuchsia
face="Courier New">50<span
>),<span
>C);

<font size=1 color=black
face="Courier New">Filter<font size=1 color=black
face="Courier New">=Buy <span
>OR Sell;

<font size=1 color=black
face="Courier New"> 

<font size=1 color=black
face="Courier New">E = <span
>Equity<font
size=1 color=black face="Courier New">(<font size=1 color=fuchsia
face="Courier New">1<span
>);

<font size=1 color=black
face="Courier New"> 

<font size=1 color=blue
face="Courier New">AddColumn<span
>(<span
>Buy,<font size=1
color=fuchsia face="Courier New">"Buy"<font size=1 color=black
face="Courier New">);

<font size=1 color=blue
face="Courier New">AddColumn<span
>(<span
>Sell,<font size=1
color=fuchsia face="Courier New">"sell"<font size=1 color=black
face="Courier New">);

<font size=1 color=green
face="Courier New"> 

<font size=2 color=blue
face=Tahoma>and
rather than use the &#8220;Range Setting&#8221; of &#8220;n last days&#8221;
change that to &#8220;from&#8221; and put in the range &#8220;1/1/2003 &#8211;
2/28/2003&#8221; (to simulate the actual running on the night of the 28th)
and then try it.

<font size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>I&#8217;ve
been adding that equity statement to my formula because I&#8217;m using
applystop and thought it is the recommended method. When I do this you see what
happens.

<font size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>If you
use E = Equity(0); then it reverts back to what you see with the original
formula.

<font size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>d

<font size=2 color=blue
face=Tahoma> 

<span
>-----Original Message-----
From: Jayson
[mailto:jcasavant@xxxxxxxxxxxx] 
Sent: Tuesday, March 18, 2003
11:24 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!

<span
> 



<font size=2 color=blue
face=Arial>Dale,





<font size=2 color=blue
face=Arial>take a
very simple system....





<span
> 





<font size=3 color=black
face="Times New Roman"> 





<font size=2 color=blue
face=Arial>Buy<font
color=blue face=Arial>=Cross(C,MA(C,50));





<font size=2
color=blue face=Arial>Sell<span
>=Cross(MA(<span
>C<font color=black
face=Arial>,50),<span
>C<span
>);





<font size=2 color=blue
face=Arial>Filter<font
color=blue face=Arial>=Buy OR Sell;





<font size=2 color=black
face=Arial>AddColumn<font
size=2 color="#282828">(<font
size=2 color=black>Buy<font
size=2 color="#282828" face=Arial>,<span
>"Buy"<font
size=2 color="#282828" face=Arial>);





<font size=2 color=blue
face=Arial>AddColumn<font
size=2 color="#282828" face=Arial>(<span
>Sell<font
size=2 color="#282828" face=Arial>,<span
>"sell"<font
size=2 color="#282828" face=Arial>);





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color="#282828"
face=Arial>run
the back test on CSCO then click actual trades.





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color="#282828"
face=Arial><img
width=297 height=269 src="gif00143.gif" align=baseline
border=0>





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color=blue
face=Arial>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 size=3 color=blue
face="Times New Roman"> 





<font size=2 color=blue
face=Arial><img
width=744 height=606 src="gif00144.gif" align=baseline
border=0>





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color=blue
face=Arial>To find this
trade the previous night you would run the same code in AA as an
exploration.......





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color=blue
face=Arial><img
width=592 height=252 src="gif00145.gif" align=baseline
border=0>





<font size=3 color=blue
face="Times New Roman"> 





<font size=2 color=blue
face=Arial>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).





<span
> 





<span
> 



<font size=2 color=blue
face=Arial>Jayson


-----Original
Message-----
From: dingo [mailto:dingo@xxxxxxxxxx]
Sent: Tuesday, March 18, 2003
10:10 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Re: Code
challenge - gurus on your toes!

<font size=2 color=blue
face=Tahoma>The
point about using Amibroker to trade the open on the next day was this:

<font size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>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 &#8211; 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 size=2 color=blue
face=Tahoma> 

<font size=2 color=blue
face=Tahoma>d

<font size=2 color=blue
face=Tahoma> 

<span
>-----Original Message-----
From: phsst
[mailto:phsst@xxxxxxxxx] 
Sent: Tuesday, March 18, 2003
12:32 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Code
challenge - gurus on your toes!

<span
> 

<Dale,
you have probably forgotten more about system design than I<font
size=2 face="Courier New">
know but for what it is worth I do use delay=1 and
Price=Open for
evaluation 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 minutes to let the dust
settle. Interday I
plot actual signals based on high or low.
(delay=o)>

I don't target to trade Mkt OPEN either... but
prefer to trade Limit
or Stop orders based upon previous days price
action. 

In the case of Buy Limit orders, I usually
determine the Limit price
from previous days Close, and to my surprise, I
very often get actual
executions at OPEN the following day which are
significantly less than
previous days close (my limit order) and have
experienced positive
trading system outcomes as a result (my primary
trading system is a
pullback system). Also, when this occurs it is not
unusual for the
OPEN to be the low for the day!

You can setup your backtest's for this condition,
and depending upon
your trading system you will observe backtest
results that mirror what
I have encountered in actual trades.

Logically, I thought that MM's would look at limit
orders at open and
take them out before gapping down, but that has
not been my actual
trading experience with these orders (either NYSE
or NASD).

My point is that while you may not want to trade
the OPEN with market
orders... the OPEN is not necessarily your enemy
either... it can be
your friend when your trading system picks out
pullbacks that are
close enough to exhaustion gaps which can be
exploited using Limit orders.

And as far as using Amibroker to signal trades
with delay = 1 and
Price = Open on the evening before the trade...
here is a code snipet
that should come close:

(b is the boolean BUY trigger variable)

b = BUY CONDITION SETUP
PctRisk = C - (L - 0.1) / C;
TargetPrice = HHV(C,10);
PctGain = (TargetPrice - C) / C;
b = b AND PctGain >= 0.12;    //
At least 12% Profit potential
BuyPrice = Min(Ref(C,-1),O); // Lessor of Previous
Close or Todays open
b = b AND BuyPrice > L;
Buy = b;

That should do it, if I have not mis-understood
what you are asking for.

OR simply code BuyPrice = O;

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
> 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,
one for
> the high price, one for the closing price and
one for volume (see
the rows
> labeled 1-5 below) and one for open interest.
These can be
referenced in AFL
> 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
based on
> them then it is an array.  In your
example you used Status to
determine what
> AB was doing (Scan, Explore etc) Since this
state is not stored nor
> calculated from the six arrays you must 
use lastvalue() .
> 
> " 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 to
tell you
> to trade the next morning or do you use some
formula in the AA and run a
> Scan or Explore to tell you?"
> 
> Dale, you have probably forgotten more about
system design than I
know but
> for what it is worth I do use delay=1 and
Price=Open for evaluation
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
minutes
> to let the dust settle. Interday I plot
actual signals based on high
or low.
> (delay=o)
> 
> Regards,
> 
> jayson
> 
> 
> 
> 
> 
> 
> 
> Jayson
> -----Original Message-----
> From: dingo [mailto:dingo@xxxx]
> Sent: Monday, March 17, 2003 4:23 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Code challenge -
gurus on your toes!
> 
> 
> Have I tried it? NO but looks like that is
the magic answer!!!
> 
> 
> 
> I get totally wrapped around the axle to this
day on what is an
array and
> what is not an array.
> 
> 
> 
> If you have the time could you explain how
this works at the
individual bar
> level? If not I understand and really
appreciate this!! It just
might help
> the little light go on in my head (yea,
right!).
> 
> 
> 
> 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 to
tell you
> to trade the next morning or do you use some
formula in the AA and run a
> Scan or Explore to tell you?
> 
> 
> 
> Thanks Jason!  You are great to be here
help us as much as you do!
> 
> 
> 
> d
> 
> 
> 
> -----Original Message-----
> From: Jayson [mailto:jcasavant@xxxx]
> Sent: Monday, March 17, 2003 3:56 PM
> To: amibroker@xxxxxxxxxxxxxxx
> Subject: RE: [amibroker] Code challenge -
gurus on your toes!
> 
> 
> 
> Dale have you tried lastvalue(tmpdelay)
> 
> 
> 
> 
> 
> tmpDelay = IIf(Status("action") ==
5, 1, 0);
> 
> tmpdelay=LastValue(tmpdelay);
> 
> 
> 
> I think this needs to be a fixed number..
> 
> 
> 
> Jayson
> 
> -----Original Message-----
> From: dingo [mailto:dingo@xxxx]
> Sent: Monday, March 17, 2003 3:41 PM
> To: _amibroker_yahoo
> Subject: [amibroker] Code challenge - gurus
on your toes!
> 
> 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
> tester/optimizer or not.
> 
> Here's a feeble attempt that doesn't work:
> 
> tmpDelay = IIf(Status("action") ==
5, 1, 0);
> tmpPrice = IIf(Status("action") ==
5, Open, Close);
> 
> SetTradeDelays(tmpDelay, tmpDelay, tmpDelay,
tmpDelay);
> BuyPrice = SellPrice = ShortPrice =
CoverPrice = tmpPrice;
> 
> Lets see if you can solve this one! 
(Use of vbScript is permissable)
> 
> d
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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
Yahoo! Terms of Service.
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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
Yahoo! Terms of Service.
> 
> 
> 
> 
>       Yahoo!
Groups Sponsor
>            
ADVERTISEMENT
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> 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
Yahoo! Terms of Service.



<span
>Send BUG REPORTS to bugs@xxxxxxxxxxxxx<font
size=2 face="Courier New">
Send 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 Yahoo!
Terms of Service. 

<span
> 



Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send 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 Yahoo!
Terms of Service. 



<span
>Send BUG REPORTS to bugs@xxxxxxxxxxxxx<font
size=2 face="Courier New">
Send 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 Yahoo!
Terms of Service. 

<span
> 

<span
>

Send
BUG REPORTS to bugs@xxxxxxxxxxxxx<font size=2
face="Courier New">
Send 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 Yahoo!
Terms of Service. 




<font size=2
face="Courier New">Send BUG REPORTS to
bugs@xxxxxxxxxxxxx<span
>
Send 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 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: ""