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)
how to extract nearest support price from arraylist?
Does anyone have code that can do this, or something similar?
I have the prices of support/resistance (S/R) lines stored in an ArrayList. When price is moving up, I want to find the nearest S/R line, in said ArrayList, that is currently below the Close price, once price gets 1 point above the nearest S/R line. And, the opposite when price is moving down.
See attached image for illustration.
Thanks guys.
Can you help answer these questions from other members on NexusFi?
That's funny... sending me a link to my own modified code. LOL
The Swing ind. only stores the most recent occurance. I have an ArrayList, which may have up to 15 stored prices, that I need to look through.
In variables section declare a list object...they are more efficient than arrays and do not need to be initialized with a size. Or just use arrays, no matter. Methods are the same.
This routine will go thru the list object and put the next supprt (SRNextLow) below the Close of the current bar, and the next resistance (SRNextHigh) above the current close
if there are no support values above, it sets SRNextHigh to 0
if there are no support values below, it sets SRNextLow to 0
items may be added to the List object using .add method
Hope this helps
PS. dont forget to add a ref to
using System.Collections.Generic;
This way you don't need to worry about which way price is moving. The current bar close is always sandwiched between the two SR lines (one above and one below).