PureBytes Links
Trading Reference Links
|
The short answer is, yes, you can reference any prior condition
occurrence with the very handy MS ValueWhen() function.
And as Roy has pointed out in a back issue of the MSTT newsletter, you
can also nest ValueWhen() functions inside each other.
Anyway, try the code below - it doesn't use any forward-referencing to
determine peaks/troughs.
---8<--------------------------
{ http://www.metastocktools.com }
{ User inputs }
back:=Input("Reference last x Stoch Peak/Trough value",1,100,1);
pds1:=Input("%k periods",2,260,5);
pds2:=Input("%k slowing",1,260,3);
{ Stochastic }
St:=Stoch(pds1,pds2);
{ Stoch peaks }
pk:=Ref(St,-1)>St AND Ref(St,-1)>Ref(St,-2);
pkVal:=ValueWhen(back,pk,Ref(St,-1));
{ Stoch troughs }
tr:=Ref(St,-1)<St AND Ref(St,-1)<Ref(St,-2);
trVal:=ValueWhen(back,tr,Ref(St,-1));
{ Plot in own window }
St; { Green }
pkVal; { Red }
trVal; { Blue }
---8<--------------------------
jose '-)
http://www.metastocktools.com
--- In equismetastock@xxxxxxxxxxxxxxx, mwtang <mwtang@xxxx> wrote:
> I would appreciate help in using Valuewhen(). For example :
>
> b1 := Ref(Stoch(5 ,3 ),+0) < Ref(Stoch(5 ,3 ),+1) AND Ref(Stoch(5 ,3
),+0) < Ref( Stoch(5 ,3 ),-1) ;
>
> ValueWhen(1 ,b1 ,Ref(Stoch(5 ,3 ),+0 )> ValueWhen(2 ,b1 ,
Ref(Stoch(5 ,3 ),+0);
>
> Could I use more than two valuewhen() i.e
> ValueWhen(3 ,b1 ,Ref(Stoch(5 ,3 ),+0 ) or
> ValueWhen(4 ,b1 ,Ref(Stoch(5 ,3 ),+0 )
> Thank in advance.
> Regards.
> mun wai.
------------------------ Yahoo! Groups Sponsor --------------------~-->
In low income neighborhoods, 84% do not own computers.
At Network for Good, help bridge the Digital Divide!
http://us.click.yahoo.com/EpW3eD/3MnJAA/cosFAA/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/
|