Australian (ASX) Stock Market Forum

System Development with Metastock Language

Joined
14 April 2007
Posts
317
Reactions
0
Hello All,

Calling all MS users!!! :eek:

I'm currently playing around with the MS language in an attempt to code some ideas which I would like to backtest and possibly trade, depending on results.

Two of the MS functions which I am currently looking at are "troughbars" and "peakbars".

However, after reading the MS online help I've realised that both these functions rely on the "Zig Zag" function to determine the troughs and peaks.

My question is this. From memory, I read somewhere that the "Zig Zag" function shouldn't be relied upon for signal confirmation when backtesting and as a result I would assume that this would therefore apply to these two other functions ??!!??

Can anyone confirm or disprove this?

Many Thanks in advance,

Chorlton
 
confirm ... proceed with maximum caution ... I have posted some code recently on Reefcap which shows just some of the percautions one needs to take ... for someone starting out learning the language I would suggest avoiding altogether .
 
confirm ... proceed with maximum caution ... I have posted some code recently on Reefcap which shows just some of the percautions one needs to take ... for someone starting out learning the language I would suggest avoiding altogether .

Hi Weird,

Can you elaborate as to what the potential problems are, as I can't remember.... :confused:

I shall also take a look on Reefcap to see what the precautions are that you posted should I decide to continue down this line of research, although I appreciate the words of warning....

All the best & Thanks.......
 
Recent signals can disappear in realtime as the most recent peak or trough value is dynamic ... the perils of zigzag have been previously commented upon so I suggest doing a search on reefcap or elsewhere. Spyros Raftopoulos has done quite abit of work on zigzag confirmation which is worth looking at, but even then going beyond this by adding additional zigzag related code brings dangers. I remember trying to develop a system using AlphaOmega metastock plugin, which uses zigzag in different time frames ... I remember thinking I eliminated all the hindsight, then started trading the system and seeing the entry signals disappearing after a trade ! I have learnt abit from that.

Not sure if you have Tradesim, but I once posted in jest this code,

EntryTrigger:=TroughBars(1,C,5)=0;

EntryPrice:=OPEN;
InitialStop:=0;

ExitTrigger:=PeakBars(1,C,5)=0;
ExitPrice:=OPEN;

ExtFml("TradeSim.Initialize");
ExtFml("TradeSim.EnableDelayofEntryByOneBar");
ExtFml("TradeSim.EnableDelayofAllExitsByOneBar");
ExtFml( "TradeSim.RecordTrades",
"CRYSTAL BALL",
LONG,
EntryTrigger,
EntryPrice,
InitialStop,
ExitTrigger,
ExitPrice,
START);


The code I posted recently on the chartist (reefcap) is here ...

http://www.thechartist.com.au/forum/ubbthreads.php?ubb=showflat&Number=68570#Post68570

The forum dll was used to avoid further hindsight issues ... I am not saying that the code is perfect (it was about 20 mins of mucking around this afternoon) ... but may provide some insight on the issues that I am attempting to avoid when using these functions.
 
Recent signals can disappear in realtime as the most recent peak or trough value is dynamic ... the perils of zigzag have been previously commented upon so I suggest doing a search on reefcap or elsewhere. Spyros Raftopoulos has done quite abit of work on zigzag confirmation which is worth looking at, but even then going beyond this by adding additional zigzag related code brings dangers. I remember trying to develop a system using AlphaOmega metastock plugin, which uses zigzag in different time frames ... I remember thinking I eliminated all the hindsight, then started trading the system and seeing the entry signals disappearing after a trade ! I have learnt abit from that.

Not sure if you have Tradesim, but I once posted in jest this code,

EntryTrigger:=TroughBars(1,C,5)=0;

EntryPrice:=OPEN;
InitialStop:=0;

ExitTrigger:=PeakBars(1,C,5)=0;
ExitPrice:=OPEN;

ExtFml("TradeSim.Initialize");
ExtFml("TradeSim.EnableDelayofEntryByOneBar");
ExtFml("TradeSim.EnableDelayofAllExitsByOneBar");
ExtFml( "TradeSim.RecordTrades",
"CRYSTAL BALL",
LONG,
EntryTrigger,
EntryPrice,
InitialStop,
ExitTrigger,
ExitPrice,
START);


The code I posted recently on the chartist (reefcap) is here ...

http://www.thechartist.com.au/forum/ubbthreads.php?ubb=showflat&Number=68570#Post68570

The forum dll was used to avoid further hindsight issues ... I am not saying that the code is perfect (it was about 20 mins of mucking around this afternoon) ... but may provide some insight on the issues that I am attempting to avoid when using these functions.


Weird,

Thanks for the detailed reply and the Reefcap link...... From memory now I think it might have been on the Reefcap site that I first read about the "Zig Zag" issue....

As always cheers for your comments......
 
I believe that Spyros published an article in TASC on zig zag validity - here is some code I found although I haven't checked it. You could google for more info.

stevo

Code:
{ZigZag validity by Spyros Raftopoulos}

perc:=Input("Percent",2,100,10);
Z:=Zig(C,perc,%);
last:=ValueWhen(1,
( Z > Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2) )
OR
( Z < Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2) ),
Ref(Z,-1));
pc:=(C-last) * 100 / last;
pc:= Abs(pc);
SD:=(z>Ref(z,-1) AND Ref(z,-1)>Ref(z,-2)) OR (z<Ref(z,-1) AND
Ref(z,-1)<Ref(z,-2));
res:=If(pc>=perc ,1,0);
If(Alert(res,2) AND SD,1,res);
 
Top