I know there is someone who can help me. I have struggled with this for a year. My maximum lot size calculation is obviously wrong, but I can't figure it out. Please help. Thanks again. ---Tom
WHRoeder wrote "marginFree = AccountFreeMargin()*0.95, // Allow some slack" (https://forum.mql4.com/35056)
maybe this is what I need to do, allow some slack?
I thought about using a "While" loop to calculate the MAX LOT SIZE using AccountFreeMarginCheck(Symbol(),OP_BUY,Lots). However, my broker/journal says "FreeMarginCheck function cannot be called from a Custom Indicator".
Thanks for looking,
Tom
tparimore: "FreeMarginCheck function cannot be called from a Custom Indicator".
- You are taking a percent of free margin.
- 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/100 = RISK = OrderLots * (|OrderOpenPrice - OrderStopLoss| * DeltaPerlot + CommissionPerLot) (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
- Indicators can not trade so I'm not surprised the function can't be called.
- See also my GUI at Indicators: Money Manager Graphic Tool - MQL5.community traders' Forum - Page 5 It's a graphic EA, so you can put the SL where it needs to be. I will be adding the free margin checks to it soon, so book mark the link.
- Please use the link button (control-K)
See the difference: https://www.mql5.com/en/forum/128506
- Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it.
It's use is always wrong
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 forum
- Lot size must also be adjusted to a multiple of LotStep. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
Thank you WHRoeder.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I have written an indicator to calculate your lot size and maximum lot size based of percent of account you are risking and stoploss distance.
It works most of the time on most pairs. But, every so often I get an insufficient funds error even though I am using the calculated lot size based on risk and SL which is less than my calculated maximum lot size. Could someone please look at my code and tell me what is wrong?
Kind Regards,
Tom