PureBytes Links
Trading Reference Links
|
Dave:
I hope you got through your furniture move alright. I know I hate it when I
have to do it.
The problem I'm working on now is getting the Exits to be a little less
sensitive. In my Triple MA Crossovers indicator I've defined FalseLong and
FalseShort to be when the Sma slips back below the Mma. The value of this
valiable is used in the Positions indicator to determine if a Long position
still holds. If the FalseLong is true then the Position should not be Long.
This is working but the exit is being triggered even if true for one day.
Then, if it isn't true the next day, the Position goes long again. Here's
the code:
Triple MA Crossovers:
Sma := FmlVar("_Triple MA","ShortMA");
Mma := FmlVar("_Triple MA","MediumMA");
Lma := FmlVar("_Triple MA","LongMA");
LongSignal:= 0;
ShortSignal:= 0;
FalseLong:= 0;
FalseShort:= 0;
LongSignal:= Cross(Sma, Mma) AND
Lma > Mma;
ShortSignal:= -1 * (Cross(Mma, Sma) AND
Lma < Mma);
FalseLong := BarsSince(LongSignal = 1) <=
BarsSince(ShortSignal = -1) AND
Sma < Mma;
FalseShort := BarsSince(ShortSignal = -1) <=
BarsSince(LongSignal = 1) AND
Sma > Mma;
What I've tried to introduce is the idea that, not only should the Sma be
below the Mma, but the difference between the two should be getting greater
over the last 3 days. When I implement the following change, I get nothing
plotted by the Positions indicator.
Triple MA Crossovers:
Sma := FmlVar("_Triple MA","ShortMA");
Mma := FmlVar("_Triple MA","MediumMA");
Lma := FmlVar("_Triple MA","LongMA");
LongSignal := Cross(Sma, Mma) AND
Lma > Mma;
ShortSignal := Cross(Mma, Sma) AND
Lma < Mma;
FalseLong := BarsSince(LongSignal = 1) <=
BarsSince(ShortSignal = -1) AND
Sma < Mma AND
Cross(Ref(Mma, -3), Ref(Sma, -3)) AND
Mma - Sma > PREV AND
Ref(Mma, -1) - Ref(Sma, -1) > PREV AND
Ref(Mma, -2) - Ref(Sma, -2) > PREV;
FalseShort := BarsSince(ShortSignal = -1) <=
BarsSince(LongSignal = 1) AND
Sma > Mma AND
Cross(Ref(Sma, -3), Ref(Mma, -3)) AND
Sma - Mma > PREV AND
Ref(Sma, -1) - Ref(Mma, -1) > PREV AND
Ref(Sma, -2) - Ref(Mma, -2) > PREV;
There may be a better way to detect a widening gap between two MAs, I don't
know. One thing I am learning is how frustrating it is to have to work in
tiny little windows where you can't see much of the formula; can't flip back
& forth between two Indicator formulas; can't resize many of the windows.
With a 17" monitor I have lots of space I could be using to make the
programming task much easier.
Here's the current state of the Positions indicator. I've been trying to
get positions to be taken earlier in the history but it seems that any
formula that's referred to must evaluate to something other than N/A before
anything happens. It seems I have to have a FalseLong and FalseShort
condition before any Long or Short position is taken. This misses many good
opportunities. You can see my attempts to have variables initialized to
zero if they aren't true.
Triple MA Positions:
BuyLong:= If(FmlVar("_Triple MA Crossovers",
"LongSignal") =1, 1, 0);
SellShort:= If(FmlVar("_Triple MA Crossovers",
"ShortSignal") = -1, -1, 0);
ExitLong:= If(FmlVar("_Triple MA Crossovers",
"FalseLong") = 1, 1, 0);
ExitShort:= If(FmlVar("_Triple MA Crossovers",
"FalseShort") = 1, 1, 0);
If(BarsSince(Ref(BuyLong,-1) = 1) <=
BarsSince(Ref(SellShort,-1) = -1) AND
(ExitLong = 0 OR
BarsSince(BuyLong) <= BarsSince(ExitLong)),
+1,
If(BarsSince(Ref(SellShort,-1) = -1) <=
BarsSince(Ref(BuyLong,-1) = 1) AND
(ExitShort = 0 OR
BarsSince(SellShort = -1) <=
BarsSince(ExitShort)), -1,0
)
);
> -----Original Message-----
> From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Dave Nadeau
> Sent: Saturday, January 20, 2001 11:31 AM
> To: metastock@xxxxxxxxxxxxx
> Subject: Systems and Testing (WAS: RE: Setting colour on a multi-plot
> indicator)
>
>
> Bill,
>
> Sorry for the delayed response. I've been away on travel,
> and came home mid
> week to a pile of stuff to catch up on...
>
> Regarding the $25 question, yes, that's exactly right. You have a $25
> profit per share over the period tested.
>
> Regarding what I mean by a "high number." For my results, I
> like something
> like 40 or so trades. That's fairly arbitrary, but well into
> the total
> amount for my results to be "statistically significant". And
> this is closed
> trades per market or security. So, across a portfolio, I'm
> looking at a
> "bunch" of trades.
>
> To refine any of my systems, what I'm going to do with the
> results of any
> single System Test is to export the trade by trade results
> into Excel and
> look at MAE or Maximum Adverse Excursion while the system runs without
> stops. Group the MAE's by winners and losers, with my
> thought being that
> I'd set a stop at some level (preferring to use percentages
> rather than
> whole dollar amounts here) of MAE where the probability of
> recovering to a
> profitable trade becomes too low--again a subjective call based on my
> trading preferences. This is another reason why I like a
> higher number of
> closed trades in my System Test.
>
> I have to be somewhere (to help move furniture...ugh!) so
> I'll finish the
> Exits portion later. I'd like to work with your code some
> more when I have
> a bit more time later today. Thanks for all of your detail
> and sharing your
> code with us!
>
> Dave Nadeau
> Fort Collins, CO
>
> -----Original Message-----
> From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Bill Irwin
> Sent: Friday, January 12, 2001 1:05 PM
> To: metastock@xxxxxxxxxxxxxxxxxx
> Subject: RE: Setting colour on a multi-plot indicator
>
>
> Dave:
> I've been wrestling with this System trying to improve it,
> amid all the
> other demands on my time during the holidays. See below:
>
> > -----Original Message-----
> > From: owner-metastock@xxxxxxxxxxxxx
> > [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Dave Nadeau
> > Sent: Monday, December 25, 2000 9:57 PM
> > To: metastock@xxxxxxxxxxxxx
> > Subject: RE: Setting colour on a multi-plot indicator
> >
> > At this point you run an exploration across the TSE and get
> > the results as
> > you suggested. Certainly, your average return tells you how
> > this system
> > performs over the broad market. It's nice if it does better on more
> > securities, but I'm of the opinion that it's very unlikely
> > that a single
> > system will work well on every market.
>
> When an Exploration's Equity column shows +25 I think that
> means that the
> trades gained $25/share over the run. Is this correct?
>
> > From here, I would sort those results and look at the best
> > performers. On a
> > chart of those, I'd plot the equity line that you have
> programmed. A
> > smoothly rising equity line suggests consistent, repeatable
> > performance in
> > the past which should have predictive value for the future,
> > assuming that
> > you have a fairly high number of trades that this is based on.
>
> How many is a "high number"?
>
> What this system needs now is an exit signal for both long and short
> positions that should be terminated. The Positions indicator
> is always in
> either a long or short position once the crossover occurs that is the
> opposite of the first crossover (it misses the first
> opportunity). We need
> to recognize that a signal may be false because the trend
> doesn't continue
> long enough for all the MAs to cross over so that the
> opposite signal can be
> generated. In other words, some times after a long signal,
> the price trends
> down before the Medium MA has crossed above the Long MA.
> Hence a short
> signal isn't generated and the position stays long all the
> way through the
> slide and up through (what should be) the next long position.
> The closest
> I've been able to come follows:
>
> _Triple MA Crossovers:
> Sma := FmlVar("_Triple MA","ShortMA");
> Mma := FmlVar("_Triple MA","MediumMA");
> Lma := FmlVar("_Triple MA","LongMA");
> LongSignal := Cross(Sma, Mma) AND
> Lma > Mma;
> ShortSignal := Cross(Mma, Sma) AND
> Lma < Mma;
> FalseLong := BarsSince(LongSignal) <=
> BarsSince(ShortSignal) AND
> Sma < Mma;
> FalseShort := BarsSince(ShortSignal) <=
> BarsSince(LongSignal) AND
> Sma > Mma;
>
> _Triple MA Positions
> BuyLong := FmlVar("_Triple MA Crossovers", "LongSignal");
> SellShort := FmlVar("_Triple MA Crossovers", "ShortSignal");
> ExitLong := FmlVar("_Triple MA Crossovers", "FalseLong");
> ExitShort := FmlVar("_Triple MA Crossovers", "FalseShort");
>
> If(BarsSince(Ref(BuyLong,-1)) <= BarsSince(Ref(SellShort,-1)) AND
> (ExitLong = 0 OR
> BarsSince(BuyLong) <= BarsSince(ExitLong)), +1,
> If(BarsSince(Ref(SellShort,-1)) <= BarsSince(Ref(BuyLong,-1)) AND
> (ExitShort = 0 OR
> BarsSince(SellShort) <= BarsSince(ExitShort)), -1,0
> )
> );
>
> The Positions indicator misses several Long and Short
> triggers early in the
> graph. I haven't figgered out why yet but I suspect my
> efforts at defining
> an early exit are preventing positions to be taken. I need a
> way to set a
> variable when a position has been entered that can be referenced when
> deciding if an exit should be done. The exit indicator
> shouldn't turn on
> unless the condition exists AND we're currently in the
> position that the
> exit is trying to get us out of. More study needed here...
>
> I'm having difficulty identifying a position that's been
> exited while the
> condition to enter the position is still true. In other
> words, After a Long
> position is entered and the ShortMA drops back below the MediumMA, the
> FalseLong indicator fires to exit the position. Then, if the
> Short pops
> back above the Medium, a Long position is taken again. I
> need to smooth out
> the short, temporary conditions that trigger an entry.
>
> Any ideas would be greatly appreciated.
>
> Bill
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
|