Increase volume as account balance increases
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
Replies
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
- if you fix a lot, it uses this
- if you let lots = 0.0 it uses THE FULL ACCOUNT (I use many small accounts everyone dedicated to a single cBot)
- if you want, you can put a variable set to some % of the total account and use it instead of the Account.Balance
- you should use the code just before opening your orders, to be sure to have the actual real balance
- ...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
gainer
27 Feb 2016, 10:02
RE:
davidp13 said:
Hi, I use this
@gainer