Calculate Break Even
Calculate Break Even
04 Jan 2014, 19:43
Please help me with a simple but sufficient Break Even Point Calculation, that includes spread and commission. Something like:
Private double calcBE(Position p) { double be = p.EntryPrice; if(p.TradeType = TradeType.Buy) { be = be + (Symbol.Spread + ... p.Commissions ....) } else { be = be - (Symbol.Spread + ... p.Commissions ...) } return be; }
But how do i calculate the commission into a course value?
Replies
jeex
04 Jan 2014, 21:18
Simple
Thanks Researcher. Way simpler than i was thinking.
So to calculate the price level of the Break Even point BE:
private double calcBE(Position p) { double totalCosts = Symbol.Spread + (p.GrossProfit - p.NetProfit); if (p.TradeType == TradeType.Buy) return p.EntryPrice + totalCosts; else return p.EntryPrice - totalCosts; }
@jeex
Cerunnos
04 Jan 2014, 23:14
RE: Simple
jeex said:
Thanks Researcher. Way simpler than i was thinking.
So to calculate the price level of the Break Even point BE:
private double calcBE(Position p) { double totalCosts = Symbol.Spread + (p.GrossProfit - p.NetProfit); if (p.TradeType == TradeType.Buy) return p.EntryPrice + totalCosts; else return p.EntryPrice - totalCosts; }
Your code includes commission only one way. Or not?
@Cerunnos
jeex
04 Jan 2014, 23:50
RE: RE: Simple
Cerunnos said:
Your code includes commission only one way. Or not?
Yep, my mistake: should include them both ways, thanks for the reminder:
private double calcBE(Position p) { double totalCosts = Symbol.Spread + ((p.GrossProfit - p.NetProfit) * 2); if (p.TradeType == TradeType.Buy) return p.EntryPrice + totalCosts; else return p.EntryPrice - totalCosts; }
@jeex
jeex
05 Jan 2014, 12:21
Alzheimer sure flies low this winter
Cerunnos, that's why i called in some help.
Somehow my math brain becomes blind for simple calculations. I'm completely lost. Maybe a short vacation will help.
double totalCosts = Symbol.Spread + (((position.GrossProfit - position.NetProfit) / position.Volume / Symbol.PipValue)*2);
@jeex
fxtradersystems
06 Oct 2020, 13:46
Break Even Price
jeex said:
Cerunnos, that's why i called in some help.
Somehow my math brain becomes blind for simple calculations. I'm completely lost. Maybe a short vacation will help.
double totalCosts = Symbol.Spread + (((position.GrossProfit - position.NetProfit) / position.Volume / Symbol.PipValue)*2);
The way I thought about it, was that the costs were fixed for the trade (now NetProfit includes both way commisions), but the profit fluctuated. You could therefore calculate the fixed cost as a proportionate distance of the Bid from the entry price.
My calculations look like:
// Calculate the distance of the trade, less the spread.
double distance = Bid - (position.EntryPrice + Symbol.Spread);
// Figure out how much the costs of the trade are versus the Gross profit.
double cost_fraction = (position.GrossProfit - position.NetProfit) / position.GrossProfit;
// The gross profit is spread out over the entire distance of the trade from the entry price
// therefore add this fraction of the distance on to the entry price.
double breakEven = position.EntryPrice + cost_fraction * distance;
// Equivalently for a sell position:
double distance = (position.EntryPrice - Symbol.Spread) - Bid;
double cost_fraction = (position.GrossProfit - position.NetProfit) / position.GrossProfit;
double breakEven = position.EntryPrice - cost_fraction * distance;
@fxtradersystems
firemyst
09 Oct 2020, 17:53
RE: Break Even Price
fxtradersystems said:
The way I thought about it, was that the costs were fixed for the trade (now NetProfit includes both way commisions), but the profit fluctuated. You could therefore calculate the fixed cost as a proportionate distance of the Bid from the entry price.
My calculations look like:
// Calculate the distance of the trade, less the spread. double distance = Bid - (position.EntryPrice + Symbol.Spread); // Figure out how much the costs of the trade are versus the Gross profit. double cost_fraction = (position.GrossProfit - position.NetProfit) / position.GrossProfit; // The gross profit is spread out over the entire distance of the trade from the entry price // therefore add this fraction of the distance on to the entry price. double breakEven = position.EntryPrice + cost_fraction * distance; // Equivalently for a sell position: double distance = (position.EntryPrice - Symbol.Spread) - Bid; double cost_fraction = (position.GrossProfit - position.NetProfit) / position.GrossProfit; double breakEven = position.EntryPrice - cost_fraction * distance;
I believe your calculations are incorrect.
For starters, you're using BID price everywhere. On Long/buy positions, you get the ASK price, not the BID price.
In your calculation, your value could be negative as a result. For instance, assume ASK is 5, BID is 4, with a 1 pip spread. Thus your entry would be 5 (because the ASK could have been 5), so 4 - (5 + 1) = -2. For a long/buy position, the break even should be above the ASK price (obviously) and not below the BID price.
Second, your calculation (position.EntryPrice + Symbol.Spread) is adding a price value plus pips. You need to add price value plus the equivalent value in pips, so it should be:
(position.EntryPrice + (Symbol.Spread * Symbol.PipSize))
Hope that helps :-)
@firemyst
fxtradersystems
10 Oct 2020, 19:25
RE: RE: Break Even Price
firemyst said:
I believe your calculations are incorrect.For starters, you're using BID price everywhere. On Long/buy positions, you get the ASK price, not the BID price.
In your calculation, your value could be negative as a result. For instance, assume ASK is 5, BID is 4, with a 1 pip spread. Thus your entry would be 5 (because the ASK could have been 5), so 4 - (5 + 1) = -2. For a long/buy position, the break even should be above the ASK price (obviously) and not below the BID price.
Second, your calculation (position.EntryPrice + Symbol.Spread) is adding a price value plus pips. You need to add price value plus the equivalent value in pips, so it should be:
(position.EntryPrice + (Symbol.Spread * Symbol.PipSize))
Hope that helps :-)
Hi @firemyst,
You were right, particularly with the ASK / BID relationship - this also means (we believe) that we don't need to include it in the distance calculation, as we can actually just get the current ASK/BID.
We've tested the following code in backtest on AUDJPY m30, both buy and sell positions, with lot sizes of 0.01, 1, and 10, and with spreads of 1 pip and 30 pips. It seems to work as intended, though for some trades falls 0.4-0.8 pips short of break even (resulting in a loss of £4 on a 10 lot trade). You could modify it to put an additional buffer of one pip if desired.
The only thing it hasn't come up against is commission and swaps in testing, but I believe these are both in the NetProfit figure (?) so it should still hold true.
Let us know if you find any more errors and we'd be happy to correct :)
private double CalculateBE(Position position)
{
// Breakeven is the entry price, plus proportional costs.
double costFraction = (position.GrossProfit - position.NetProfit) / position.GrossProfit;
double priceDistance;
double bePriceLevel;
if (position.TradeType == TradeType.Sell)
{
// Get the ask price, as you're trying to buy back
priceDistance = Math.Abs(Ask - position.EntryPrice);
bePriceLevel = position.EntryPrice - priceDistance * costFraction;
}
else
{
// Get the bid price as you're trying to sell back
priceDistance = Math.Abs(Bid - position.EntryPrice);
bePriceLevel = position.EntryPrice + priceDistance * costFraction;
}
return bePriceLevel;
}
Made by fxtradersystems.com
@fxtradersystems
Researcher
04 Jan 2014, 21:02
Use this code to get amount of pips:
@Researcher