PureBytes Links
Trading Reference Links
|
Hi again Ron,
I was just reading my own post and saw a
mistake : - (
The 1 in these two lines should be -1...sorry
about that...
EPrice = ValueWhen( Ref( Buy, 1), Open
);XPrice = ValueWhen( Ref( Sell, 1), Open );
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
Steve Dugas
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Wednesday, September 17, 2003 9:23
PM
Subject: Re: [amibroker] Exploration
Problem
Hi Ron,
I think this may be what you
want. It uses info from the last buy and the last sell, so the profit
calculations won't be correct until you close out your open position (buy
info should be correct though). You can try it and let me know if it is what
you were looking for.
Steve
<FONT face=Arial
size=2>---------------------------------------------------
FastStoch = StochK( 14 );SlowStoch = StochD(
14 );
Buy = Cross( FastStoch, SlowStoch
);Sell = Cross( SlowStoch, FastStoch );
StochKBuy = ValueWhen( Buy, FastStoch
);StochKSell = ValueWhen( Sell, FastStoch );StochKDiff =
StochKSell - StochKBuy;
EPrice = ValueWhen( Ref( Buy, 1), Open
);XPrice = ValueWhen( Ref( Sell, 1), Open );
Rtn = XPrice -
EPrice;PctRtn = Rtn / EPrice * 100;
Filter = C > 1 AND C < 100 AND V >
100000;
AddColumn( StochKBuy, "Buy Value", 1.2
);AddColumn( StochKSell, "Sell Value", 1.2 );AddColumn( StochKDiff,
"%K Diff", 1.2 );AddColumn( EPrice, "Entry $", 1.2 );AddColumn(
XPrice, "Exit $", 1.2 );AddColumn( Rtn, "$ Rtn", 1.2 );AddColumn(
PctRtn, "% Rtn", 1.2 );
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
mrdavis9
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibrokeryahoogroups
Sent: Wednesday, September 17, 2003
7:48 PM
Subject: [amibroker] Exploration
Problem
Steve, thanks for your response. This
email will explain in detail what I hope to accomplish. This
exploration assumes that you have a day job, and are making buy
and sell decisions each night with a fresh download of EOD
data. Therefore, a buy signal and the subsequent sell
signal will never happen on the same day.
I want to be able to read a detailed report of
the results of (buying on the open) of the next day following an
occurrance of my buy condition. My buy condition is
Cross(stochkd(14),stochd(14)). My sell condition will
occur when the next
cross(stochd(14),stochk(14)) makes it's
appearance in one of the daily downloads of EOD data.
The actual sell will occur at the opening price of the
day after the sell condition appeared.
eg, (selling on the open).
Below is the complete exploration. The seven "plot(xxxxxx" lines
of code at the bottom of this exploration are my attempt to set up the
column titles for displaying the data that I want to be able
to analyze.
I could actually feel some of the gears in my brain grinding as I tried
to understand the proper way to use ValueWhen and
BarsSince. I hope we can get this working. Ron
D
<FONT face=Arial
size=2>==========================================================================
BuyStocVal=<FONT color=#0000ff
size=1>ValueWhen(<FONT color=#0000ff
size=1>Cross(<FONT color=#0000ff
size=1>StochK(<FONT color=#ff00ff
size=1>14),<FONT color=#0000ff
size=1>StochD(<FONT color=#ff00ff
size=1>14)),<FONT color=#0000ff
size=1>StochK(<FONT color=#ff00ff
size=1>14),<FONT color=#ff00ff
size=1>1);<FONT face="Courier New" color=#008000
size=1>//This is the value of StochK(14)
when the buycross occurred.
SellStocVal=ValueWhen<FONT
size=1>(Cross<FONT
size=1>(StochD<FONT
size=1>(14<FONT
size=1>),StochK<FONT
size=1>(14<FONT
size=1>)),StochK<FONT
size=1>(14<FONT
size=1>),BarsSince<FONT
size=1>(Cross<FONT
size=1>(StochK<FONT
size=1>(14<FONT
size=1>),StochD<FONT
size=1>(14<FONT
size=1>)));<FONT face="Courier New" color=#008000
size=1>//StochK(14) value at
sellcross.
StocRise=SellStocVal-BuystocVal; < the difference in the <FONT
color=#0000ff size=1>StochK(<FONT color=#ff00ff
size=1>14)<FONT face="Courier New" color=#008000
size=1>// Buy AND Sell values, assumed to
be a positive value.
Entryprice=ValueWhen<FONT
size=1>(Cross<FONT
size=1>(StochK<FONT
size=1>(14<FONT
size=1>),StochD<FONT
size=1>(14<FONT
size=1>)),Ref<FONT
size=1>(Open,0<FONT
size=1>),1<FONT
size=1>);//<FONT
color=#008000 size=1>opening price on the Day the Buy
occurrs.
Exitprice=ValueWhen<FONT
size=1>(Cross<FONT
size=1>(StochD<FONT
size=1>(14<FONT
size=1>),StochK<FONT
size=1>(14<FONT
size=1>)),Ref<FONT
size=1>(Open,0<FONT
size=1>),BarsSince<FONT
size=1>(Cross<FONT
size=1>(StochK<FONT
size=1>(14<FONT
size=1>),StochD<FONT
size=1>(14<FONT
size=1>)));<FONT face="Courier New" color=#008000
size=1>//Open price of Sell
Day.
Pricerise=Exitprice-entryprice<FONT face="Courier New"
size=1>;//<FONT
color=#008000 size=1>The difference between the two opening
prices.
percentrise=pricerise/entryprice;<FONT face="Courier New"
color=#008000 size=1>//The % of increase
on the value of the Open price when the Buy occurred.
Filter=C><FONT
face="Courier New" color=#ff00ff size=1>1<FONT face="Courier New"
size=1> AND C<<FONT face="Courier New" color=#ff00ff
size=1>100 AND
V><FONT face="Courier New" color=#ff00ff
size=1>100000 AND Buystocval
AND Sellstocval AND stocrise AND entryprice AND
exitprice AND pricerise AND percentrise;<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(BuyStocVal,<FONT
face="Courier New" color=#ff00ff size=1>"Buy Value"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(SellStocVal,<FONT
face="Courier New" color=#ff00ff size=1>"Sell Value"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(StocRise,<FONT
face="Courier New" color=#ff00ff size=1>"Stoc Rise"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(Entrypric,<FONT
face="Courier New" color=#ff00ff size=1>"Buy price"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(Exitprice,<FONT
face="Courier New" color=#ff00ff size=1>"Sell price"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(Pricerise,<FONT
face="Courier New" color=#ff00ff size=1>"Price rise"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);<FONT
face="Courier New" color=#0000ff size=1>
AddColumn(percentrise,<FONT
face="Courier New" color=#ff00ff size=1>"% change"<FONT
face="Courier New" size=1>,format=<FONT face="Courier New"
color=#ff00ff size=1>1.2<FONT face="Courier New"
size=1>,textcolor=colorDefault,bkgndcolor=colorDefault);
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.
|