Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
One simple way is not to store any negative values in the list. If you need the negative values for another purpose, create an additional array variable. See the psuedo code at below:
Your other most straightforward option is to read each item in the list using a for loop. Additionally, you could simply keep a running track of the smallest item thereby not requiring any search at all.
hi,
i was hoping this to be posible without the use of an array.
i have never build an array.....
the values i am storing are fixed (floor pivots) and i want to find the one that is the closed below the current price.
Arrays aren't very difficult to use: you might look into them. However, if you want to avoid an array and only have a few items you can use the code below which is basically implementation of pseudo method shown above:
pretty is in the eye of the beholder - if it works for you, great.
If you want to create it more efficient you can take a look at a "for loop" (as @tpredictor mentioned) and the "switch" statement and combine them (basically loop from 0 to 12 and have the switch statement return the corresponding pivot to your current loop count) - you don't even have to use an array in that approach, just one variable that holds your current pivot (within the loop) and one variable that holds the current smallest positive value.