# Bizarre uneven takeprofit and stoploss

10

Hi All,

I've been trying to ensure that my takeprofit and stoploss are equal (in other words, profits and losses should be of the same magnitude). I've done a bit of investigating and tried a few solutions but I still get uneven profits and losses - even though looking at the prices in the results tab it they should be equal. Here's the code I used to execute the trades:

{

//Get new market prices

RefreshRates();

//Define lot size
double Lots = 0.01;
int LotDigits = (int) - MathLog10(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP));
double LotSize=NormalizeDouble(Lots,LotDigits);

return(false);

//Define allowed slippage

int SlippageInPoints = 0;

//Define TakeProfit and StopLoss levels

if(Ticket==-1)
{
return(false);
}

if(Ticket>=0)
{
return(true);
}

return(false);

}

bool OpenSell()
{

//Get new market prices

RefreshRates();

//Define lot size

double Lots = 0.01;
int LotDigits = (int) - MathLog10(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP));
double LotSize=NormalizeDouble(Lots,LotDigits);

return(false);

//Define allowed slippage

int SlippageInPoints = 0;

//Define TakeProfit and StopLoss levels

if(Ticket==-1)
{
return(false);
}

if(Ticket>=0)
{
return(true);
}

return(false);

}

and here are some of the resulting trades:

As you can see the profit is always 23 cents and the loss is always 37 cents. I've been wracking my brain to figure out what is going on but I can't figure it out. Am I missing something obvious to do with the bid/ask spread?

Any help would be greatly appreciated.

Moderator
10651

7 cents commission?
10

Keith Watford:
7 cents commission?

You know what - I think you're right. That makes sense on what the broker charges. I hadn't figured on that. Dammit!

Thanks for your help though :) Much appreciated

15925

1.  Play video Please edit your post. For large amounts of code, attach it

2.    int LotDigits = (int) - MathLog10(SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP));
double LotSize=NormalizeDouble(Lots,LotDigits);

Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
LotDigits also fails when not a power of 1/10. (int) MathCeil(-MathLog10(...)) will work.