bondikho 0 Posted November 4, 2021 Report Share Posted November 4, 2021 Lets say I have those price values 0.38 0.33 0.30 0.25 0.20 0.17 0.12 I scrape my crypto price that gives me a value of 0.22 Now what I want is to find the closest value under and over this price of 0.22, In this case it will be 0.25 and 0.20 How can I do that with ubot after adding all values to a list. Any other suggestion will be appreciated thank you Quote Link to post Share on other sites
Varo 28 Posted November 5, 2021 Report Share Posted November 5, 2021 add your value (0.22) to the list, sort the list, find index position value from list. set(#target,0.22,"Global") clear list(%source) add list to list(%source,$list from text("0.38 0.33 0.30 0.25 0.20 0.17 0.12"," "),"Delete","Global") add item to list(%source,#target,"Delete","Global") clear list(%sorted) add list to list(%sorted,$list from text($sort list(%source,"Ascending")," "),"Delete","Global") set(#position,0,"Global") loop while($comparison(#target,"!= Does not equal",$list item(%sorted,#position))) { increment(#position) } alert("value under target price : {$list item(%sorted,$subtract(#position,1))} value over target price: {$list item(%sorted,$add(#position,1))}") Quote Link to post Share on other sites
bondikho 0 Posted November 10, 2021 Author Report Share Posted November 10, 2021 thank you will try that Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.