PureBytes Links
Trading Reference Links
|
I am writing some code to follow Le Beau's strategy for testing Entries in
"Computer Analysis of the Futures Markets" - i.e. test a bunch of entries
using with the only exits being time stops and compare to a random entry. I
am therefore assuming an entry as per the system, and an exit as the earlier
of a system reversal or a time stop.
For a long and short system, I am ending up with code with 4 PREV latches. I
can't get the indicator exit and the time stop in the same latch since the
time stop needs to refer to the prior latch to set the clock running. This
seems to work, but it feels clumsy - is there a better way?
Here's an example, written as an indicator which will show long positions as
+1, short as -1 and time out of the market as 0. The entry is on the slope
of a moving average. I've annotated the long side for clarity. Short is just
the opposite of long. I have included entry and exit signals for use in
TE/TradeSim/System Tester although they're not actually used in the
Indicator. Ideally I'm trying to get to a baseline code that I can use to
quickly compare different entries. [NB this is not a tradable system -it
cuts off trends way too early- just an exercise to compare different
entries]
Thanks for your thoughts
Andrew
----------------------------------------------------------------------------
---------------------------
{Single MA System - gives entry signals when slope of MA changes to up or
down in one day. Exit is a reverse signal or a time stop. Indicator.}
B1:= Input("Enter bars for MA1",1,300,50);
B2:= Input("Enter bars for TStop",1,100,10);
MA:= Mov(C,B1,E); {today's MA}
MA1:= Ref(Mov(C,B1,E),-1); {yesterday's MA}
MA2:= Ref(Mov(C,B1,E),-2); {day before yesterday's MA}
Set:= MA2>=MA1 AND MA1<MA; {MA turns up}
Reset:= MA2<=MA1 AND MA1>MA; {MA turns down}
Trigger1:= If(PREV=0,If(Set,1,0),If(Reset,0,PREV));
{first binary trigger for set and reset signals}
TStopL:=if(Trigger1=1,if(barssince(roc(Trigger1,1,$)>0)=B2,1,0),0);
{time stop keying off Trigger1}
Trigger2:= If(PREV=0,If(Set,1,0),If(Reset OR TStopL,0,PREV));
{second binary trigger to include time stop}
Long:=Trigger2;
EL:=if(ref(long,-1)=0,if(set,1,0),0);
{Enter Long if you're out of the market and get an indicator buy}
CL:=if(ref(long,-1)=1,if(Reset OR TStopL,-1,1),0);
{Close Long on an indicator sell or time stop}
Trigger3:= If(PREV=0,If(Reset,1,0),If(Set,0,PREV));
TStopS:=if(Trigger3=1,if(barssince(roc(Trigger3,1,$)>0)=B2,1,0),0);
Trigger4:= If(PREV=0,If(Reset,1,0),If(Set OR TStopS,0,PREV));
Short:=Trigger4;
ES:=if(ref(short,-1)=0,if(Reset,1,0),0);
CS:=if(ref(short,-1)=1,if(Set OR TStopS,-1,1),0);
Long - Short; {i.e., will show +1 for long market position, -1 for short and
0 for out}
-----Original Message-----
From: praktikus_ms [mailto:praktikus@xxxxxxxxxx]
Sent: Monday, June 28, 2004 8:36 AM
To: equismetastock@xxxxxxxxxxxxxxx
Subject: [EquisMetaStock Group] Re: unnecessary repetitive signals
Hormuz,
Go to the files section of this group and search for a word document
called 'Using Latches in MS.doc' by Roy Larsen. This should give you
an idea about how solve this problem.
A quick shot would be:
{Trade Latch; Idea by }
{2004 Roy Larsen, rlarsen@xxxxxxxxxxxxxx}
Set:=Fml(your long therm buy signal);
Reset:=Fml(your long term sell signal); Init:=Cum(Set+Reset>-1)=1;
Trade:=If(BarsSince(Init+Set)<BarsSince(Init+Reset),1,-1);
Trade; {swings between +1 and -1}
This gives you an output of +1 for the buy signal and -1 for the sell
signal. Just assign those to your expert signals and you should doing
fine.
Martin
--- In equismetastock@xxxxxxxxxxxxxxx, hormuz maloo
<hormuzmaloo@xxxx> wrote:
> Hi everybody,
> I am trying to program my own expert advisor, which
> gives long-term buy and sell signals.
> Have just got started, but I find that the buy or sell
> signal is repeated everytime the pattern is found on
> the chart.
> What I would like to do is see that a buy signal does
> not follow a buy signal, ie a buy signal should occur
> only if the previous signal was a sell signal and vice
> versa.
> Can somebody please show me a simple way to do this.
> Thanks in advance,
> Hormuz Maloo
Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|