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)
I'm probably doing something wrong here. I can't seem to Add and Remove values from the ArrayList. The prints are not going to the output window. Could someone please help? I've attached the code. TIA! Kay Wai
May I know why that is the case? I only want to store the 2 most recent observations and discard the older observations.
Perhaps you could suggest a better way of doing this.
These observations only come about when a bool is true and I want to use the 2 most recent observations to draw horizontal lines which updates as new bars are created and stops when either 1) another bool becomes true or 2) the observation is "old". However, I would like to keep the old line on the chart, if possible.
I thought about using the DataSeries but I understand that when there is "no" data for it to add, it defaults to zero. trying to avoid that problem.
Sure, you have a logic flaw in your code. Your code says only add to the arraylist if the arraylist has more than 2 items in it. Since the arraylist starts with a count of zero, it will never be greater than 2 since it can only ever be added to once the count is greater than 2. In other words, the greater than 2 condition can never be true.
This condition will never be executed since .Count > 2 will never be true. Your need to move the .Add() call outside of this if branch.