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

[amibroker] Re: Single Value from Array



PureBytes Links

Trading Reference Links

Try this:

//---------------------------------------------
DN	= DateNum();

for (i= 0; i < BarCount - 1 AND Close[i]== Close[0]; i++);

_TRACE("firstDifferent = " + Close[i]);
_TRACE("DateNum = " + DN[i]);

//----------------------------------------------

Bill


--- In amibroker@xxxxxxxxxxxxxxx, "fatboycato" <fatboycato@xxx> wrote:
>
> Well, I'm stumped. I've tried just about every way I could think of 
> to get this accomplished, but I'm simply not smart enough to do it. 
> Hopefully, someone here is.
> 
> I can't seem to iterate through an array to discover if a value is 
> different from a base value. For example: suppose your array looks 
> like this:
> 0,0,0,0,0,0,0,0,1,1,1,1,1
> 


> I want to look through that array and return "1" the first time it 
> changes from 0 to 1. The problem is that arrays can't show up in any 
> kind of loop. I don't know the 1 is there, so I can't just look 
> for "1". I need to look through the array and return the different 
> value, whatever it may be.
> 
> Here's an example of what the code would look like:
> 
> I have an array.
> Look at the first number in the array and call it "x".
> Look at the second number in the array. If it's the same as "x", 
> then look at the third number. If it's still the same, look at the 
> fourth number, etc...
> Once you get to a number that is not "x", call that number "y".
> Stop looking for something other than "x".
> 
> Any ideas? The Ref() function obviously won't work because it 
> returns an array. Is there another function that works like Ref(), 
> but returns a single value?
>






------------------------ 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/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/