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

Please help extend function of condition counter (Was Re: [amibroker] Re: Resetting counter)



PureBytes Links

Trading Reference Links

i think this is an application of the flip() function:

//condition must be true to count events
cond1 = flip(Cross(C,MA(C,20)),Cross(MA(C,20),c));/* or
flip(Buy,Sell), for your trading system*/

//the event to count
event = cross(stochd( 7 ),ma(stochd( 7 ),5));// or whatever

//summation
countevents = iif(cond1==true,sum(event,barssince(cond1==true)),0);

I did not try it.
In case you want to use it ony with Buy/Sell events, you should also
have a look at the Exrem() function. 

HTH Stephan



--- In amibroker@xxxxxxxxxxxxxxx, "Owen Davies" <owen5819@xxxx> wrote:
> Can anyone tell me how to count events after a certain condition is
met?
> Say, number of times a stochastic (or whatever) has crossed its
moving
> average (or whatever) since Cross(C,MA(C,20)) (or whatever?)
> 
> Actually, while I'd like the most general solution possible, at the
moment
> I'm trying to count events after a Buy, Sell, Short, or Cover. 
And, of
> course, it has to be reset for the next trade.
> 
> (I swear, fifteen years ago I could have figured this out for
myself.  I
> really gotta get back into programming!)
> 
> Many thanks.
> 
> Owen Davies


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Get A Free Psychic Reading! Your Online Answer To Life's Important Questions.
http://us.click.yahoo.com/O10svD/Me7FAA/AG3JAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

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