PureBytes Links
Trading Reference Links
|
Hi Ed,
OK, I see your point. I dont believe the buy array
gets shifted - my guess would be that it is probably handled by
creating another array of actual buys - which is good because it allows us to
see both signals and actual trades.
The "n-th most recent works like this - suppose you
want to get the value of the close the LAST time it crossed above its 50 bar MA.
Then n-th most recent = 1. To get the close on the previous time this occured
(i.e. - 2nd most recent occurance), use n-th = 2, etc, etc...
One helpful way to check your results every step of
the way, and debug your formulas is to look at the arrays you have created. For
example, to see the value of the 10-period MA of the close for the last 100
bars, go to analysis window, set "n=" to last qoutes and type 100 into the box.
Then print it to the results window:
MovAvg = MA( Close, 10 );
filter = 1;
addcolumn( MovAvg, "close", 1.2 );
You will get 100 rows containing this value for the
last 100 days. You can look at all your arrays this way, including buy, sell,
etc. It can be very helpful, especially when you are building array upon
array, to check your results each step of the way.
Steve
<BLOCKQUOTE
>
----- Original Message -----
<DIV
>From:
ed2000nl
To: <A title=amibroker@xxxxxxxxxxxxxxx
href="">amibroker@xxxxxxxxxxxxxxx
Sent: Monday, September 29, 2003 6:26
PM
Subject: [amibroker] Re: help with
trading system
thanks Steve,but I basicly understand what
ValueWhen() does. In principle ValueWhen(Buy, Open) is the same as Open,
or it returns the values of the Open array at the positions where the Buy
array is true.The point I did not understand is with the delay.
Apparently the Buy array remains unchanged if I set the buydelay to 1. I
would have thought that the positions of the "1" numbers inside the buy
array would shift 1 position to the right.If this were so then I
could have used ValueWhen(Buy,Open) even though I set the buydelay to
1.I must admit that I do not understand the definition of ValueWhen in
the help files with respect to the third parameter n: "n-th most
recent occurence". So I wonder if I still could use ValueWhen as I did
originally if I put some value there for n .....I have a bit of a hard
time learning AFL. I have to find out how I can work with it interactively
in order to find out what I am doing every step op the
way.regards, Ed --- In
amibroker@xxxxxxxxxxxxxxx, "Steve Dugas" <sjdugas@xxxx> wrote:>
Hi Ed,> > You can look at Valuewhen() like this:>
Variable = valuewhen( A, B );> is the same as saying> Variable =
the VALUE of B WHEN A occurs;> > So...> > BuyPrice
= ValueWhen(Buy, Open);> is the same as saying> BuyPrice = the
VALUE of open WHEN a signal occurs in the "Buy" array (i.e. - no
delay).> > Steve> > > ----- Original
Message ----- > From: ed2000nl > To:
amibroker@xxxxxxxxxxxxxxx > Sent: Monday, September 29,
2003 5:35 PM> Subject: [amibroker] Re: help with trading
system> > > OK thanks. I see I have a lot
more studying and playing ahead of me. > I'm not sure
if I understand the bit about ValueWhen() completely but
> for now I will not use it if I also use SetTradeDelays().
> > thanks and> regards,
Ed> > > --- In amibroker@xxxxxxxxxxxxxxx,
"Tomasz Janeczko" <amibroker@xxxx> >
wrote:> > Hello,> >
> > > thanks. I found the proper buy and sell
signals. Still I am > > > puzzled ... my super simple
code does not give proper results. If > I
> > > execute this code on CTMI I get 3 trades.
However, it not always > buys > >
> at the open like I tell it to. Do you agree when looking at the
> code > > > below that it
*always* should buy at the open?> > >
> No. To buy always at open you should write:> >
> > BuyPrice = Open;> >
> > (isn't this obvious ?)> >
> > If you write> >
> > BuyPrice = ValueWhen(Buy, Open);>
> > > and you SET DELAY > 0>
> this code actually attempts to buy at OPEN price WHEN NON DELAYED
> buy> > occurred. Since trading is
delayed as per your setting the open of> > N-days
before may NOT fit into High-LOW range of the bar when>
> ACTUAL TRADE takes place so AmiBroker must readjust it
to> > fit into H-L range (what ever is nearer your
desired price).> > > >
> > Hope this helps.> >
> > Best regards,> > Tomasz
Janeczko> > amibroker.com> > -----
Original Message ----- > > From: "ed2000nl"
<pablito@xxxx>> > To:
<amibroker@xxxxxxxxxxxxxxx>> > Sent: Monday,
September 29, 2003 10:47 PM> > Subject: [amibroker] Re:
help with trading system> > > >
> > > Jayson,> > >
> > > > > How can this be
explained?> > > > > >
regards, Ed> > > > > >
//---------------------------------------------------->
> > // overide default settings, set buy delay at 1
bar> > > SetTradeDelays(1,0,0,0);>
> > > > > // make a simple trading
system> > > Buy =
Cross(RSI(),30);> > > > > >
// define the BuyPrice> > > BuyPrice = ValueWhen(
Buy, Open);> > > > > > //
define the sell condition> > > SellCond1 = C >
BuyPrice * 1.02; > > > SellCond2 = C < BuyPrice *
0.96; > > > SellCond3 = Cross( BarsSince(Buy), 5 );
> > > > > > Sell = SellCond1
OR SellCond2 OR SellCond3;> > > >
> > // define the SellPrice> > > SellPrice =
ValueWhen( Sell, Close);> > > >
> > Buy = ExRem(Buy,Sell);> > > Sell =
ExRem(Sell,Buy);> > >
//---------------------------------------------------->
> > > > > > > >
backtest:> > > > > > CTMI
Long 7/25/2002 15.7500 7/25/2002 16.5900 5.3%> > >
533.33 5.3% 634.921 10000 533.333 1 5.33%> > > CTMI
Out 7/25/2002 16.5900 3/14/2003 17.8190 7.4%> > >
0.00 0.0% 0 0 533.333 160 0.00%> > > CTMI Long
3/14/2003 17.8190 3/14/2003 18.5100 3.9%> > > 408.47
3.9% 591.129 10533.3 941.804 1 3.88%> > > CTMI Out
3/14/2003 18.5100 8/22/2003 13.1000 -29.2%> > > 0.00
0.0% 0 0 941.804 112 0.00%> > > CTMI Long 8/22/2003
13.1000 8/26/2003 13.5800 3.7%> > > 400.92 3.7%
835.252 10941.8 1342.72 3 1.22%> > > CTMI Out
8/26/2003 13.5800 9/26/2003 14.0000 3.1%> > > 0.00
0.0% 0 0 1342.72 22 0.00%> > > >
> > > > > > > >
> > > > > > --- In
amibroker@xxxxxxxxxxxxxxx, "Jayson" <jcasavant@xxxx>
wrote:> > > > Are you simply double clicking
the trade to plot the arrows or > have
> > > you> > > > right
clicked then chosen "Show actual trades"??> > > >
> > > > Try this... create a new indicator
with this code.....> > > > >
> > > > > > > x =
Cross(RSI(),30);> > > >
Plot(RSI(),"",5,1);> > > >
PlotGrid(30,colorWhite);> > > >
Plot(x,"",4,2|styleOwnScale);> > > >
> > > > The red lines will show the actual cross.
Now run this simple > > > system
test...> > > > > > > >
> > > >
SetTradeDelays(3,0,0,0);> > > > Buy=
Cross(RSI(),30);> > > >
Sell=Cross(30,RSI());> > > > >
> > > Test over enough days to be sure you get a signal. Next rt
> click a > > > trade
and> > > > choose "Show actual trade". I believe
you will see the arrow to > be >
> > 3 days> > > > after the red line
cross..> > > > > > > >
> > > > > > > >
> > > > > > > >
Regards,> > > > Jayson> >
> 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 > <A
href="">http://docs.yahoo.com/info/terms/
> > > > > >
> > >> >
> 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.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.
|