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

Re: [EquisMetaStock Group] help with barsSince



PureBytes Links

Trading Reference Links

Juan

> I've been reading a file in pdf format, not easy for begginers. You are
the
> author "Using latches in MS"?

I wrote the item and put it out there in Word document format. I've never
revisited it to try and make it more user freindly so I apologise for it not
being as clear as it could be. I have no idea how it got to PDF format but
that's not a problem.

> I have to redefine the binary latch to outcomes of -1 and 1, instead of 0
> and 1 as you pointed out before.

OK, I'm beginning to see where you're coming from with this, and it appears
at this stage that you may be confusing two or more quite different
concepts.

> But I tried in a different way, without changing the binary latch but it
> does no work:

A SIMPLE binary latch, i.e. one with no PREV's and using the format
"BarsSince(I OR N)< BarsSince(I OR X)", can easily be changed to give
different (than zero and one) values by adding an If(), as follows.
If(BarsSince(I OR N)< BarsSince(I OR X),+2,-5)


Generally a PREV based latch does not need the 'I' initialisation variable.
The code naturally kicks into life when all signals are present without the
aid of 'I'. The value of the PREV based latch is that it can store values
that are not known ahead of time - the entry price for example. It's also
quite easy with a PREV latch to control the resetting using tests within the
latch rather than needing to rely on values that were known ahead of time. A
timed exit is a good example of this which can be done by including "OR
BarsSince(PREV=0)>=23" as one of the exit conditions. You can even include a
simple latch within a PREV latch if you want, though construction can be
confusing for the novice.

When using ATR and other values to determine an latch reset you have to be
very sure about whether you are referring to the value when the trade
commentced or the current value. If you're referring to the current value
then do you need a delay? There are many issues to think about.

I agree with Corey that you need to test each signal as you construct your
indicator - always create code as an indicator before moving it to System
Tester or Explorer because it is much easier to troubleshoot. Create an
output for each variable, one at a time or several together if necessary,
and look closely to see that it performs as expected. If not, why not?
Displaying several binary variables at a time to test visually can be messy
unless each output is charted in its own space. I add 1.25 to the second
output, 2.5 to the third, 3.75 to the fourth, and so on. this allows me to
see how all binary variables interact with each other and to know which is
which.

I realize tthat none of the above actually solves your problem so perhaps
you could explain what the 'stlongl' variable is supposed to do. At the
moment I am unclear. Is it a latch? If so what conditions set it, what
conditions reset it, and what values do you want it to store in both states?

Roy


