PureBytes Links
Trading Reference Links
|
Al/Gary/and Dave: this is an
excellent thread and I read all messages in it before replying. This came
up once in some conversations I had and the idea was that if the position did
not rise a certain percentage in a specified number of days, then it was sold.
Al, it seems like you are saying to do
this with a n-days stop but my question is how do you “turn off”
the n-days stop if in fact the stock price has appreciated enough that you want
to maintain the trade controlled by a trailing stop???
A variation of this aspect is how do you
write a stop that exits if there is less than y appreciation in the last n days.
IOW, many stocks exhibit a “stair-step” pattern: up for several
days in a row, then horizontal (within some upper and lower consolidation
limits) and then up some more, etc.
Supposedly, you could just stay in the
trade if it appreciated more than your required y percentage in the first n
days, but what if it just then stagnated. You would want to put your
money elsewhere.
My impression is that complex stops like
this need to be programmed manually. I do not see how you can use the builtin
Applystops?? Unless…can these be controlled by IIF statements?
Sitting here trying to write an example and cannot think how I would do it?
Want to see a “home-brew” of
some complex conditions I made up for this and some additional
constraints. This was a nightmare that sort of ran but I abandoned it for
other reasons. This was the section, however, that attempted such a
control of the situation so to speak. I just put some notes in for this
message in purple.
<font size=2 color=black
face="Courier New">Buy1 = <font size=2
color=blue face="Courier New">Cross<font size=2
color=black face="Courier New">(Blevel,CMO) <font size=2
color=red face="Courier New">AND<font size=2 color=black
face="Courier New"> Up;
<font size=2 color=black
face="Courier New">Sell1= EUp;
<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">=<font size=2 color=blue
face="Courier New">ExRem<font size=2
color=black face="Courier New">(Buy1,Sell1);
<font size=2 color=black
face="Courier New">TimeL=<font size=2
color=blue face="Courier New">BarsSince<font size=2
color=black face="Courier New">(<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">==<font size=2
color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">);<font
size=2 color=fuchsia face="Courier New"><<Measuring the
time in trade
<font size=2 color=black
face="Courier New">BPrice=<font size=2
color=blue face="Courier New">ValueWhen<font size=2
color=black face="Courier New">(<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">==<font size=2
color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">,<font size=2
color=red face="Courier New">O<font size=2 color=black
face="Courier New">,<font size=2 color=fuchsia
face="Courier New">1<font size=2 color=black
face="Courier New">);
<font size=2 color=black
face="Courier New">ChangeL=<font size=2
color=fuchsia face="Courier New">100<font
size=2 color=black face="Courier New">*(<font
size=2 color=red face="Courier New">C<font size=2
color=black face="Courier New">-BPrice)/BPrice;<font
size=2 color=fuchsia face="Courier New"><<Change in the
position since purchase
<font size=2 color=black
face="Courier New">TooLongL=TimeL><font
size=2 color=fuchsia face="Courier New">15<font
size=2 color=black face="Courier New"> <font size=2
color=red face="Courier New">AND<font size=2 color=black
face="Courier New"> ChangeL<<font size=2
color=fuchsia face="Courier New">2<font
size=2 color=black face="Courier New">;<font size=2
color=fuchsia face="Courier New"><<Don’t keep if
<2% gain in 15 days
<font size=2 color=black
face="Courier New">TooLongL=<font size=2
color=blue face="Courier New">ExRem<font size=2
color=black face="Courier New">(ToolongL,TimeL<<font
size=2 color=fuchsia face="Courier New">15<font
size=2 color=black face="Courier New">);
<font size=2 color=black
face="Courier New">StopLossL=<font size=2
color=blue face="Courier New">IIf<font size=2 color=black
face="Courier New">(<font size=2 color=blue
face="Courier New">Cross<font size=2
color=black face="Courier New">(-<font size=2
color=fuchsia face="Courier New">13<font
size=2 color=black face="Courier New">,ChangeL),<font
size=2 color=fuchsia face="Courier New">6<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">0<font
size=2 color=black face="Courier New">);<font
size=2 color=fuchsia face="Courier New"><<setting
unique code to tell why an exit
<font size=2 color=black
face="Courier New">StopLOssL=<font size=2
color=blue face="Courier New">ExRem<font size=2
color=black face="Courier New">(StopLossL,<font size=2
color=red face="Courier New">Buy<font size=2 color=black
face="Courier New">);
<font size=2 color=black
face="Courier New">ProfitL=<font size=2
color=blue face="Courier New">IIf<font size=2 color=black
face="Courier New">(<font size=2 color=blue
face="Courier New">Cross<font size=2
color=black face="Courier New">(ChangeL,<font size=2
color=fuchsia face="Courier New">10<font
size=2 color=black face="Courier New">),<font
size=2 color=fuchsia face="Courier New">1<font
size=2 color=black face="Courier New">,<font size=2
color=fuchsia face="Courier New">0<font
size=2 color=black face="Courier New">);<font
size=2 color=fuchsia face="Courier New"><< Profit
target met then sell + set code
<font size=2 color=fuchsia
face="Courier New">
<font size=2 color=fuchsia
face="Courier New">(There is no trailing stop nor feature to stay
with the trailing stop
<font size=2 color=fuchsia
face="Courier New">if the price continues to appreciate, but I
suppose that could be added in
<font size=2 color=fuchsia
face="Courier New">here somehow, somewhere)
<font size=2 color=black
face="Courier New">
<font size=2 color=black
face="Courier New">ProfitL=<font size=2
color=blue face="Courier New">ExRem<font size=2
color=black face="Courier New">(ProfitL,<font size=2
color=red face="Courier New">Buy<font size=2 color=black
face="Courier New">);
<font size=2 color=black
face="Courier New">Above2_15 = <font size=2
color=blue face="Courier New">Flip<font size=2 color=black
face="Courier New">(ChangeL><font size=2
color=fuchsia face="Courier New">2<font
size=2 color=black face="Courier New"> <font size=2
color=red face="Courier New">AND<font size=2 color=black
face="Courier New"> TimeL><font size=2
color=fuchsia face="Courier New">15<font
size=2 color=black face="Courier New">,<font size=2
color=red face="Courier New">Buy<font size=2 color=black
face="Courier New">);
<font size=2 color=black
face="Courier New">Drop2 = Above2_15 <font
size=2 color=red face="Courier New">AND<font size=2
color=black face="Courier New"> <font size=2 color=blue
face="Courier New">Cross<font size=2
color=black face="Courier New">(<font size=2 color=fuchsia
face="Courier New">2<font size=2 color=black
face="Courier New">,ChangeL);
<font size=2 color=black
face="Courier New">Drop2=<font size=2
color=blue face="Courier New">ExRem<font size=2
color=black face="Courier New">(Drop2,<font size=2
color=red face="Courier New">Buy<font size=2 color=black
face="Courier New">);
<font size=2 color=red
face="Courier New">Sell<font size=2 color=black
face="Courier New"> = Sell1 <font size=2
color=red face="Courier New">OR<font size=2 color=black
face="Courier New"> TooLongL <font size=2
color=red face="Courier New">OR<font size=2 color=black
face="Courier New"> StopLossL <font size=2
color=red face="Courier New">OR<font size=2 color=black
face="Courier New"> ProfitL <font size=2
color=red face="Courier New">OR<font size=2 color=black
face="Courier New"> Drop2;
<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">=<font size=2 color=blue
face="Courier New">ExRem<font size=2
color=black face="Courier New">(<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">,<font size=2 color=red
face="Courier New">Sell<font size=2 color=black
face="Courier New">);
<font size=2 color=red
face="Courier New">Sell<font size=2 color=black
face="Courier New">=<font size=2 color=blue
face="Courier New">ExRem<font size=2
color=black face="Courier New">(<font size=2 color=red
face="Courier New">Sell<font size=2 color=black
face="Courier New">,<font size=2 color=red
face="Courier New">Buy<font size=2 color=black
face="Courier New">);
Talk about inefficient coding logic!!! LOL
You can tell I am a brute force kind of clunky coder; some of the experts here
would reduce this to several lines. LOL again.
Can a series of Applystops do
this???? I doubt it.
Ken
-----Original Message-----
From: Al Venosa
[mailto:advenosa@xxxxxxxxxxxx]
Sent: Friday, December 12, 2003
7:02 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] exiting
flat positions
I don't remember, either. Sorry. I simply remember that if their
expected trend faltered but the price still didn't trigger a max stoploss
either, they would get out. I'd have to go back and read it again to find out
what they based it on, but I'm disinclined to do so at the moment. I suspect,
as you did, that it was based on ATR in some way (like if the price didn't move
by 1 or 2 ATR in 2 weeks, exit). You're welcome about the money mgt. stuff.
It's kind of a passion with me.
I'm not sure MFE would do the trick, either. MFE is the maximum
favorable excursion (upward price movement if long), and Dave's example was
when the price wasn't doing diddly squat. Unless you mean that, if the price
didn't reach, say, 0.5*MFE by, say, 1 week from now, get out. Is that what you
mean? Don't know the answer.
----- Original Message -----
<span
>From:<font
size=2 face=Arial> <a
href="" title="serkhoshian777@xxxxxxxxx">Gary A.
Serkhoshian
To:<font size=2
face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx
Sent:<font size=2
face=Arial> Friday, December
12, 2003 6:29 PM
Subject:<font size=2
face=Arial> Re: [amibroker]
exiting flat positions
Hi Al,
Not to sound Clintonesque, but how did the turtles define
"move" as in "they set 2 or maybe 3 weeks to get out if the
price just didn't move at all". I think it was ATR based as were
most of their targets and stops. Don't quite remember.
Maybe MFE is the answer? Just thinking aloud, and sucking up everyone's
extra bandwidth. BTW, thanks for posting all that stuff on Tharpe.
Very helpful.
Kind Regards,
Gary
Al Venosa
<advenosa@xxxxxxxxxxxx> wrote:
Gary:
Well, if the stock doesn't move as you expected it to by a certain time
period, you just exit and get into another trade. The Turtles used that
technique. I think they set 2 or maybe 3 weeks to get out if the price just
didn't move at all. Assuming all other system signals are in place at the time
of the buy, I don't see any reason for not setting a time-based exit if the
stock simply doesn't behave the way it's supposed to. The position performance
simply failed, and since no stoploss has been triggered, you would just
stagnate if you stayed in the trade, so prudence says get out and wait for the next
signal on another stock. You're right, though: lots of options, no clear
solutions.
AV
----- Original Message -----
<span
>From:<font
size=2 face=Arial> <a
href="" title="serkhoshian777@xxxxxxxxx">Gary A.
Serkhoshian
To:<font size=2
face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx
Sent:<font size=2
face=Arial> Friday, December
12, 2003 6:08 PM
Subject:<font size=2
face=Arial> Re: [amibroker]
exiting flat positions
Hi Al,
I thought about that, too. However, it seems that a time-based stop
doesn't tackle the heart of the issue which is position performance (or lack
thereof).
Maybe gate the either a time stop or the stop Dave proposed if a
certain performance threshold hasn't been met by a given time. But then,
that gets us back to determining an intra-trade performance measure which seems
to be the fundamental question.
If the methodology is completely systematized, this lack of performance
will show up in the equity curve, and assuming we have broken below some
minimum threshold objective function for the OOS results maybe it's
time to trip the circuit breaker on the system?
Seems like a multitude of options with no one, clear solution.
Regards,
Gary
Al Venosa
<advenosa@xxxxxxxxxxxx> wrote:
Dave:
Why not try a simple Nbar exit, like:
nBar=Optimize("nbar",6,1,15,1);
ApplyStop( stopTypeNBar, stopModeBars, nbar);
I don't know what your average trade duration is, but whatever it is,
you can set Nbar to get you out at some time point near your average trade
length (or min or max or whatever) if the stock does not move. This plus the
combination of a max stoploss to get you out if the stock moves against you and
a trailing stop to get you out with a profit or a profit target stop might get
you what you want.
Al Venosa
----- Original Message -----
<span
>From:<font
size=2 face=Arial> <a
href="" title="dmerrill@xxxxxxx">Dave Merrill
To:<font size=2
face=Arial> <a
href="" title="amibroker@xxxxxxxxxxxxxxx">amibroker@xxxxxxxxxxxxxxx
Sent:<font size=2
face=Arial> Friday, December
12, 2003 5:39 PM
Subject:<font size=2
face=Arial> RE: [amibroker]
exiting flat positions
<span
>Hi Gary, I saw
your EI post and want to investigate, but unless I'm misunderstanding
something, that's not the issue I'm trying to get at. It seems like you'd
use EI to put you in stocks that move without big changes in volatility,
which I'd think would allow more tailored stops, among other things.
<span
>What I'm
wondering about is positions that don't move at all, or stop moving after
you've held them a while. For instance, say you get a great bump up immediately
after entry, then it just sits there flat. Doesn't hit a stop since it's not
falling, didn't go high enough to hit a target if you have one, just sits.
<span
>My code was an
effort at kicking positions like that out the door at some point, so their
capital can be used for other things. It didn't test out profitably in the
context I checked it though. Not sure what that means.
<span
>Dave
I like your code, and your idea. In terms of an alternative, Al
posted Tharpe's Efficiency Index which addresses chop. Here's his code
and explaination. Regards,
Gary
<span
>Effiency Index (EI) = (C - ref(C,-x)/ATR(x)
An
efficient stock is a stock whose price movements are high relative to its
volatility changes (i.e., the price change is high but the volatility change is
minor). So, if a stock increases by 3 points while its volatility only
increases a little, that's good because it gives you greater profitability at a
given volatility.
I think
the way you would use it would be as a boolean Buy (or Short) qualifier. In
other words, something like this:
Buy =
<your normal buy rules> AND EI > y; //where y is an optimizable
variable.
Dave Merrill
<dmerrill@xxxxxxx> wrote:
Obviously, losses are a problem. But so are positions that hang in
there
forever taking up available cash but going
nowhere, without hitting profit
targets or stops.
How would you code that, assuming you're dealing
with a system that tries to
dump losers but let winners run as long as they're
advancing.
I tried starting from a modest stoploss, with the
stop percentage advancing
every day until it becomes negative, enforcing the
requirement to make a
profit or get off the bus. I'm not certain, but I
think it's working, just
not very profitable in the context I tried it:.
Here's the code:
----------------
bars_since_buy = NZ(BarsSince(buy), BarCount);
bars_since_short = NZ(BarsSince(short), BarCount);
bars_since_entry = IIf(bars_since_buy <
bars_since_short, bars_since_buy,
bars_since_short);
stoploss_rise = Optimize("stoploss
rise", .5, .1, 1, .1);
stoploss = 13 - (stoploss_rise *
bars_since_entry);
ApplyStop(stopTypeLoss, stopModePercent, stoploss,
false, true, 0);
----------------
Anyone see any problems with the implementation?
Any other ideas for
avoiding sitting in stagnant positions?
Dave
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!
Te! ! rms of Service.
<font size=3
face="Times New Roman">
Do you Yahoo!?
<a
href="">New
Yahoo! Photos - easier uploading and sharing
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.
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.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 11/21/2003
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=3
face="Times New Roman">
Do you Yahoo!?
<a
href="">New
Yahoo! Photos - easier uploading and sharing
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.
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=3
face="Times New Roman">
Do you Yahoo!?
<a
href="">New
Yahoo! Photos - easier uploading and sharing
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.
|