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

Re: [amibroker] iif and ref



PureBytes Links

Trading Reference Links

try this, hopefully I have typed correctly


ab[0]=C[0]-100;
for(i=1;i<barcount;i++)
{
 if( C[i] < ab[i-1] )
 {
  ab[i] = C[i]+100; 
 }
 else
 {
  if( C[i] > ab[i-1] )
  { 
   ab[i] = C[i]; 
  }
  else
  { 
   ab[i] = C[i]-100; 
  }
 }
}

On Sat, 5 Feb 2005 16:14:34 +0100, ed nl <ed2000nl@xxxxxxx> wrote:
> not sure what you want to do but the result of your code is: ab = C.  That's
> why you will only see C plotted.
>  
> you start with: 
>  
> ab = C - 100;
>  
> then 
>  
> if  C is less than Ref(ab,-1)  This will be very unlikely to happen for
> normal close prices because ab is the close minus 100
>  
> then it goes to the else part: 
>  
> else if C is greater than Ref(ab,-1). Well yes this will probably always be
> answered with yes (for normal price arrays) so that's why ab will be set to
> C
>  
> rgds, Ed
>  
> ----- Original Message ----- 
> From: Arie Ellerbrak 
> To: amibroker@xxxxxxxxxxxxxxx 
> Sent: Saturday, February 05, 2005 4:02 PM
> Subject: [amibroker] iif and ref
> 
> 
> 
> I'm trying to write a very simple indicator that references itself.
> 
>  
> 
> Like:
> 
>  
> 
> ab = C - 100;
> 
>  
> 
> ab =   IIf(C < Ref(ab,-1), C + 100,
> 
>              IIf(C > Ref(ab,-1), C,
> 
>              C - 100));
> 
>  
> 
> Plot(C,"Close",colorBlue);
> 
> Plot(ab,"ab",colorRed);
> 
>  
> 
>  
> 
> In my first attempts I didn't use the first assignment of zz and got an
> error: 
> 
> Variable 'zz' used without having been initialized.
> 
>  
> 
> Now, no errormessages appear, but only the close will be plotted.
> 
>  
> 
> Can anyone help?
> 
>  
> 
>  
> 
> Arie
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> 
> 
> Check AmiBroker web page at:
> http://www.amibroker.com/
> 
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> 
> ________________________________
> Yahoo! Groups Links
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/amibroker/
>   
> To unsubscribe from this group, send an email to:
> amibroker-unsubscribe@xxxxxxxxxxxxxxx
>   
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
Has someone you know been affected by illness or disease?
Network for Good is THE place to support health awareness efforts!
http://us.click.yahoo.com/Rcy2bD/UOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

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

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

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