# How to properly calculate fee into backtester

I know this is a simple questions but I can't seem to get this right.

I am trying to figure out to how to calculate the minimum sell to be profitable and also the maximum buy to be "profitable" (after a sell). Obviously profits are not realized until the sell, but for the purposes of my algo I would like to break things down into two calculations: minimum sell to be profitable after a buy, maximum buy to be profitable after a sell.

So for a particular broker let's say there is a 1% fee on a trade (buy or sell). Let's say I buy at a price point of \$100 dollars. I want to figure out the minimum sell price that would make a profit.

Since I am buying at \$100 and then selling at price X, that makes me think I am making two trades (1% + 1% == 2%), so I would need to sell at at least \$102 to make a profit.

So that makes sense, but then when I do the reverse, and try to calculate the maximum buy to make a "profit" after a sell, I feel like I am counting fees twice since the sell that was made, already has it's fees incorporated into last calculations. I'm not sure if it makes sense to treat each buy/sell pair as individual entities as charge them a 2% fee, or whether or not fees from the initial trade should not count and only charge 1%.

Submitted November 11, 2020 at 07:06PM by Yogi_DMT
via https://ift.tt/32Btb3M