MT5 - Problem in arithmetic operation to extract lot size

 

Good evening

MT5

When doing this calculation:

(Balance * 23%) Divide by 0.0015 resulting (lot size)

Example: (788 * 0.23) = 181.24 / 0.0015 = 120.827

the problem:

Lot size,

for example: 120826

It cannot be put this way
Required:

The result should be a valid lot number, for example: 120000 or 1.20  or 0,30 or 1,32 ..........

(I want the output of the process to be suitable for inserting a transaction)

Can you write a command that does this (MT5)?  


And I thank you all

 
Nedal Burdukani: (Balance * 23%) Divide by 0.0015 resulting (lot size)

Bogus.

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. 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 FreeMargin to avoid stop out

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.

 
وليام رويدر # :

وهمية.

المقيمين في الخارج. لا تعتمد على الهامش والرافعة المالية. عدم وجود SL يعني أن لديك مخاطرة لا نهائية . لا تخاطر أبدا بأكثر من نسبة صغيرة من أموال التداول الخاصة بك ، بالتأكيد أقل من 2٪ لكل صفقة ، 6٪ إجمالا.

  1. . على سبيل المثال ، تداول حالة الطقس في حالة ارتداد ، وقت الوقف.

  2. AccountBalance * بالمائة / 100 = RISK = OrderLots * (| OrderOpenPrice - OrderStopLoss | * DeltaPerLot + CommissionPerLot) (ملاحظة OOP-OSL تشمل السبريد ، و DeltaPerLot عادة ما يكون حوالي 10 دولار / PIP لكنه في أسعار الصرف للزوج مقابل. .)

  3. لا تستخدم TickValue من تلقاء نفسها - DeltaPerLot وتحقق من أن MODE_TICKVALUE يقوم بإرجاع قيمة بعملة الإيداع الخاصة بك، هو كمآ مذكور في الوثائق، أو ما إذا كان يقوم بإرجاع قيمة بالعملة الأساسية للأداة المالية . MODE_TICKVALUE غير موثوق به على الوسائل المالية من العملات الأجنبية مع الوسطاء - منتدى البرمجة MQL4 (20 17 ) هل يوجد شامل لقيمة تقيمة؟ - أزواج العملات - عام - منتدى البرمجة MQL5 (20 18 ) تم حساب قيمة اللوت بمعامل 100 - منتدى البرمجة MQL5 (20 19 )
              
              
              

  4. يجب تسوية اللوت بشكل صحيح والتحقق من دقيقة و ماكس .

  5. عليك أيضًا التحقق من التحرر من منطقة التوقف الحر

تبلغ قيمة معظم الأزواج حوالي 10 دولارات لكل PIP . خطر 5 دولارات مع (صغير جدًا) 5 PIP SL هو 5 دولارات / 10 دولارات / 5 دولارات أو 0.1 لوت كحد أقصى.

I thank you for the advice

But I gave this as an example

I certainly wouldn't take that much risk

Thank you again

 

Don't double post! You already had this thread open.
          General rules and best pratices of the Forum. - General - MQL5 programming forum (2017)