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