Hi,
See most recent version of binary search at
viewtopic.php?f=5&t=7749
It has one for seconds bars and minute bars as well as test scripts. It properly handles maxbarsback. This thread may be of some value but I have removed the zip file so people only use the zip file from the above thread.
ORIGINAL POST BEGINS HERE:
I have some EL code in a study that is executed only in the last bar in the chart which gets a date and time from somewhere (GV, arrow placement on the chart, whatever). This date and time is not the current bars date and time but rather a historic bar. The study needs to use this date and time to get the high and low of that historic bar. I am looking for the fastest way to get this to execute. I have scanned all the functions in the reference and unless I missed it, there appears to be no function for this. Is there an existing function for this? I searched the forum and nothing is found.
To save reading, I did write the binary search and it works. It is limited to a certain number of bars back. You can play with it if you want.
Thanks,
John.
Fastest way to search back with only date and time.
I don't really understand what you mean when you say: "I have some EL code in a study that is executed only in the last bar in the chart which gets the date and time and needs to go back and get the high and low of a previous bar that has this date and time.
How can a previous bar has the same date and time than the last bar on the chart?
Either way, binary search is only useful when the list of data is sorted. If you try to find a value in an unsorted list, you will need to look at each value.
How can a previous bar has the same date and time than the last bar on the chart?
Either way, binary search is only useful when the list of data is sorted. If you try to find a value in an unsorted list, you will need to look at each value.
Here is the code.
See most recent version of binary search at
viewtopic.php?f=5&t=7749
It has one for seconds bars and minute bars as well as test scripts.
viewtopic.php?f=5&t=7749
It has one for seconds bars and minute bars as well as test scripts.
Last edited by bowlesj3 on 07 Jul 2008, edited 5 times in total.