How to calculate entry price + 1 pip + commission costs
How to calculate entry price + 1 pip + commission costs
27 Jun 2019, 08:04
Hi everyone:
I have a formula where when a position is in profit by x-amount of pips, I want to move the SL to a "break even" point (including commissions) plus 1 pip.
Example: if Entry price is $5, commission each way is $1, and 1 pip is $0.50, then the "break even" point would be:
5 + ABS($1 * 2) + (1 * $0.50) == $7.50.
I have the following, but it doesn't seem to be working quite as expected as sometimes (depending on the symbol) when it's moved and I check in cTrader, the line on the chart says, "0.4" pips (above the entry point) for the SL, whereas it should always show at least "1.0".
Here's what I have for "buy long" trades. My gut feeling is it's not 100% correct, but I can't seem to find what's wrong with it either:
//calculate the value of 1 pip + the commission cost (both ways) double adjustment = (Symbol.PipSize * 1) + (Math.Abs(p.Commissions) * 2 * Symbol.PipValue); //I also had the following: //double adjustment = (Symbol.PipSize * 1 * Symbol.PipValue) + (Math.Abs(p.Commissions) * 2 * Symbol.PipValue); //add it onto the entry price double newSL = entryPrice + adjustment; //modify the position to the new price TradeResult r = p.ModifyStopLossPrice(newSL);
Any help would be appreciated.
Thanks!
firemyst
27 Jun 2019, 10:20
I believe I have figured it out.
I believe the calculation should be the following:
But if anyone else thinks otherwise, I'm definitely open.
Thanks!
@firemyst