Money Management: Size by Account Balance for FX

Can we please have an option for Size by Account Balance for FX.



Examples Settings:
Account Balance for Size: $5,000
Size: 0.03


Calculation for Order Size:
(Current Account Balance / Account Balance for Size) * Size


E.g.
Current Account Balance = $15,000
Account Balance for Size = $5,000
Size = 0.03




Order size will be calculated as :
($15,000 / $5,000) * 0.03 = 0.09




I wrote the attached Whatif snippet for Quant Analyzer that does this for me for backtesting.


I'm also currently working out how to modify my MQL4 files to do this too, but it would be good to have this as a native option inside SQ.


Thanks

Attachments
  • Votes +5
  • Project StrategyQuant X
  • Type Feature
  • Status New
  • Priority Normal

History

JK
#1

Insanity82007

26.02.2021 12:01

Task created

JK
#2

Insanity82007

26.02.2021 12:01
Voted for this task.
JK
#3

Insanity82007

26.02.2021 12:22

Attachment MultiplyOrderAccountBalance.java deleted

JK
#4

Insanity82007

26.02.2021 12:23

Attachment MultiplyOrderAccountBalance.java added

MultiplyOrderAccountBalance.java
(2.61 KiB)
re-attached snippet because it was wrong
k
#5

Karish

26.02.2021 14:43
Voted for this task.
MF
#6

Marti

26.02.2021 16:27
Voted for this task.
AT
#7

AngelTalavera

26.02.2021 20:07
Voted for this task.
b
#8

bentra

27.02.2021 01:36
Voted for this task.
JK
#9

Insanity82007

01.03.2021 02:20
I'm busy working on my QA script above trying to add a "cash injection" component to see what happens to my equity growth when I deposit $x per month. I'll attach this soon. 


In the mean time the following modification works in the MQL4 code:

//+------------------------------------------------------------------+

// Money Management variables

//+------------------------------------------------------------------+


extern string smm = "----------- Money Management - Fixed size -----------";

extern double mmLots = 0.03;


extern double AcctEquity = 0; 

extern double AcctEquityPerSize = 5000;

extern double SizeForAcctEquity = 0.03;


........

.......


then further down in void OnTick


//////////

//+------------------------------------------------------------------+

// -- Functions

//+------------------------------------------------------------------+


void OnTick() {


   AcctEquity=AccountEquity();


   mmLots = MathRound(100* AcctEquity / AcctEquityPerSize * SizeForAcctEquity) / 100;

   

   if (mmLots <= 0.01) {mmLots = 0.01;}


   sqInitStart();       

   

   sqManageOrders(MagicNumber);

   

   openingOrdersAllowed = sqHandleTradingOptions();

JK
#10

Insanity82007

01.03.2021 03:44
this is better


AcctEquity=MathMin( AccountEquity(), AccountBalance() );

JK
#11

Insanity82007

02.03.2021 00:42

Attachment MultiplyOrderAccountBalance.java added

MultiplyOrderAccountBalance.java
(3.55 KiB)
Ok final version of this extension for QA4.9


I fixed an issue with the Current Balance not calculating correctly due to the resizing of the Order PL. The Current Balance appears in the "Comments" field.


I've also added the ability to do a monthly cash injection that will check if the month has changed based on the order.CloseTime, and if it has, it will add the injection amount to the current balance at the start of the month. I've done this based on CloseTime as all other stats relate to CloseTime e.g. order.Size and order.P


Votes: +5

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please