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

[EquisMetaStock Group] Re: Eliminating PREV and Signal Delay - Help Needed



PureBytes Links

Trading Reference Links

Hi Gary, 
 
I am glad you got the delay in. The PREV is considered a bad choice 
for several reasons, but I'd just leave it in. Even if it takes 
longer to calculate, the performance you gain is often not worth the 
effort to rewrite the code. As long as it works, don't fix it. 
 
Anyhow, but looking at your code... 
 
> > > > > Trigger:=If( LE=1, 1, If(SE=1, -1, If((LX AND PREV=1) OR 
(SX  
> > > AND   
> > > > > PREV=-1),0,PREV)));  
 
I'd rewrite this as follows, for my own understanding 
 
    T1:=((LE=1)-(SE=1))*(LX=0)*(SX=0); 
    T2:=T1+(T1=0)*Ref(T1,-1); 
 
I haven't tested this at all, I don't even have access to MS over 
here, but you can try this and see if T2 does duplicate your trigger 
(it should at least come close). 
 
Regards  
MG Ferreira  
TsaTsa EOD Programmer and trading model builder  
http://www.ferra4models.com  
http://fun.ferra4models.com   
 
 
--- In equismetastock@xxxxxxxxxxxxxxx, "richr4ever" 
<richr4ever@xxxx> wrote: 
> 
> Hi MG: 
>  
> I managed to understand and able to code the delay 1 bar signal.  
> But, still can't do the same thing on PREV part. I believe there 
is  
> a distance between my humble IQ and your incredible knowledge. 
>  
> Good trading! 
>  
> Gary 
>  
> --- In equismetastock@xxxxxxxxxxxxxxx, mgf_za_1999 <no_reply@xxxx>  
> wrote: 
> > 
> > Hi Gary, 
> >  
> > The trick really is in the condition - the LX - of entry or 
exit.  
> Ref 
> > just provides a mechanism to delay the entry or exit. 
> >  
> > Suppose you have *any* signal, say LX 
> >  
> >     LX := some stuff 
> >  
> > Now you want to act on LX, but only after a one bar delay. Then 
use 
> > the ref function as follows: 
> >  
> >     LX1 := Ref(LX,-1); 
> >  
> > This is *exactly* the same as LX, just one bar behind which is 
what 
> > you are looking for I suppose. So, in stead of using LX as say 
long 
> > exit, you now use LX1 and the exit comes a bar later. Again, the  
> trick 
> > is in LX, LX1 just delays it. 
> >  
> > You can use the same idea to get rid of the PREV, as 
> >  
> >     PREV = Ref(x,-1) 
> >  
> > PREV works on recursion, so there is some fancy stuff you can do  
> with 
> > it, but it generally is better to replace or recode your stuff 
to  
> work 
> > with the Ref(x,-1) mechanism. An exponential average can be 
> >  
> >     0.8 * C + 0.2 * PREV 
> >  
> > It is not that easy to do away with PREV, but you can repeatedly  
> write 
> > this out as 
> >  
> >     0.8 * C + 0.2 * ( 0.8 * Ref(C,-1) + 0.2 * Ref(PREV,-1)) 
> >  
> > and so on, until you get something, in math, like 
> >  
> >     0.8 * SUM ( 0.2 ^ i * Ref(C,-i) ) 
> >  
> > It gets complex, and I'm a bit rusty, so I'm not doing it even 
on  
> your 
> > code and the stuff up here is a bit shaky and not tested. But it  
> does 
> > serve to illustrate the point. 
> >  
> > Regards  
> > MG Ferreira  
> > TsaTsa EOD Programmer and trading model builder  
> > http://www.ferra4models.com  
> > http://fun.ferra4models.com   
> >  
> >  
> > --- In equismetastock@xxxxxxxxxxxxxxx, "richr4ever"  
> <richr4ever@xxxx> 
> > wrote: 
> > > 
> > > Hi MG: 
> > >  
> > > Thanx for the lines. But, I don't really get it all. Can you  
> post  
> > > some examples, especially on delay execution with 1 bar for 
the  
> Long  
> > > Exit, so that I can have better ideas of coding it?  
> > >  
> > > My only idea now is Ref(LX,-1)=1. But will it refer to my  
> previous  
> > > LX signal when current LX condition is not yet fulfil? 
> > >  
> > > Thank yoU! 
> > >  
> > > Gary. 
> > >  
> > >  
> > > --- In equismetastock@xxxxxxxxxxxxxxx, mgf_za_1999  
> <no_reply@xxxx>  
> > > wrote: 
> > > > 
> > > > Hi Gary,  
> > > >   
> > > > Try the ref(x,-n) function, which references or 'delays' a  
> time  
> > > > series x with n periods. So you could do something like  
> calculate  
> > > > two triggers,  
> > > >   
> > > >     Trigger1 := some stuff  
> > > >     Trigger2 := some stuff, based on Ref(Trigger1,-1)  
> > > >   
> > > > and use Trigger2. I did not attempt to do it with your code,  
> but  
> > > > hope you get the idea. The same applies for your entry/exit  
> code.  
> > > In  
> > > > stead of using say signal, use Ref(signal,-1) to delay  
> execution  
> > > > with 1 bar.  
> > > >   
> > > > Regards  
> > > > MG Ferreira  
> > > > TsaTsa EOD Programmer and trading model builder  
> > > > http://www.ferra4models.com  
> > > > http://fun.ferra4models.com   
> > > >   
> > > >   
> > > > --- In equismetastock@xxxxxxxxxxxxxxx, "richr4ever"  
> > > > <richr4ever@xxxx> wrote:  
> > > > >  
> > > > > Hello to all:  
> > > > >   
> > > > > I have two questions here. One about eliminating the PREV  
> and  
> > > one  
> > > > on   
> > > > > signal delay.  
> > > > >   
> > > > > For PREV, I have the below codes:  
> > > > >   
> > > > > LE:=Condition A  
> > > > > SE:=Condition B   
> > > > > LX:=Condition C   
> > > > > SX:=Condition D  
> > > > > Trigger:=If( LE=1, 1, If(SE=1, -1, If((LX AND PREV=1) OR 
(SX  
> > > AND   
> > > > > PREV=-1),0,PREV)));  
> > > > > LEEntry:=Cross(Trigger,0.5 );  
> > > > >   
> > > > > How can I perfect the above codes by removing the PREV  
> function  
> > > > and   
> > > > > increase the codes efficiency, and without using any DLL?  
> > > > >   
> > > > > And for the signal delay, say the Long Exit's condtion is  
> met  
> > > on   
> > > > > current bar. But I want the Long Exit signal set to one 
bar  
> > > delay  
> > > > to   
> > > > > next bar's open. I am currently using BarsSince() function  
> but  
> > > I   
> > > > > wonder if there a better way to code it. I don't want to 
use  
> > > the   
> > > > > System Tester feature for this purpose.  
> > > > >   
> > > > > Many thanx in advance!  
> > > > >   
> > > > > Gary.  
> > > > > 
> > > > 
> > > 
> > 
> 
 





------------------------ 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/