What's the best way to compare if a variable falls within a range of parameters

I need to store a value and then check if it’s outside a specified amount of exisiting values, i.e. Current value 500 is within 100 of any of the following 105, 290, 333, 450, 547, 670, 850

Each value is being checked one at a time, so I need to check if it’s both within 100 above and 100 below

if it’s not within 100 of a given value it passes the check if not it store a record to pass on adding the new value to the list.

My current logic is as follows, but I seem to be getting values that shouldn;t be added

The following is only part of multiple scripts running in line with each other so ingnore and non defined variables, it’s more about the part that compares the entry value with openrate and if the logic is sound or if I need to edit that part to make it work correctly.

{
“Command”: “store”,
“Target”: “False”,
“Value”: “NoMoreAction”,
“Description”: “”
},
{
“Command”: “sourceSearch”,
“Target”: “<td class=“col-instrument”>”,
“Value”: “Orders”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “NextOrder”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “tr[${Orders}]”,
“Value”: “ATN”,
“Description”: “Limit Action Number”
},
{
“Command”: “gotoIf_v2”,
“Target”: “${Orders} < 1”,
“Value”: “Exit”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${Orders}==1”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “tr”,
“Value”: “ATN”,
“Description”: “Limit Action Number”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “storeText”,
“Target”: “xpath=//*[@id=“region-main”]/div/div/div[2]/div[3]/table/tbody/${ATN}/td[4]”,
“Value”: “entry”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “var str = ${entry};\nstr = str.replace(/\s+/g,’’ ).replace(/^\s/,’’).replace(/\s$/,’’);\nreturn str”,
“Value”: “entry”,
“Description”: “”
},
{
“Command”: “comment”,
“Target”: “executeScript // return Number((${Gap}) * 2) * Math.ceil(${entry}/ Number((${TradeGap}) * 2));”,
“Value”: “openRate”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “return ((100 * Math.ceil(${entry})/ 100) + 50);”,
“Value”: “entryUp”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “return ((100 * Math.floor(${entry})/ 100) - 50);”,
“Value”: “entryDown”,
“Description”: “”
},
{
“Command”: “storeAttribute”,
“Target”: “xpath=(//tbody/${ATN}/td[1]/div[1]/div[1]/div[1]/span[1])@data-direction”,
“Value”: “EntryActionType”,
“Description”: “”
},
{
“Command”: “executeScript”,
“Target”: “return (Number(${Orders}) - 1);”,
“Value”: “Orders”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${entryUp} > ${openRate}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “elseif”,
“Target”: “${entryDown} < ${openRate}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoLabel”,
“Target”: “NextOrder”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “if_v2”,
“Target”: “${entry} == ${openRate}”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “gotoIf_v2”,
“Target”: “${EntryActionType} != ${CurrentActionType}”,
“Value”: “Pass”,
“Description”: “”
},
{
“Command”: “gotoLabel”,
“Target”: “NoAction”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “Pass”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “Exit”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “1”,
“Value”: “DoAction”,
“Description”: “”
},
{
“Command”: “gotoLabel”,
“Target”: “Action”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “label”,
“Target”: “NoAction”,
“Value”: “”,
“Description”: “”
},
{
“Command”: “store”,
“Target”: “0”,
“Value”: “DoAction”,
“Description”: “”
},