Function SQ_StocksSizeByPrice

BUG MULTICHARTS sqx 129.297


Dear Mark Fric,


if I select "Size by Price" in the money management settings, there is a problem with the multicharts code. As you can see in the picture attached, the calculation is wrong. I believe that the problem is the SQ_StocksSizeByPrice function.


thank you very much,
Giuseppe Piloni

Attachments
image_2020_08_07T19_54_31_608Z.png
(114.08 KiB)
BUG MC.pla
(66.09 KiB)
BUG MC Strategy 0112301.sqx
(55.45 KiB)
Build BUG MC.cfx
(26.65 KiB)
  • Votes 0
  • Project StrategyQuant X
  • Type Bug
  • Status Refused
  • Priority Normal

History

b
#1

beppil

07.08.2020 23:38

Task created

TB
#2

Tomas Brynda

10.08.2020 11:50

Status changed from New to Waiting for information

Hi Giuseppe,

I believe this is not a bug, because order size for StocksSizeByPrice money management method is calculated from the actual balance which is InitialBalance + NetProfit.

In your screenshot I can see the balance being around 32k which +/- corresponds with the order size given the price on the chart.


Please confirm if it is OK so I can close this task.


Best regards,

Tomas

b
#3

beppil

12.08.2020 12:32

Attachment image-0.png added

Attachment image-1.png added

image-0.png
(79.38 KiB)
image-1.png
(79.38 KiB)
unfortunately it's not ok ... look at this





b
#4

beppil

12.08.2020 12:32

Attachment image-0.png added

image-0.png
(95.44 KiB)
unfortunately it's not ok ... look at this
b
#5

beppil

12.08.2020 12:41
this sounds better

inputs:
    OpenPrice( numericsimple ),
    UseAccountBalance( TrueFalseSimple ),   
    MaxSize( numericsimple ),
    InitialCapital( numericsimple );
vars:
      double Balance( 0 ),
      double TradeSize( 0 );

Balance = InitialCapital + NetProfit;
If UseAccountBalance then TradeSize = Balance / OpenPrice Else TradeSize = (InitialCapital - OpenPositionProfit) / OpenPrice;
   
TradeSize = IntPortion(TradeSize); //Round down to integer
         
If TradeSize <= 0 then TradeSize = 1;
If TradeSize > MaxSize then TradeSize = MaxSize;

SQ_StocksSizeByPrice = TradeSize;

TB
#6

Tomas Brynda

12.08.2020 12:45
The mmUseAccountBalanceParameter only sets if the current balance will be calculated as InitialBalance + NetProfit (if it's true) or InitialBalance + NetProfit + OpenPositionProfit (if it's false).


b
#7

beppil

12.08.2020 13:08

ok, how do I then if I have € 5000 of capital available for each trade to have the right number of lots?

es.
stock price 5000 lots 1
stock price 1000 lots 5

etc.

b
#8

beppil

12.08.2020 13:11

Attachment image-0.png added

image-0.png
(7.50 KiB)
this is the option provided by Multicharts
MF
#9

Mark Fric

12.08.2020 13:12
Giuseppe, I don't understand the need for this. 

If you want to use only money management compute from InitialBalance which is always fixed then you don't need to use Money Management at all, you can enter fixed position size.


The function of money management is to compute position size dynamically from the actual size of your account, which means from InitialBalance + NetProfit so far

b
#10

beppil

17.08.2020 16:37
No because if I would enter a fixed position size, ex. 20 contracts, it would buy always 20 contracts, even if the price of the stock would change. This is not would be correct: if the stock price grows, the number of contracts must decrease, and viceversa, it I want use always the same capital, es. 5000$.


In summary, SQX allows that I use or not use the account balance; if I export the code, Multicharts allows only that I use the account balance: it's impossibile that I don't use it. This is the bug. If you turn on or turn off the function, it is not important: the account balance is always on.


Thank you for your work.

Best regards, Giuseppe


Votes: 0

Drop files to upload

or

choose files

Max size: 5MB

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

...
Wait please