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

Re: [EquisMetaStock Group] RoC - event triggered



PureBytes Links

Trading Reference Links

> the function doesn't go to zero when the condition is false

Nor it should, Daniele.
Your condition is always false whenever the condition is not true.

The logical result of the above statement means that if you wish MS to 
only plot a value when the condition is true, it will always plot the 
current true condition's value, which is always reset to zero.

You may need to use some latch code (and exit conditions) to implement 
your idea, once you have though a little more about it.
In the meantime, try this idea:

---8<-------------------------

{ http://www.metastocktools.com }

{ User inputs }
choose1:=Input("plot:  [1]%RoC,  [2]BarCount,  [3]Signals",1,3,1);
choose2:=Input("plot values:  [1]Normal,  [2]AtSignalOnly",1,2,1);

{ Event/RoC/Bars }
event:=Mov(C,15,S)>Mov(C,90,S);
eventVal:=ValueWhen(1,event,C);
eventRoC:=(C/eventVal-1)*100;
eventBars:=BarsSince(event);

{ User input choices }
signal:=If(choose1=1,eventRoC,
 If(choose1=2,eventBars,event));
plot:=If(choose2=1,signal,Ref(signal,-1)*event);

{ Plot in own window }
plot

---8<-------------------------


jose '-)
http://www.metastocktools.com




--- In equismetastock@xxxxxxxxxxxxxxx, "Daniele Del Monte" 
<daniele_delmonte@xxxx> wrote:
>
> Hi, I Have a problem very similar to this.
> I have to create an exploration to find the roc and the number of
> bar from a defined event, but only if the condition is always true. 
> For example I want to know the bars and the performance from the
> event Mov(c,15,s)>Mov(c,90,s), (without stop in the condition).
> I have tried with barsince() and also with the Roc since event but
> the the function doesn't go to zero when the condition is false.
> Thank in advance!!
> 
>
> ----- Original Message ----- 
> From: Jose Silva 
> To: equismetastock@xxxxxxxxxxxxxxx 
> Sent: Thursday, November 03, 2005 2:20 PM
> Subject: [EquisMetaStock Group] RoC - event triggered
> 
> 
> Ever wanted to measure the Rate of Change (RoC/Momentum in
> MetaStock) since a defined past event, rather than since the normal
> x periods ago?
> 
> The indicators below will measure % or $ RoC since the beginning of 
> year as default.
> Input your own event code (or system entry signals code), to measure 
> RoC since a specific date or event.
>
>
> MetaStock -> Tools -> Indicator Builder -> New ->
> Copy and paste complete formulae between "---8<---" lines.
>
> ===============
> RoC since event
> ===============
> ---8<--------------------------
>
> { Rate of Change (RoC) since past event v1.0 }
>
> { ©Copyright 2005 Jose Silva.
>   The grant of this license is for personal use
>    only - no resale or repackaging allowed.
>   All code remains the property of Jose Silva.
>   http://www.metastocktools.com }
>
> { User inputs }
> choose:=Input("event: [1]Week, [2]Month, [3]Year, [4]User-defined",
>  1,5,3);
> method:=Input("method:  [1]%-percent,  [2]$-points",1,2,1);
> plot:=Input("plot:  [1]RoC,  [2]Event signals",
>  1,2,1);
>
> { Event1 - start of Week }
> event1:=DayOfWeek()<Ref(DayOfWeek(),-1);
>
> { Event2 - start of Month }
> event2:=DayOfMonth()<Ref(DayOfMonth(),-1);
>
> { Event3 - start of Year }
> event3:=Year()<>Ref(Year(),-1);
>
> { Event4 - EMA crossover signals example }
> event4:=Cross(Mov(C,5,E),Mov(C,21,E));
>
> { Event5 - LinReg crossover signals example }
> event5:=Cross(LinearReg(C,5),LinearReg(C,21));
>
> { Choose event }
> event:=
>  If(choose=1,event1,
>  If(choose=2,event2,
>  If(choose=3,event3,
>  If(choose=4,event4,
>  event5))));
>
> { Event's Close value }
> start:=Cum(IsDefined(event))=1;
> eventVal:=ValueWhen(1,event OR start,C);
>
> { RoC since chosen event }
> RoCper:=(C/eventVal-1)*100;
> RoCpts:=C-eventVal;
>
> { Select % or $ method }
> eventRoC:=If(method=1,RoCper,RoCpts);
>
> { Plot in own window }
> If(plot=1,eventRoC,event)
>
> ---8<--------------------------
>
>
>
> ==============
> RoC since date
> ==============
> ---8<--------------------------
>
> { Rate of Change (RoC) since past date v1.0 }
>
> { ©Copyright 2005 Jose Silva.
>   The grant of this license is for personal use
>    only - no resale or repackaging allowed.
>   All code remains the property of Jose Silva.
>   http://www.metastocktools.com }
>
> { User inputs }
> StDay:=Input("Day",1,31,1);
> StMnth:=Input("Month",1,12,1);
> StYear:=Input("Year",1800,2200,2005);
> method:=Input("method:  [1]%-percent,  [2]$-points",1,2,1);
> plot:=Input("plot:  [1]RoC,  [2]Date signal",
>  1,2,1);
>
> { Event date }
> date:=Year()>StYear
>  OR (Year()=StYear AND (Month()>StMnth
>   OR Month()=StMnth AND DayOfMonth()>=StDay));
> event:=date AND Alert(date=0,2);
>
> { Event's Close value }
> start:=Cum(IsDefined(event))=1;
> eventVal:=ValueWhen(1,event OR start,C);
>
> { RoC since chosen event }
> RoCper:=(C/eventVal-1)*100;
> RoCpts:=C-eventVal;
>
> { Select % or $ method }
> eventRoC:=If(method=1,RoCper,RoCpts);
> eventRoC:=If(date,eventRoC,0);
>
> { Plot in own window }
> If(plot=1,eventRoC,event)
>
> ---8<--------------------------
>
>
> jose '-)
> http://www.metastocktools.com








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/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/