> {draws resistances and supports}
> LookBack := 34;
>
> Resistance :=ValueWhen(1,Cross(Mov(C, LookBack,S),C),HHV(H, LookBack));
>
> Support :=ValueWhen(1,Cross(C,Mov(C, LookBack,S)),LLV(L, LookBack));
>
> R1:=Resistance;
>
> S1:=Support;
>
>
>
> {binary latch, gives 1 if L>Resistance, and resets if H<Resistance to 0}
>
> sigtl:=If(L>R1,1,0);
>
> rsttl:=If(H<R1,1,0);
>
> itl:=Cum(sigtl+rsttl>-1)=1;
>
> rmbtl:=BarsSince(sigtl OR itl)<BarsSince(rsttl OR itl);
>
>
>
> {looks for HHV since L>Resistance to place a trailing stop}
>
> all:=If(rmbtl=0,-1,l);
>
> stlongl:= If(all=-1,0, If(HHV(H,LastValue(PREV+
> BarsSince(all=-1)-PREV))-ATR(6)*0.5<C,1,0));
>
> stlongl;
>
>
>
>
>
>
> ----- Original Message -----
> From: "Roy Larsen" <rlarsen@xxxxxxxxxxxxxx>
> To: <equismetastock@xxxxxxxxxxxxxxx>
> Sent: Monday, March 10, 2003 1:14 AM
> Subject: Re: [EquisMetaStock Group] help with barsSince
>
>
> > Juan
> >
> > One problem that is evident with your 'stlong' variable is that the
> > BarsSince() function is often returning a "zero" value. This is not
> > acceptable for the HHV(H,periods) function, as I think I pointed out in
my
> > earlier post. So the problem at this point is not so much that the code
> > won't work as that it won't work with the parameters you are supplying
it.
> > Try adding some number to BarsSince(rmbtl=0) so that you have an
> expression
> > like (BarsSince(rmbtl=0)+5) instead. This should at least get an output
> > instead of N/A - It does for me. Because I don't yet understand the
> thinking
> > behind the formula I can't offer further suggestions, but using a
variable
> > as a constant does not appear to be the only issue.
> >
> > You can dispense with the If function in "stlong" (to simplify the code
a
> > little) because any output signal will be the same whether or not you
use
> > If(). But the main task is to rethink the BarsSince() function usage so
> the
> > result is never zero and always a whole number, as required by HHV()
> >
> > Roy
> >
> > ----- Original Message -----
> > From: "emarco" <emarco@xxxxxxxxxxxxxxx>
> > To: <equismetastock@xxxxxxxxxxxxxxx>
> > Sent: Monday, March 10, 2003 4:29 PM
> > Subject: Re: [EquisMetaStock Group] help with barsSince
> >
> >
> > > Thanks Roy.
> > > Unfortunatly it does not work.
> > > Here's the full code. Thanks again,
> > > Juan
> > >
> > > LookBack := 34;
> > >
> > > Resistance :=ValueWhen(1,Cross(Mov(C, LookBack,S),C),HHV(H,
LookBack));
> > >
> > > Support :=ValueWhen(1,Cross(C,Mov(C, LookBack,S)),LLV(L, LookBack));
> > >
> > > R1:=Resistance;
> > >
> > > S1:=Support;
> > >
> > >
> > >
> > > sigtl:=If(L>R1,1,0);
> > >
> > > sigts:=If(H<S1,1,0);
> > >
> > > rsttl:=If(H<R1,1,0);
> > >
> > > rstts:=If(L>S1,1,0);
> > >
> > > itl:=Cum(sigtl+rsttl>-1)=1;
> > >
> > > its:=Cum(sigts+rstts>-1)=1;
> > >
> > > rmbtl:=BarsSince(sigtl OR itl)<BarsSince(rsttl OR itl);
> > >
> > > rmbts:=BarsSince(sigts OR its)<BarsSince(rstts OR its);
> > >
> > > stlong:=If(HHV(H,LastValue(PREV+
> > > BarsSince(rmbtl=0)-PREV))-ATR(6)*2.5<C,1,0);
> > >
> > > stlong;
> > >
> > >
> > >
> > >
> > > ----- Original Message -----
> > > From: "Roy Larsen" <rlarsen@xxxxxxxxxxxxxx>
> > > To: <equismetastock@xxxxxxxxxxxxxxx>
> > > Sent: Sunday, March 09, 2003 6:38 PM
> > > Subject: Re: [EquisMetaStock Group] help with barsSince
> > >
> > >
> > > > Juan
> > > >
> > > > Thanks to Corey Saxe there is a way that MS will accept a variable
as
> > > > constant. Try redefining your variable using
> > > > LastValue(PREV+"Variable Data"-PREV)
> > > >
> > > > This method does not work on every occasion but there are a couple
of
> > > things
> > > > you can do to help.
> > > > 1. Make sure your variable is greater than or equal to one.
> > > > 2. Make sure your variable is a whole number.
> > > >
> > > > LastValue() can be used in a number of situations to make a result
> > > suitable
> > > > for using as a constant, but only where the last value of the
variable
> > is
> > > > the same as on every other bar. The above example of adding then
> > > subtracting
> > > > PREV from the current value appears to return the "actual" value
> rather
> > > than
> > > > the "last" value, and therefore is accepted as a "constant" by many
MS
> > > > functions.
> > > >
> > > > I have some doubts about the code you have given as an example and
> doubt
> > > it
> > > > could work in its present form even without MetaStock's perceived
> > > > inadequacies. The code appears to be looking for results from two
If()
> > > > statements yet I can only see one If(). It also seems to me that the
> > > > calculated "constant" for the HHV periods has no check to ensure
that
> it
> > > is
> > > > a whole number.
> > > >
> > > > When looking for assistance with code it is also helpful if
associated
> > > code
> > > > can be supplied. You may know how "rmbtl" is calculated but those
> > capable
> > > of
> > > > offering help won't. Providing actual code or at least a working
> > > substitute
> > > > will increase your chances of real help that goes beyond "buy some
> more
> > > > software".
> > > >
> > > > Good luck with your attempts to solve your problem whichever method
> you
> > > > choose to use.
> > > >
> > > > Roy
> > > >
> > > > ----- Original Message -----
> > > > From: "emarco" <emarco@xxxxxxxxxxxxxxx>
> > > > To: <equismetastock@xxxxxxxxxxxxxxx>
> > > > Sent: Saturday, March 08, 2003 11:37 AM
> > > > Subject: [EquisMetaStock Group] help with barsSince
> > > >
> > > >
> > > > This is a trailing stop. The problem is that MS does not accept
> variable
> > > > data in HHV.
> > > >
> > > >
> > > >
> > > > stlong:=if(HHV(H,BarsSince(rmbtl=0))-ATR(6)*2.5>C,1,0),1,0)
> > > >
> > > >
> > > > As you can see, MS does not accept barssince as a period data.
> > > > How can I solve this problem?
> > > > Thanks
> > > >
> > > > Juan
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > 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/
> > > >
> > > >
> > >
> > >
> > >
> > >       Yahoo! Groups Sponsor
> > >             ADVERTISEMENT
> > >
> > >
> > >
> > >
> > > To unsubscribe from this group, send an email to:
> > > equismetastock-unsubscribe@xxxxxxxxxxxxxxx
> > >
> > >
> > >
> > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > >
> >
> >
> >
> > 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/
> >
> >
> >
>
>
>
>       Yahoo! Groups Sponsor
>             ADVERTISEMENT
>
>
>
>
> To unsubscribe from this group, send an email to:
> equismetastock-unsubscribe@xxxxxxxxxxxxxxx
>
>
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>



------------------------ Yahoo! Groups Sponsor ---------------------~-->
New Yahoo! Mail Plus. More flexibility. More control. More power.
Get POP access, more storage, more filters, and more.
http://us.click.yahoo.com/Hcb0iA/P.iFAA/46VHAA/BefplB/TM
---------------------------------------------------------------------~->

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/