MetaStock™ Zone Forum & FAQ Artykuły Linki Elliott Waves EasyLanguage™ Zone

A B C D E F G H I J K L M N O P R S T U V W Y Z #

Triple MA I
TEST OF INDICATORS BASED ON OTHER INDICATORS


Now, you can create an Exploration with INDICATOR4 as one of the columnsand quickly see the equity performance across your portfolio of stocks. Then, you can change "Length:=17;" to 18 or 20 in INDICATOR1, and run the exploration again to get the results for that value. You can repeat thisfor as many values as you like. (I copy the exploration results into Excelto do my summary statistics).

The first indicator is

_Triple MA

ShortTime := 25;
MediumTime := 75;
LongTime := 200;
ShortMA := Mov(CLOSE, ShortTime, S);
MediumMA := Mov(CLOSE, MediumTime, S);
LongMA := Mov(CLOSE, LongTime, S);
ShortMA; MediumMA; LongMA;

 

Next is :

 


_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;

 

Then comes :

 


_Triple MA Positions

BuyLong := FmlVar("_Triple MA Crossovers", "LongSignal");
SellShort := FmlVar("_Triple MA Crossovers", "ShortSignal");

If(
BarsSince(Ref(BuyLong,-1)) <= BarsSince(Ref(SellShort,-1)), +1,
If(
BarsSince(Ref(SellShort,-1)) <= BarsSince(Ref(BuyLong,-1)), -1,0)
);

 

 
And lastly,

 


_Triple MA Equity

Cum(
Cum(
If(
FmlVar("_Triple MA Crossovers","LongSignal")= 1,
OPEN-Ref(OPEN,-1),
If(FmlVar("_Triple MA Crossovers","ShortSignal")=-1,
-1 * OPEN-Ref(OPEN,-1),0
)
)
)
)

 

 
e-w-Triple_MA_I.gif
 
I've plotted the _Triple MA and set the 3 colours and saved that as a template. Plotting the Positions indicator produces a horizontal line at 1 when I'm long, -1 when short and zero when out. That's as I think it should be. The Equity indicator, when applied to the price bars, produces a stepping pattern that's horizontal until it steps vertically up or down to another location, then horizontal again. This doesn't seem right to me.

The Exploration:

ColA: FmlVar("_Triple MA","ShortMA")

ColB: FmlVar("_Triple MA","MediumMA")

ColC: FmlVar("_Triple MA","LongMA")

ColD: ((HHV(C,250)-LLV(C,250))/LLV(C,250))*100

ColE: Fml("_Triple MA Equity")

Filter: colD > 100 AND

colD < 300 AND

CLOSE > 5.00


Running this Exploration on the TSE produces a report where ColE ranges from -1331.80 to 17.95. Does this mean that, using this Triple MA indicator, and buying/selling when the crossovers hit, the best stock earned $17.95 over the history (5 years) and the worst stock lost $1,331.80?

from Bill Irwin






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 moresecurities,
> 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 achart 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


RE: Systems and Testing (WAS: RE: Setting colour on a multi-plot indicator)
To: <metastock@xxxxxxxxxxxxx>
Subject: RE: Systems and Testing (WAS: RE: Setting colour on a multi-plot indicator)
From: "Bill Irwin" <Bill-Irwin@xxxxxxxx>
Date: Sat, 27 Jan 2001 20:47:37 -0800
Importance: Normal
In-Reply-To: <NEBBLKHFFBPAJCIPNOCLGELJCCAA.dave_nadeau@xxxxxxxxx>
Reply-To: metastock@xxxxxxxxxxxxx
Sender: owner-metastock@xxxxxxxxxxxxx

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
)
);
Source / From: TOP
http://purebytes.com/archives/metastock/ http://www.guppytraders.com

Equis and MetaStock® and MetaStock Professional® are registered trademarks of Equis International. Achelis Binary Wave®, The DownLoader®,
Expert Advisor®, OptionScope®, Quotecenter® and Smart Charts® are trademarks of Equis International, a Thomson Reuters company.

TradeStation® Pro, TradeStation® 2000i, OptionStation®, SuperCharts®, PowerEditor® and EasyLanguage®
are registered trademarks of TradeStation Technologies, Inc. Other names and marks referred to are the property of their respective owners.

All information provided on this website is for educational purposes only. Trading involves risk, including possible loss of principal and other losses.

Ten i inne materiały na tej stronie zostały zamieszczone zostały jedynie w celach edukacyjnych, nie ponoszę żadnej odpowiedzialno¶ci za ich stosowanie.

Gra na giełdzie i rynkach walutowych (FOREX) niesie ze sob± ryzyko poważnych strat finansowych!