Increase volume as account balance increases

Created at 27 Feb 2016, 08:18
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
DA

davidp13

Joined 06.05.2014

Increase volume as account balance increases
27 Feb 2016, 08:18


Hi. Im looking for a way to increase the volume on trades as my account balance increases. For every $1000 the account grows I want to add an additional unit automatically. How would one code something like this?

Thanks


@davidp13
Replies

gainer
27 Feb 2016, 10:02

RE:

davidp13 said:

Hi. Im looking for a way to increase the volume on trades as my account balance increases. For every $1000 the account grows I want to add an additional unit automatically. How would one code something like this?

Thanks

 

Hi, I use this

  1. if you fix a lot, it uses this
  2. if you let lots = 0.0 it uses THE FULL ACCOUNT (I use many small accounts everyone dedicated to a single cBot)
  3. if you want, you can put a variable set to some % of the total account and use it instead of the Account.Balance
  4. you should use the code just before opening your orders, to be sure to have the actual real balance
  5. ...only one note: it doesn't consider the commissions and so on, but normally this isn't a problem, because the rounding let in the account enough to pay them

 

......

public double lots = 0.0;

.....

long maxVolume = Symbol.NormalizeVolume((lots > 0 ? Symbol.QuantityToVolume(lots) : Account.Balance * Account.Leverage), RoundingMode.Down);

.....

 


@gainer

gainer
27 Feb 2016, 11:00

RE: RE:

gainer said:

davidp13 said:

Hi. Im looking for a way to increase the volume on trades as my account balance increases. For every $1000 the account grows I want to add an additional unit automatically. How would one code something like this?

Thanks

 

Hi, I use this

  1. if you fix a lot, it uses this
  2. if you let lots = 0.0 it uses THE FULL ACCOUNT (I use many small accounts everyone dedicated to a single cBot)
  3. if you want, you can put a variable set to some % of the total account and use it instead of the Account.Balance
  4. you should use the code just before opening your orders, to be sure to have the actual real balance
  5. ...only one note: it doesn't consider the commissions and so on, but normally this isn't a problem, because the rounding let in the account enough to pay them

 

......

public double lots = 0.0;

.....

long maxVolume = Symbol.NormalizeVolume((lots > 0 ? Symbol.QuantityToVolume(lots) : Account.Balance * Account.Leverage), RoundingMode.Down);

.....

 

 

this is the complete code, you must use a % of the total account as parameter, so the money can vary according to your Account.Balance

(...warning! I wrote it now... test it carefully !!!)

 

.....

[Parameter("Fix lots (0 = NO)", DefaultValue = 0.0)]
public double lots { get; set; }

[Parameter("% of the total account to use", DefaultValue = 100.0, MinValue = 0.0, MaxValue = 100.0)]
public double openRatio { get; set; }

.....

long maxVolume = Symbol.NormalizeVolume((lots > 0 ? Symbol.QuantityToVolume(lots) : Account.Balance * Account.Leverage * openRatio / 100), RoundingMode.Down);

 


@gainer

moped170574
17 Mar 2016, 15:01

This post was removed by moderator.