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

[Metastockusers] Writing code for "the first time an event happens" METAROCKX



PureBytes Links

Trading Reference Links

Metarockx,

I have a question pertaining to the code you supplied recently. I'll paste 
the code in first:

Trend := Mov(C,55,E) > Ref(Mov(C,55,E),-1);
StartTrend := Trend AND Ref(Mov(C,55,E),-1) < Ref(Mov(C,55,E),-2);
Trigger:= Cross(Mov(C,8,E),Mov(C,13,E));
Signal:= Trend AND Trigger
AND BarsSince(Ref(Trigger,-1)) > BarsSince(StartTrend);

I'm clear on:
Trend := Mov(C,55,E) > Ref(Mov(C,55,E),-1);

And I think I also understand StartTrend:
StartTrend := Trend AND Ref(Mov(C,55,E),-1) < Ref(Mov(C,55,E),-2);

You have to define the event that marks the beginning of the trend because 
you will later be comparing the number of bars to have elapsed since the 
beginning of the trend to the number of bars to have elapsed since the most 
recent Trigger. In this specific case, a trend has begun when the EMA(55) 
is rising today, but it wasn't rising yesterday.

What if I wanted to state the StartTrend in more general terms. Could I 
say: A trend has begun when there is trend today according to such and such 
a definition, but yesterday there was no trend according to this 
definition? Is that correct?

For example, would this work?

Trend: MyTrendUp; (say, couple of moving averages, or a rising ADX, or 
whatever)
Condition1:=Ref(MyTrendUp, -1);
StartTrend:= Trend and condition1=false;

Something like that would give me more room to maneuver.

Philip 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/zMEolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/