# Thinking of a way to algorithmically adjust lot sizes without a stop loss.

Thinking of a way to algorithmically adjust lot sizes without a stop loss. Is there a framework or calculation people normally use in this situation?

gouki1001: Thinking of a way to algorithmically adjust lot sizes without a stop loss. Is there a framework or calculation people normally use in this situation?

You can't change the volume (lots) of an open position.

You can however partially close out a position, incurring a loss or a profit depending on the current price.

You can also add to a position, but at the current prices only.

To calculate the net open price, net closing price, net stop-loss or net take-profit prices, or the net risk or net reward, you need to apply the following calculations ...

Any great idea about HEDGING positions welcome here

Fernando Carreiro, 2018.09.17 21:17

For those of you that want to learn to see the "light" and not fall into the trap of "hedging" and Grid strategies, here is the basic math:

:

Learn to do your research properly! Do not be blinded by false promises. Do the math!

calculate tp for a basket of positions

Fernando Carreiro, 2022.04.17 18:44

There is no exact MQL code to give you, because it varies depending on the strategy and what information needs to be calculated. That is why I gave you the math instead for you to implement depending on your requirements.

The math is self explanatory, but if you are having difficulty with it, then I doubt you will be able to implement it in code, but here are the variables anyway:

• vi = volume of individual position
• oi = open price of individual position
• ci = close price of individual position
• Vn = total volume for a basket of positions
• On = net mean open price for a basket of positions
• Cn = net mean close price for a basket of positions
• PLn = profit/loss for a basket of positions
The rest is in the math calculations.

Also, basing the volume on just the margin requirements (leverage) is a recipe for disaster. You ALWAYS have to consider the risk of the price changes of the open position and how that will reduce or increase your equity and free margin.

If you don't take that into consideration, you can quickly get a margin call or margin stop-out and blow your account totally and sometimes even be left with a negative balance which you may need to pay to the broker.

So be very careful how you approach your position volume sizing.

Fernando Carreiro #:

You can't change the volume (lots) of an open position.

You can however partially close out a position, incurring a loss or a profit depending on the current price.

You can also add to a position, but at the current prices only.

To calculate the net open price, net closing price, net stop-loss or net take-profit prices, or the net risk or net reward, you need to apply the following calculations ...

I would like to increase my lots or decrease my lots based on a percentage of my balance or make close to a target percentage using fixed lots going into a trade. I dont use stop loss btw.

gouki1001 adjust lot sizes without a stop loss

Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

1. 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.

2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around \$10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)

3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

4. You must normalize lots properly and check against min and max.

5. You must also check Free Margin to avoid stop out

6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

Most pairs are worth about \$10 per PIP. A \$5 risk with a (very small) 5 PIP SL is \$5/\$10/5 or 0.1 Lots maximum.

William Roeder #:

Risk depends on your initial stop loss, lot size, and the value of the symbol. It does not depend on margin and leverage. No SL means you have infinite risk (on leveraged symbols). Never risk more than a small percentage of your trading funds, certainly less than 2% per trade, 6% total.

1. 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.

2. AccountBalance * percent/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerLot + CommissionPerLot) (Note OOP-OSL includes the spread, and DeltaPerLot is usually around \$10/PIP, but it takes account of the exchange rates of the pair vs. your account currency.)

3. Do NOT use TickValue by itself - DeltaPerLot and verify that MODE_TICKVALUE is returning a value in your deposit currency, as promised by the documentation, or whether it is returning a value in the instrument's base currency.
MODE_TICKVALUE is not reliable on non-fx instruments with many brokers - MQL4 programming forum (2017)
Is there an universal solution for Tick value? - Currency Pairs - General - MQL5 programming forum (2018)
Lot value calculation off by a factor of 100 - MQL5 programming forum (2019)

4. You must normalize lots properly and check against min and max.

5. You must also check Free Margin to avoid stop out

6. For MT5, see 'Money Fixed Risk' - MQL5 Code Base (2017)

Most pairs are worth about \$10 per PIP. A \$5 risk with a (very small) 5 PIP SL is \$5/\$10/5 or 0.1 Lots maximum.

I know NO SL means infinte risk but how would someon who is not using stop loss target a specific gain (ROI per week or hour) without hard stop losses? Ny pointers or norms in the indstry would appreciated. Ultimately my worse case is to use AI.

gouki1001 #: I know NO SL means infinte risk but how would someon who is not using stop loss target a specific gain (ROI per week or hour) without hard stop losses? Ny pointers or norms in the indstry would appreciated. Ultimately my worse case is to use AI.

By calculating an average and maximum risks, based on the volatility of the symbol in question, for the duration of the position.

For example, if you plan to leave the position open for a day on EURUSD, and the average daily range of the symbol is 100 pips (1000 points), then your average risk will be \$1000 for a position of 1.0 lots.

However, that is only an average as the daily range my spike for example to 170 pips, making your daily risk \$1700.

And if you forget to close the position after a day and leave it for a week, you could easily reach a risk of \$3000.

In essence, you should first learn about all the trading essentials and all the maths that is involved with it, before considering these matters.

Fernando Carreiro #:

By calculating an average and maximum risks, based on the volatility of the symbol in question, for the duration of the position.

For example, if you plan to leave the position open for a day on EURUSD, and the average daily range of the symbol is 100 pips (1000 points), then your average risk will be \$1000 for a position of 1.0 lots.

However, that is only an average as the daily range my spike for example to 170 pips, making your daily risk \$1700.

And if you forget to close the position after a day and leave it for a week, you could easily reach a risk of \$3000.

In essence, you should first learn about all the trading essentials and all the maths that is involved with it, before considering these matters.

My kind friend thank your giving your input but i do understand the factors Im merely trying to the norm in trading without a stop loss. Alot of people do and Im just curious about the framework they use.

Fernando Carreiro #:

By calculating an average and maximum risks, based on the volatility of the symbol in question, for the duration of the position.

For example, if you plan to leave the position open for a day on EURUSD, and the average daily range of the symbol is 100 pips (1000 points), then your average risk will be \$1000 for a position of 1.0 lots.

However, that is only an average as the daily range my spike for example to 170 pips, making your daily risk \$1700.

And if you forget to close the position after a day and leave it for a week, you could easily reach a risk of \$3000.

In essence, you should first learn about all the trading essentials and all the maths that is involved with it, before considering these matters.

This idea here , or split your capital into # of trades to be taken , and based on that \$ do the above for a slightly higher timeframe volatility .

So take for example 10000\$ , divide it into 200 trades . you get 50\$

Let's say you are holding daily , you take the atr of the weekly chart and calculate the lot as if you had a stop loss for \$50 at that distance

Or even better , get a coder to code the max recorded unrelenting soul smashing cumulative spike to the opposite direction ever recorder on the timeframe that interests you

Now the wider the loss range the less the gain as well .

When you close anything above your previous equity you reset , otherwise you stick to the initial division.

gouki1001 #: My kind friend thank your giving your input but i do understand the factors Im merely trying to the norm in trading without a stop loss. Alot of people do and Im just curious about the framework they use.

I have just given you an example of the framework. The framework is knowledge and experience. You have to know and understand the market you are trading. That is the framework.

This knowledge and experience you gain over time, over several years (not days nor months).

Im hedging btw. So atm Im realising most people ue " change in pips per period " This looks interesting but I wonder if thats how most people are doing it without using hard stop losses .  I dont mind using Reinforcd leanring to adjust lots but I dont want to manually increase or decrese lots going into trades.
Reason: