Hello! My account currency is USD, symbol traded is e mini Dax , margin currency for the symbol is USD , Profit Currency is EUR… how about tickvalue ? In what currency would that be? How can I find out?

Daniel Cioca: Hello! My account currency is USD, symbol traded is e mini Dax , margin currency for the symbol is USD , Profit Currency is EUR… how about tickvalue ? In what currency would that be? How can I find out?

Technically, tick value should always be expressed in account currency, but a few brokers "break" that rule on some of their symbols. Most brokers however, do it correctly!

Fernando Carreiro #:

Technically, tick value should always be expressed in account currency, but a few brokers "break" that rule on some of their symbols. Most brokers however, do it correctly!

Thanks ! So how can I confirm?

Daniel Cioca #: Thanks ! So how can I confirm?

If you mean manually, then looking at the returned value and verifying that it is in fact based on the account currency.

If however, you mean purely by code, then that would be difficult to implement a generalised solution. So, instead you should use the function and not rely on the tick value.

Documentation on MQL5: Trade Functions / OrderCalcProfit
• www.mql5.com

Fernando Carreiro #:

If you mean manually, then looking at the returned value and verifying that it is in fact based on the account currency.

If however, you mean purely by code, then that would be difficult to implement a generalised solution. So, instead you should use the function and not rely on the tick value.

How can I use this function to calculate lot  size?

Daniel Cioca #: How can I use this function to calculate lot  size?

This site has something called "search" ... https://www.mql5.com/en/search#!keyword=OrderCalcProfit%20calculate%20volume&module=mql5_module_forum

1. Use the OrderCalcProfit to first obtain the correct volume based on your stop-loss size and percentage risk.
2. Adjust the volume, based on the contract specifications
3. Use the OrderCalcMargin to verify that the volume is within the margin limits and requirements, and if not, then either reduce the volume or abort the trade.
4. And finally, before placing the order, use OrderCheck to make sure everything is in valid.

Fernando Carreiro, 2022.08.23 17:41

You can! These are the steps I take. I supply the function with a lot size equal to the “Max Lot Size” allowed for the symbol in question, then calculate the ratio needed to achieve the fractional risk that I wish to apply, to get the correct volume for the order. I then align that with the “Lot Step” and finally check it against both the maximum and minimum allowed lots for the symbol.

The reason I use the “maximum” lots instead of just “1.0” lots as a reference value is because there is no guarantee that the value of 1.0 is within the minimum and maximum values allowed. Given that using 1.0, or the maximum, gives equivalent results anyway (by using the ratio method), I choose to use the “max lots” as the reference point which also offers the most precision for the calculation.

Something like this ...

```// This code will not compile. It is only a example reference

if( OrderCalcProfit( eOrderType, _Symbol, dbLotsMax, dbPriceOpen, dbPriceStopLoss, dbProfit ) )
{
dbOrderLots = fmin( fmax( round( dbRiskMax * dbLotsMax / ( -dbProfit * dbLotsStep ) )
* dbLotsStep, dbLotsMin ), dbLotsMax );

// the rest of the code ...
};```

Market Registration of EA Unable to Validate

Fernando Carreiro, 2022.08.30 14:20

For your screenshot with an Error 131 and it also has a link on "How to fix it". So follow up on it and fix your EA accordingly.

In regards to volume, you have to check the contract specification of the symbol and limit your volume to the minimum, maximum and step that is allowed for the symbol.

```// Variables for symbol volume conditions
double
dbLotsMinimum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MIN  ),
dbLotsMaximum = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_MAX  ),
dbLotsStep    = SymbolInfoDouble( _Symbol, SYMBOL_VOLUME_STEP );

// Adjust volume for allowable conditions
dbLots = fmin(  dbLotsMaximum,                           // Prevent too greater volume
fmax(  dbLotsMinimum,                           // Prevent too smaller volume
round( dbLots / dbLotsStep ) * dbLotsStep ) );  // Align to step value```

Complete formula for calculating forex pip value for XAUUSD with account funded in euros

Fernando Carreiro, 2022.08.29 15:43

One more thing that should be considered by the OP or those following this thread ...

After you determine your volume (lots) for your risk amount, you should then check that against the free margin, useing the OrderCalcMargin (MQL5) or order_calc_margin (Python), to verify that the amount of margin that will be required is available in your free margin.

In fact, make sure that the required margin plus the risk is not greater than your free margin and that it will not cause a margin call or stop out.

I personally set a margin % limit and reduce the lot size if required. For example, I set a maximum % margin of 5-10% and use the OrderCalcMargin to adjust the volume to reduce the volume should the margin be higher than my limit.

The reason I set it to 5-10% is because I have to account for multiple positions in the market if I am trading on multiple symbols at the same time. If I were to allow a maximum margin on my balance, then I would not have any free margin left to trade on other symbols.

Daniel Cioca:
Hello! My account currency is USD, symbol traded is e mini Dax , margin currency for the symbol is USD , Profit Currency is EUR… how about tickvalue ? In what currency would that be? How can I find out?
Hello! Based on the information provided, the tick value for e-mini Dax would be in EUR since that is the profit currency for the symbol. You can typically find this information on the trading platform or the website of the exchange where the instrument is traded. Alternatively, you can also contact your broker or the exchange's customer support to get more information on the tick value and other relevant trading parameters.

Bogdan Ion Puscasu #:
Hello! Based on the information provided, the tick value for e-mini Dax would be in EUR since that is the profit currency for the symbol. You can typically find this information on the trading platform or the website of the exchange where the instrument is traded. Alternatively, you can also contact your broker or the exchange's customer support to get more information on the tick value and other relevant trading parameters.
Thank you! The idea is to find it out in code

Fernando Carreiro #:

This site has something called "search" ... https://www.mql5.com/en/search#!keyword=OrderCalcProfit%20calculate%20volume&module=mql5_module_forum

1. Use the OrderCalcProfit to first obtain the correct volume based on your stop-loss size and percentage risk.
2. Adjust the volume, based on the contract specifications
3. Use the OrderCalcMargin to verify that the volume is within the margin limits and requirements, and if not, then either reduce the volume or abort the trade.
4. And finally, before placing the order, use OrderCheck to make sure everything is in valid.
Thank you! Looks good in MT5. how about MT4?! This function doesn’t exists in MT4

Daniel Cioca #: Thank you! Looks good in MT5. how about MT4?! This function doesn’t exists in MT4

If your question is about MQL4, why did you post in the general MQL5 section?

You know this already, so which is it—MQL5 or MQL4?

Let me know so I can move the thread. In future please post in the correct section.

Fernando Carreiro #:

If your question is about MQL4, why did you post in the general MQL5 section?

You know this already, so which is it—MQL5 or MQL4?

Let me know so I can move the thread. In future please post in the correct section.

I thought General is for general staff … anyway… your guidance is for MT5, so thanks for that. So if I need an answer for MT4 as well, should I bring it up there also?