Replacing/updating data in a running column with previously unused data in rows above

aiki100

Board Regular
Joined
Aug 16, 2016
Messages
102
Greetings all -

I am stumped on how to accomplish this and would be very grateful for any help or suggestions, thank you!


1 - I have rows with prices in them in a table: open, high, low, close (cols ABCD)

2 - Col E has a formula that identifies a condition. For simplicity's sake, I am hand entering a text string of "SC" (satisfies criteria) for this example worksheet.


3- Col F records the high price of the row (col B) if ColE = "SC".


4- Col G is a running count of the price (col F) last triggered by Col E's "SC". When a new "SC" is triggerred, Col G is updated with that new price.

5- If the high (col B) exceeds the value listed in Col G, then Col H should return "condition met", and if not, it is left blank.

A precondition for this to calculate properly is:
One issue I have identified, is that the high (col B) of the row before must be below an SC value before the next row can (possibly) exceed it. This ensures that an SC value that has already been exceeded is not counted as exceed again for rows (or even the very next row) that starts above an SC value already encountered.


A requirement:
Since this a table, that the solution still function if the table is sorted.


Example:

Once SC Val run price (col G) has been used (exceeded), subsequent rows now need to validate against the (now) nearest, unused SC Val run price. This would come from an unused price in col F.

In this case, row four is the first row that satisfies the criteria, so the price (SC value) is stored in F4. It also now constitutes the first running value in G4.


In row 8, the high price exceeds the SC Val run (G6, the stored 99.83), thus "condition met" in H8.

In row 15, the criteria has been satisfied, so a new SC Value (85.00, F15) has been stored. It happens to be below the the last used SC Value. It satisfies the condition in H17, even though it satisfies it at a lower price.


Now— Please note that in F9, there is a stored price (that did satisfy the criteria), but no high price from col B9-B18 so far has exceeded it.

**What I need is to have the NEAREST, UNUSED, price to become the data for col G18.


Why G18? Because the bar above it has had the condition met, so this is now a used price. I now need to supply the nearest UNUSED price above, in col G18 for subsequnt rows to test against.


Question one: how do you discard a price that has now been used in a running column, and get the next nearest unsused price above into that column? An unused SC value run (col G) could be above or below the most recently exceeded one.


Question two: it is certainly possible that a single high price could exceed several SC values in one shot. If it does, again, how to eliminate all those now "used" prices in favor of the (now) most recent, unused SC value run price?


Question three: It is also certainly possible that in 2000 rows, an SC value could be the exact same as some value used before, which could still be a now legitimate new value to test against. So there needs to be some way to reset what is considered used vs. something that (even if at the exact same price as before) is considered a new value to test against. Reset by number of rows? Days? A range of high to low prices?

I hope the above description makes sense:
It is (very) possible that running column is not the way to achieve this. It is also possible that I am either overthinking the problem, or the opposite, missing additional issues.

Thanks so much for the help!




The FO Q.xlsx
ABCDEFGH
1Open PriceHigh PriceLow PriceClose priceSatisfies CriteriaSC ValueSC Val RunCondition Met
2(formula to satisfy criteria)
3100.0082.0099.5899.68 0.00 
499.6799.8398.5898.81SC99.8399.83 
598.8299.1298.6498.88 99.83 
698.8799.0097.7898.90 99.83 
798.9199.6098.8699.74 99.83 
899.76101.5199.73100.58 99.83condition met
9100.58101.7899.83100.06SC101.78101.78 
10100.05100.3798.3898.54 101.78 
1198.5499.6898.4299.41 101.78 
1299.41101.0098.85100.58 101.78 
13100.5691.0099.2599.95 101.78 
1499.9684.0099.6599.71 101.78 
1590.0085.0089.7590.25SC85.0085.00 
1699.5584.9098.8699.07 85.00 
1784.9086.0084.5085.75 85.00condition met
1885.7586.2683.0083.20 85.00 
Sheet1
Cell Formulas
RangeFormula
F3:F18F3=IF(E3="SC",B3,"")
G3:G18G3=IF(F3="",G2,F3)
H3:H18H3=IF(AND(B2<G3,B3>G3), "condition met","")
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Greetings all -

I am stumped on how to accomplish this and would be very grateful for any help or suggestions, thank you!


