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

Re: [Metastockusers] Fwd: Setting A Flag



PureBytes Links

Trading Reference Links

Hello Roy,

Your flag works nicely. My reset is a long trade entry, effectively H > 
Resistance Level. The flag is being reset on that bar, i.e. the last bar on 
which the flag is set is the preceding bar. Is there an elegant way of 
delaying the flag reset until the bar after the trade entry? I could use 
Ref() in the system test of course......

Thanks again,
Kevin

At 08:36 01/10/2004 +1200, you wrote:
>Hi Kevin
>
> >>What is the most efficient way of setting a flag in Metastock? For
> >>example, say I want to enter a trade on a signal but only, say, if there
> >>has been an RSI overbought signal during the past four hours:
> >>
> >>flag:=If(Cross(RSI(14),70),1,0)
> >>
> >>initially sets the flag but it will get reset next bar. How can I keep the
> >>flag set at 1 for the next four hours?
>
>There are a number of ways you can do this. The subject will feature in my 
>newsletter in a couple of
>months, but for now here's some latch (flag) code that should do the 
>trick. You've already got the
>signal to set the latch and all you need is a signal to reset it. For my 
>example I'll use the
>beginning bar of the next day.
>
>FlagSet:=Cross(RSI(14),70);
>FlagReset:=Hour()<Ref(Hour(),-1);
>Flag:=BarsSince(FlagSet)<BarsSince(FlagReset);
>Flag;
>
>If you want to make sure the very first signal is picked up, perhaps for 
>back-testing, then the code
>needs an initialisation (Init) variable added.
>
>FlagSet:=Cross(RSI(14),70);
>FlagReset:=Hour()<Ref(Hour(),-1);
>Init:=Cum(FlagSet+FlagReset>-1)=1;
>Flag:=BarsSince(Init+FlagSet)<BarsSince(Init+FlagReset);
>Flag;
>
>The same thing can be done with a little less code using PREV, but until 
>you have a reset signal to
>complement the set signal no flag or latch code can work.
>
>
>
>Kind regards
>
>Roy Larsen
>www.metastocktips.co.nz
>Free formulas and MS links
>
>
>
>
>
>
>
>Yahoo! Groups Links
>
>
>
>
>
>
>--
>This message has been scanned for viruses and
>dangerous content by HostPlus MailScanner, and is
>believed to be clean, see www.hostplus.co.uk for details.



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/zMEolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Metastockusers/

<*> To unsubscribe from this group, send an email to:
    Metastockusers-unsubscribe@xxxxxxxxxxxxxxx

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