Calculate long/short positions

Megamannen

New Member
Joined
Oct 23, 2013
Messages
7
Hi I’m an excel newbie. I have Mac excel 2010.

I’m trying to perform trading backtesting and calculate long and short positions.

In column A I have Google stock closing price
In column B I have “BUY” or no information at all
In column C I have “SELL” or no information at all

In D2 I have a sum of 10 000 dollars. Let’s say there is a BUY in B3 and a blank in C3. In this case I would perform this calculation =IF(B3=”BUY”,C3=””),(A4/A3)*D2,D2). If there was a blank in column B3 and a SELL in C3, I would perform this calculation =IF(B3=””,C3=”SELL”),(A3/A4)*D2,D2).

But here is my problem: Sometimes a BUY and a SELL collides on the same row level. And sometimes neither a BUY or a SELL appears.

Is there a neat way to solve this?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
why on earth would you buy 1000 google shares and sell 1000 google shares at the same time ?
 
Upvote 0
I wouldn't. I'm sorry if I was unclear.

If there is a BUY i B3 and a blank in C3 I would buy. But if there was a blank in B3 and a SELL in C3 I would sell. Of course this could not happen at the same time.

If there is a BUY in B3 and a SELL in C3 I would not do anything. I use various trading strategies and sometimes they contradict each other. My way of dealing with this is to stay passive and only change position if there is a clear SELL or BUY.
 
Upvote 0
Try something like this...

=IF(B3&C3="BUY",(A4/A3)*D2,IF(B3&C3="SELL",(A3/A4)*D2,D2))

Thank you sir for your response. It does partially solve my problem.

Although whenever a situation arises where there is a SELL and a BUY on the same row level, it is calculated just like I was liquidating my position. I would like to perform the previous calculation until there is a clear reverse signal, i.e. a BUY and a blank or a blank and a SELL.

Please bear with me if my english is terrible. It is a second language.
 
Upvote 0
Your english is very good.

I don't know how the previous calculation is determined or labeled, but maybe something like this? You will have to modify it to add the calculation.

=IF(B3&C3="BUY",(A4/A3)*D2,IF(B3&C3="SELL",(A3/A4)*D2,IF(B3&C3="BUYSELL","Previous calculation here", "Neither")))
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

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