1 - I have rows with prices in them in a table: open, high, low, close (cols ABCD)

2 - Col E has a formula that identifies a condition. For simplicity's sake, I am hand entering a text string of "SC" (satisfies criteria) for this example worksheet.


3- Col F records the high price of the row (col B) if ColE = "SC".


4- Col G is a running count of the price (col F) last triggered by Col E's "SC". When a new "SC" is triggerred, Col G is updated with that new price.

5- If the high (col B) exceeds the value listed in Col G, then Col H should return "condition met", and if not, it is left blank.

A precondition for this to calculate properly is:
One issue I have identified, is that the high (col B) of the row before must be below an SC value before the next row can (possibly) exceed it. This ensures that an SC value that has already been exceeded is not counted as exceed again for rows (or even the very next row) that starts above an SC value already encountered.


A requirement:
Since this a table, that the solution still function if the table is sorted.


Example:

Once SC Val run price (col G) has been used (exceeded), subsequent rows now need to validate against the (now) nearest, unused SC Val run price. This would come from an unused price in col F.

In this case, row four is the first row that satisfies the criteria, so the price (SC value) is stored in F4. It also now constitutes the first running value in G4.


In row 8, the high price exceeds the SC Val run (G6, the stored 99.83), thus "condition met" in H8.

In row 15, the criteria has been satisfied, so a new SC Value (85.00, F15) has been stored. It happens to be below the the last used SC Value. It satisfies the condition in H17, even though it satisfies it at a lower price.


Now— Please note that in F9, there is a stored price (that did satisfy the criteria), but no high price from col B9-B18 so far has exceeded it.

**What I need is to have the NEAREST, UNUSED, price to become the data for col G18.


Why G18? Because the bar above it has had the condition met, so this is now a used price. I now need to supply the nearest UNUSED price above, in col G18 for subsequnt rows to test against.


Question one: how do you discard a price that has now been used in a running column, and get the next nearest unsused price above into that column? An unused SC value run (col G) could be above or below the most recently exceeded one.


Question two: it is certainly possible that a single high price could exceed several SC values in one shot. If it does, again, how to eliminate all those now "used" prices in favor of the (now) most recent, unused SC value run price?


Question three: It is also certainly possible that in 2000 rows, an SC value could be the exact same as some value used before, which could still be a now legitimate new value to test against. So there needs to be some way to reset what is considered used vs. something that (even if at the exact same price as before) is considered a new value to test against. Reset by number of rows? Days? A range of high to low prices?

I hope the above description makes sense:
It is (very) possible that running column is not the way to achieve this. It is also possible that I am either overthinking the problem, or the opposite, missing additional issues.

Thanks so much for the help!




The FO Q.xlsx
ABCDEFGH
1Open PriceHigh PriceLow PriceClose priceSatisfies CriteriaSC ValueSC Val RunCondition Met
2(formula to satisfy criteria)
3100.0082.0099.5899.68 0.00 
499.6799.8398.5898.81SC99.8399.83 
598.8299.1298.6498.88 99.83 
698.8799.0097.7898.90 99.83 
798.9199.6098.8699.74 99.83 
899.76101.5199.73100.58 99.83condition met
9100.58101.7899.83100.06SC101.78101.78 
10100.05100.3798.3898.54 101.78 
1198.5499.6898.4299.41 101.78 
1299.41101.0098.85100.58 101.78 
13100.5691.0099.2599.95 101.78 
1499.9684.0099.6599.71 101.78 
1590.0085.0089.7590.25SC85.0085.00 
1699.5584.9098.8699.07 85.00 
1784.9086.0084.5085.75 85.00condition met
1885.7586.2683.0083.20 85.00 
Sheet1
Cell Formulas
RangeFormula
F3:F18F3=IF(E3="SC",B3,"")
G3:G18G3=IF(F3="",G2,F3)
H3:H18H3=IF(AND(B2<G3,B3>G3), "condition met","")

Thought I would add this, for clarity:
 

Attachments

  • Desired result.jpg
    Desired result.jpg
    62.5 KB · Views: 6
Upvote 0

Forum statistics

Threads
1,214,428
Messages
6,119,420
Members
448,895
Latest member
omarahmed1

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top