Consolidating Stock Backtest Data into Table

LakeDog

New Member
Joined
Oct 18, 2017
Messages
18
Office Version
  1. 365
Platform
  1. Windows
My novice ignorance will be showing here. Having written out a spreadsheet that uses raw stock price data, generates a couple indices and then based upon the indicators generates a "Long" or "Short" signal. While I have that in one column (of either Long or Short) as well as another column that only lists it as "Buy" or "Sell" only when the signal changes, There are a lot of empty cells in the later column. I'd like to consolidate it into a table that lists for each Buy signal, the next signal (which is a Sell by the column) and appropriate dates and prices. Here's an example demo table of what the main sheet looks like:

DatePriceIndicator1Indicator2SignalBuy/Sell
Date1Price1XXYYShort
Date2Price2XXYYLongBuy
Date3Price3XXYYLong
Date4Price4XXYYLong
Date5Price5XXYYShortSell
Date6Price6XXYYShort
Date7Price7XXYYLongBuy
Date8Pirce8XXYYLong
Date9Price9XXYYLong
Date10Price10XXYYShortSell

What I am after is something like this:


TradeBuyDateEntry PriceSellDateExit PriceP/L
1Date2Price2Date5Price5=(Price5-Price2)
2Date7Price7Date10Price10etc
3
4
5

I have tried a variety of LOOKUP functions, that haven't worked. I am happy to experiment and will keep trying, but was hoping someone might have a suggested solution or at least a direction to try. Suspect it's obvious to some, but totally escapes me. Any help appreciated.

Lakedog
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,223,164
Messages
6,170,444
Members
452,326
Latest member
johnshaji

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