# Calculate lotsize from money (USD)

MQL5 language supports OpenCL. Try it!
28
2015.03.16 23:49

Hi,

I need a simple function.

I know stop loss and fixed amount of money (let's say in USD).

I'd like to know, where SL should be placed.

Please, don't post some topics, libraries, big parts of code, that doesn't solve the exact problem...

Just something like

double LotsizeFromMoney(StopLoss, Money) {} //returns SL

I couldn't find it anywhere and I am looking for it for about 3 months, it really drives me mad.

20
2015.03.17 00:18
question:

Hi,

I need a simple function.

I know stop loss and fixed amount of money (let's say in USD).

I'd like to know, where SL should be placed.

Please, don't post some topics, libraries, big parts of code, that doesn't solve the exact problem...

Just something like

double LotsizeFromMoney(StopLoss, Money) {} //returns SL

I couldn't find it anywhere and I am looking for it for about 3 months, it really drives me mad.

Wtf are u talking about? You said the sl is known, which form is it stored? Be precise
14518
2015.03.17 01:28
 question: I'd like to know, where SL should be placed. You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support. Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD) Do NOT use TickValue by itself - DeltaPerlot You must normalize lots properly and check against min and max. You must also check FreeMargin to avoid stop out
28
2015.03.17 08:06

Sorry, I explained wrong.

I know SL and amount of money that I want to loose when SL is hit.

I want to calculate lotsize from that. Just one goddamn function.

WHRoeder - sadly that's not the exact solution of the problem

Example - I know my SL is 40 pips and I want to loose \$80 when SL is hit.  I need to calculate lotsize.

PLAESE DON'T POST ANY OTHER THINGS. TRY TO POST ONE, WORKING FUNCTION. THANKS

28
2015.03.17 12:45
14518
2015.03.17 12:48
 question: . TRY TO POST ONE, WORKING FUNCTION. Example - I know my SL is 40 pips and I want to loose \$80 when SL is hit.  I need to calculate lotsize. DON'T SHOUT AT USTRY to learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem. I gave you the formula, solve for lotsize and code it.
28
2015.03.17 12:55

Sorry, I didn't want to.

I just wanted to find the solution. I've already read those topics, but it has never worked for me.

Is that really that complicated?  I just can't figure out the solution...

28
2015.03.17 14:08

Ok, you posted this formula:

Account Balance * percent = RISK = (OrderOpenPrice - OrderStopLoss)*DIR * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)

So for Lotsize it should be:  Lotsize = Account Balance/(DIR*OrderOpenPrice*DeltaPerlot - DIR*OrderStopLoss*DeltaPerlot)

Is that correct? What is DIR?

Thanks

379
2015.03.17 14:09
question:

Sorry, I didn't want to.

I just wanted to find the solution. I've already read those topics, but it has never worked for me.

Is that really that complicated?  I just can't figure out the solution...

Stop being petulant and at least attempt to understand what others are trying to tell you.

The formula is: lotsize = risk amount / stoploss value (i.e., lotsize equals risk amount divided by stoploss value)

Be careful about calculating stoploss value...you must calculate stoploss value correctly.

This site is replete with discussions and examples of how to calculate lotsize (here is my lotsize code).  If you haven't been able to find anything for 3 months, you haven't been looking very hard.  I suggest you search again and try to understand some of discussions you uncover regarding lotsize calculation.

14518
2015.03.17 20:58
 question: What is DIR? +1 for a buy -1 for a sell
28
2015.03.17 20:58
Thirteen:

Stop being petulant and at least attempt to understand what others are trying to tell you.

The formula is: lotsize = risk amount / stoploss value (i.e., lotsize equals risk amount divided by stoploss value)

Be careful about calculating stoploss value...you must calculate stoploss value correctly.

This site is replete with discussions and examples of how to calculate lotsize (here is my lotsize code).  If you haven't been able to find anything for 3 months, you haven't been looking very hard.  I suggest you search again and try to understand some of discussions you uncover regarding lotsize calculation.

Thanks for your answer. If I am not wrong , the code in link you posted solves when you want to get lotsize from % of balance.

Those things can be found easily, that's not the problem.

My question is, how can I improve the formula and make it finally usable? Should I multiply stoploss with PointValue like you do? Would that be a solution?

EDIT: Actually isn't, I am wrong again.

12