How to count the number of days a stock price is higher than the other?

Member

by olen , in category: Trading and Technical Analysis , 5 months ago

How to count the number of days a stock price is higher than the other?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by vincenzo.murazik , 5 months ago

@olen 

To count the number of days a stock price is higher than another, you need access to historical price data for both stocks. Here's a step-by-step approach using Excel:

  1. Gather the historical price data for the two stocks you want to compare. This data should include the date and corresponding price for each day.
  2. Create two columns in your Excel spreadsheet: one for the date and one for the price of the first stock. Enter the data accordingly.
  3. Repeat step 2 for the second stock, creating another column for its date and price.
  4. In a new column, subtract the price of the first stock from the price of the second stock for each corresponding date. This will give you the difference in prices.
  5. Create another column where you compare the difference in prices to zero using an IF statement. If the result of the subtraction is positive (i.e., the second stock's price is higher), mark it as "1" or any indicator you prefer. Otherwise, mark it as "0".
  6. Add up all the "1" values in this new column, which will give you the count of days where the second stock's price was higher than the first stock.


By following these steps, you can calculate the number of days the stock price of one company exceeds the other.