It doesn't give you the same array... it gives you a scalar.
(as Bruce mentioned it seems sometimes AFL can see an array has the same value 
all the way through and treats it as a scalar).

--- In [email protected], Yuki Taga <yukit...@...> wrote:
>
> That was exactly my take on it.  Wonderful that I can use IF, but why
> is it possible?
> 
> Tomasz ????  (The layman's interpretation, please.) ^_^
> 
> Yuki
> 
> Monday, June 14, 2010, 5:11:34 PM, you wrote:
> 
> TS> Rick changing a string to a number THAT'S COMING FROM AN ARRAY
> TS> and after that changing a number to a string again, should give
> TS> me the same array with the initial strings. But the fact that I
> TS> can use IF after the string manipulation shows me that I am no
> TS> longer having an array ... I still do not get this. Weird ...
> 
> TS> Tomasz ????
> 
> TS> Regards, Ton.
> 
> 
> TS>   ----- Original Message ----- 
> TS>   From: Rick Osborn 
> TS>   To: [email protected] 
> TS>   Sent: Sunday, June 13, 2010 5:33 PM
> TS>   Subject: Re: [amibroker] impenetrable AFL
> 
> 
> TS>     
> 
> TS>   First off let me repeat - this is not my original code.
> TS>   I found it in someone's code for TD Sequential (with apologies
> TS> to the original coder - didn't keep your name)
> 
> TS>   The Buysignal is a Flip(Buy,Sell) type - or could be a true/false item.
> 
> TS>   Checking the help file  the NunToStr  says
> TS>         FUNCTION  It is used to convert numeric value of NUMBER or ARRAY 
> to string.
> TS>   Next the StrToNum function
> TS>         FUNCTION  It is used to convert numeric value of NUMBER or ARRAY 
> to string.
> TS>   So the combination of changing that value of the array from a
> TS> number to a string and then "that string" back to "a number" (not an 
> array)
> 
> TS>   LastValue works the same but I still don't understand that function 
> well enough.
> TS>   From the help file
> TS>         FUNCTION  Returns last calculated value of the specified
> TS> ARRAY. The result of this function can be used in place of a
> TS> constant (NUMBER) in any function argument. 
> TS>         If ARRAY is undefined (e.g., only 100-days loaded and
> TS> you request the last value of a 200-day moving average) then the
> TS> lastvalue function returns zero. 
> TS>         Caveat: since this function fills an entire data array
> TS> with the last value of another array, it allows a formula to look into 
> the future.
> TS>   so if there are repeated events (buy signals and sell
> TS> signals), I'm not sure if lastvalue sees any but the last one.  Plus I 
> worry about the Caveat!!
> 
> 
> TS>   Best Regards
> TS>   Rick Osborn
> 
> 
> 
> 
> 
> TS> 
> ------------------------------------------------------------------------------
> TS>   From: Ton Sieverding <ton.sieverd...@...>
> TS>   To: [email protected]
> TS>   Sent: Sun, June 13, 2010 2:55:32 AM
> TS>   Subject: Re: [amibroker] impenetrable AFL
> 
> TS>     
> TS>    
> 
> TS>   That's interesting code, Rick. Can you explain me why this works ?
> 
> TS>   1. First I assume BuySignal to be BUY. Therefore being an
> TS> array. So IF should not work. Should be IIF. But even when I put
> TS> there BUY to be sure it's an array, it does work. Why ?
> 
> TS>   2. What's the difference between StrToNum(NumtoStr( BUY)) and
> TS> BUY ? Should give me the same result. But is does not. Without
> TS> this trick I cannot use IF. What's going on here ????
> 
> TS>   Regards, Ton.
> 
> 
> TS>     ----- Original Message ----- 
> TS>     From: Rick Osborn 
> TS>     To: amibro...@yahoogrou ps.com 
> TS>     Sent: Saturday, June 12, 2010 10:52 PM
> TS>     Subject: Re: [amibroker] impenetrable AFL
> 
> 
> TS>       
> 
> TS>     Yuki
> 
> TS>     I have the following code which changes the background
> TS> gradient color depending on whether a buy or sell signal is given.
> 
> TS>     if(StrToNum(NumToStr(BuySignal)) ) 
> TS>     bgColor = ColorRGB(0,66, 2); 
> TS>     else 
> TS>     bgColor = ColorRGB(66,2, 0); 
> TS>     SetChartBkGradientF ill( colorBlack, bgColor); 
> 
> 
> TS>     Perhaps you can change this to meet your needs
> 
> 
> TS>     Best Regards
> TS>     Rick Osborn 
> 
> 
> 
> 
> 
> TS> 
> ----------------------------------------------------------------------------
> TS>     From: Yuki Taga <yukit...@tkh. att.ne.jp>
> TS>     To: amibro...@yahoogrou ps.com
> TS>     Sent: Sat, June 12, 2010 1:24:58 AM
> TS>     Subject: [amibroker] impenetrable AFL
> 
> TS>       
> TS>     Impenetrable! (At least to me.)
> 
> TS>     xcolor = IIf(TSI >= SigLine, SetChartBkGradientF ill(
> TS> ParamColor(" BgTop", ColorRGB( 172,172,172 )),
> TS>     ParamColor(" BgBottom" , ColorRGB( 172,172,172 ))),
> TS> SetChartBkGradientF ill( ParamColor(" BgTop", ColorRGB(140, 140,140)) ,
> TS>     ParamColor(" BgBottom" , ColorRGB(140, 140,140)) ));
> 
> TS>     SetChartBkColor( SelectedValue( xcolor));
> 
> TS>     I tried that line above as
> TS>     SetChartBkGradientF ill(SelectedValu e(xcolor) ); but that produced a
> TS>     syntax error.
> 
> TS>     I think you can see what I'm trying to do here. The idea is simple:
> TS>     change the background gradient depending on a true/false result. The
> TS>     gradients in this example are not the gradients I would actually use
> TS>     (in fact they are not gradients at all, as your intelligent eyes will
> TS>     quickly have seen). They are just test code to see if I can even
> TS>     make it work. I cannot.
> 
> TS>     For one thing, the gradient does not change no matter the selected
> TS>     value. It's static. For another thing, the margin background goes
> TS>     to black, a hideous (although somewhat foreseen) result.
> 
> TS>     Okay, what am I doing wrong, and where did I miss this in the docs?
> TS>     And what, if anything, can I do about this margin result? The only
> TS>     way I can change the *entire* background color is by not using a
> TS>     gradient??? (Using SetChartBkColor) How sad that would be! I can
> TS>     make that work, at least. But not with a gradient.
> 
> TS>     Anything is possible in Amibroker, right?
> 
> TS>     Wrong?
> 
> TS>     Thanks,
> 
> TS>     Yuki
> 
> 
> 
> 
> 
> TS>
>


Reply via email to