Calculating Take Profit as a Percentage of Account Balance

164

Hi Guys,

So I'm trying to write a piece of code to calculate a take profit in PIPs that will equal a set percentage of the Account Balance at the time of placing the trade. I have preivously calculated the number of Lots for the trade as a function of the Stop Loss and Percentage Risk, and so I tried to rearrange the equation to work out a take profit, but I can't get it to work. Was hoping that someone could look at the maths and tell me where I've gone wrong. Here is the code.

```   //Calculate Lot Size
RiskAmount = (AccountBalance()*(RiskPercentage/100));
TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
if(Point == 0.001 || Point == 0.00001) TickValue *= 10;
Lots = ((RiskAmount / StopLoss) / TickValue);
Print(Lots);

//Calculate Take Profit
ProfitAmount = (AccountBalance()*(ProfitPercentage/100));
Print(ProfitAmount);
TickValue = MarketInfo(Symbol(),MODE_TICKVALUE);
if(Point == 0.001 || Point == 0.00001) TickValue *= 10;
TakeProfit = (((Lots/TickValue)/ProfitAmount)/PointValue);
Print(TakeProfit);
```
The lot size calculates perfectly, but the take profit gives me silly numbers. I suck at maths by the way...
436

DrBeardface:

Hi Guys,

So I'm trying to write a piece of code to calculate a take profit in PIPs that will equal a set percentage of the Account Balance at the time of placing the trade. I have preivously calculated the number of Lots for the trade as a function of the Stop Loss and Percentage Risk, and so I tried to rearrange the equation to work out a take profit, but I can't get it to work. Was hoping that someone could look at the maths and tell me where I've gone wrong. Here is the code.

The lot size calculates perfectly, but the take profit gives me silly numbers. I suck at maths by the way...

I can not help you with the formula, as i scuk at math also.

But just like you set you stop levels where they need to be, so should your take profit level(s). Calculating your take profit level based on your account balance is similar to calculating your take profit level based on the current outside temperature. There is no correlation.

164

It's part of the strategy that I use. But it doesn't matter anyway, I figured it out.

5

```Try this

TakeProfit = ProfitAmount/(TickValue*Lots);```
To add comments, please log in or register