PureBytes Links
Trading Reference Links
|
Collectable
A suggestion is to always have a buy/sell condition as an
unique event. This means it happens on a single bar, rather than many bars. This
helps by immediately removing many unwanted signals. This will save many
headaches later on when you want to condition the sell around the buy bar or
price.
Cond10 = Cross( H, PMH);
Buy = Cond10;
The buy price should then be tied to the day of purchase,
per buy signal and tradedelays.
BuyPrice = Valuewhen( Buy, Max(PMH + 0.01, O) ); //if you
had trade delays set to 1 then use ref(Buy,-1)
The finding highest since the lowest of the last 20 bars
could be this (just an alternative way of doing it)
DaysMH = highestsincebars ( L = ref( LLV( L, 20 ), -1 );
To answer your original problem, you have set the trade
delays to 0, so when it looks for PMH this is defined as the high before the
buy signal, so on the day of the buy it will see only the value of the day
before for PMH. Hope this is not confusing <font size=3
face=Wingdings>L
In your PMH and PML you use valuewhen but you need to
actually define a unique occurrence for this to be useful, else it just looks
at any old possible bar.
<span
>PML = ValueWhen( <font
color=red>L== LLV<span
> (L, Ref(n, -1)), L, 1); //finds the value
of low at lowest low date
PMH = ValueWhen( H== HHV<font
color=blue> (H, Ref(DaysML, -1)), H, 1); //finds the
value of high at highest high date
Hope I have helped a bit, and not confused the issue too
much.
Cheers,
Graham
http://e-wire.net.au/~eb_kavan/
<span
>-----Original Message-----
From: Collectable Images
[mailto:telecard@xxxxxxxxxxxxxx]
Sent: Tuesday, July 06, 2004 9:48
AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] How is this
possible?
<font size=2
face="Times New Roman">
<span
>Now this will find the LOWEST LOW in the last 20 days
and the highest High since that date.
All signals are generated on chart correctly to show the buy and sel ldays
based on this code. ie when price breaks the highest high (PMH) entry is made
so code is referenceing the valuewhen function corectly.
Now, when I look at the actual buy and sell prices obtained it fails to
reference the correct values for PMH and looks like it is taking the value of
the high from the day before the entry.
<font size=2
face="Times New Roman">
<font size=2
face="Times New Roman">I feel I am about to
scream with chasing my self round in circles all week!!
<span
>
DaysML = Ref(LLVBars(L, 20), -1);
//finds the number of days since the lowest low within last 20 days
DaysMH = Ref(HHVBars(H, DaysML), -1); //finds teh highest high since the lowest
low date
PML = ValueWhen(LLVBars(L, Ref(n, -1)), L, 1); //finds the value of low at
lowest low date
PMH = ValueWhen(HHVBars(H, Ref(DaysML, -1)), H, 1); //finds the value of high
at highest high date
Cond10 = H > PMH; //Enter when High of highest day is broken
Buy = Cond10;
BuyPrice = Max(PMH + 0.01, O); //Buy Price criteria Buys at 1 cent break of
Highest price in last (daysML) number of days
Sell = Cross(Ref(LLV(L, 4), -1), L); //sells at break of lowest low in last 4
days
SellPrice = C; //sells at close price of day of break
Buy = ExRem(Buy, Sell);
SetTradeDelays(0, 0, 0, 0);
<font size=2
face="Times New Roman">
Check AmiBroker web page at:<font
face="Courier New">
http://www.amibroker.com/
Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
Yahoo! Groups Links
To visit your group on the web, go to:http://groups.yahoo.com/group/amibroker/
To unsubscribe from this group, send an email to:amibroker-unsubscribe@xxxxxxxxxxxxxxx
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
|