[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indicator System problem



PureBytes Links

Trading Reference Links

Sean

There appears to be a difference between what I worked on and your current code. What I have
initialises immediately that all entry/close variables are valid, while the code below misses the
first trade (on my test data) and doesn't initialise until the end of the second trade. I will chase
this down as I am able.

What troubleshooting techniques are you using? I like to display each variable within the indicator
other on its own or with relation to other internal variables. For example, to display all
entry/exit signals I might adjust the last line to read
{Equity;} LongEntry+3; LongExit+2; ShortEntry+1: ShortExit;
Colouring each variable differently when more than one is displayed can also useful.

What ticker codes are you testing on?

Roy

> I've been working through your code suggestions and the Pos variable doesn't
> get initialised until after both a Long and a Short trade.
> I've stripped out everything else to resolve this first.  I'm also not
> worried about triggers a day early or late than can be adjusted later.
> I'm assuming it's because there is now nothing to trigger the LongEntry,...
> variables early now.
>
> This is the stripped out segment:
>
> LongEntryPoint:=Ref(H,-1);
> ShortEntryPoint:=Ref(L,-1);
> LongExitPoint:=O;
> ShortExitPoint:=O;
> LongEntry:=Ref(C,-1) < C AND
>     C < L+((H-L)/4) AND
>     C < O AND
>     H < Ref(H,+1); {last part only for system test - following day entry
> condition}
> LongExit:=barsSince(LongEntry)=3;{auto exit 3 days later}
> ShortEntry:=Ref(C,-1) > C AND
>     C > H-((H-L)/4) AND
>     C > O AND
>     L > Ref(L,+1); {last part only for system test - following day entry
> condition}
> ShortExit:=barsSince(ShortEntry)=3;{auto exit 3 days later}
> Init:=Cum(LongEntry<>2 AND LongExit<>2 AND
>   ShortEntry<>2 AND ShortExit<>2)=1;
> Pos:=Ref(If(BarsSince(LongEntry OR Init)>=
>   BarsSince(LongExit OR Init),0,2) +
>   If(BarsSince(ShortEntry OR Init)>=
>   BarsSince(ShortExit OR Init),0,-1),-0);
>
> Thanks again for your help,
> Sean
>
> -----Original Message-----
> From: owner-metastock@xxxxxxxxxxxxx
> [mailto:owner-metastock@xxxxxxxxxxxxx]On Behalf Of Roy Larsen
> Sent: Sunday, July 01, 2001 1:01 AM
> To: metastock@xxxxxxxxxxxxx
> Subject: Re: Indicator System problem
>
>
> Sean
>
> I believe the following code will track long and short positions more
> accurately than that swapped
> in previous posts. For the sake of brevity I have reduced Position to Pos. A
> long trade is assigned
> a value of +2, and a short trade a value of -1. Therefore Pos will have a
> value >0 for any long
> position (with or without a short position) and = ABS(1) for any short
> position (with or without a
> long position). I guess you do not expect to be in both a long and short
> position at the same time,
> but with system testing if it can happen then it will. There are probably a
> number of other values
> that could be used for Position but +2 and -1 seem to make it simple enough
> to differentiate between
> current positions.
>
> Roy
>
> Pos{ition}:=Ref(If(BarsSince(LongEntry OR Init)>=
>   BarsSince(LongExit OR Init),0,2) +
>   If(BarsSince(ShortEntry OR Init)>=
>   BarsSince(ShortExit OR Init),0,-1),-0);
> EnterLong:=Alert(Pos<1,2) AND Pos>=1;
> CloseLong:=Alert(Pos>=1,2) AND Pos<1;
> EnterShort:=Alert(Abs(Pos)<>1,2) AND Abs(Pos)=1;
> CloseShort:=Alert(Abs(Pos)=1,2) AND Abs(Pos)<>1;
>
>
>