More than four years have passed since I have introduced my online position size calculator for EarnForex.com visitors. Since then it became very popular. A poll shows that about ¼ of this blog’s readers frequently use online Forex calculators, while Google Analytics shows that the current position size calculator form is the 4th most popular destination on EarnForex.com.
OK, enough with the introduction. Today, I would like to present the position size calculator for MetaTrader — an automated tool that can be added to any MT4 or MT5 chart and be used
Some features of this MetaTrader tool:
- Use either account balance or account equity to calculate position size.
- Change entry/
stop-loss points simply by dragging the lines on chart. - Does not consume much CPU resources.
- Automatic reference pair detection rate fetching (may be buggy, especially for
non-standard trading instruments). - Great potential for customization and enhancements.
You can download the code of the MT5 and MT4 versions or read more info about this handy calculator tool.
Updated: 2013-06-08: Added optional input parameter for
Updated: 2013-11-11: Added optional input parameter for the indicator to track entry level using current Ask/Bid rate (depending on
Updated: 2014-04-11: Reporting some new changes as per discussion in dedicated forum thread. I added more color and style customization options, reordered the output parameters and added potential profit (Reward) output in case
If you find any bugs in this MetaTrader indicator or if you have some feature suggestions, please post them using the commentary form below.
Hello Andrei
I have loaded this great little tool, thankyou for taking the time to build it.
I have one question, the referenece pair never changes from AUDUSD when I load the indicator on to other currency pairs. I have tried changing the label name, but to no avail.
Any help would very much appreciated
Regards
Steve
▼Reply
admin Reply:
April 9th, 2012 at 6:58 am
Are you sure it should be changing? Isn’t your account balance in Australian dollars?
▼Reply
I have installed the position size calculator, it works well, however is there any way of using it with a fixed capital risk amount rather than % of capital
▼Reply
admin Reply:
May 10th, 2012 at 6:25 am
Currently, there is no way for that but I might add this feature soon.
▼Reply
admin Reply:
May 10th, 2012 at 12:04 pm
I’ve just added the support for a fixed capital risk to this indicator. Please re-download and make sure it’s version 1.1 (if you are using MT5).
▼Reply
Mani Reply:
May 30th, 2013 at 7:44 am
Does this feature work in MT4 too?
▼Reply
admin Reply:
May 30th, 2013 at 7:46 am
Yes, the feature is working in MT4 too, it’s just that only MT5 supports version number display.
▼Reply
Hi, I get the following message when attempt to use the MT4 position size calculator:
“Failed to detect a proper currency pair for pip valuation.”
Any reason why? I’m using a spread betting account with GBP as the base currency.
Thanks in advance.
▼Reply
admin Reply:
May 20th, 2012 at 7:18 pm
And what pair are you trying to attach the indicator to?
▼Reply
hello, i have loaded the indicator to my mt4,i have a dollar account but your Mt4 position size indicator doesnt show the currency pair’s ask price that i am trading & it simply leaves a gap in between the Stop Loss Price and the Risk Percentage. Its supposed to show the ask Price pulled from the market watch window but i cannot seem to do this.Can you help
▼Reply
admin Reply:
June 18th, 2012 at 7:24 am
What currency pair are you attaching it to with your dollar account?
▼Reply
Frank Reply:
June 18th, 2012 at 9:18 am
am attaching it to the USDJPY currency pair,actually i was setting up a trade on the USDJPY. but it seems to show the same problem on all pairs! The ask price of the pair just doesnt appear on the chart. Can you tell me how to set this up properly?
▼Reply
admin Reply:
June 18th, 2012 at 10:52 am
How is USDJPY pair called in the Market Watch window of your MetaTrader?
▼Reply
it is called “USDJPYpro” in the Market Watch Window of my MT4 Trading Platform
▼Reply
admin Reply:
June 18th, 2012 at 6:01 pm
Please re-download and re-install the indicator. Then try again. I’ve tried to correct this bug.
▼Reply
hi, i had the same problem of frank, my pairs are named **.uni and the position size calculator didnt find them. now with the version (1) you have made it works perfectly. the only thing is that the pop up alert window is still popping up telling that an error occurred but the indicator works fine.
thanks a lot
▼Reply
sorry, its me again
the indicator worked fine with the pair eurgbp.uni but i tried with the eurjpy.uni and it doesnt work. i didnt try more pairs but i think something must be related to the price. the price of eurgbp is 0.8051 for example but the price of eurjpy is completely different 103.46 for example.
why is this happening? could you sort it out please?
thank you very much
▼Reply
admin Reply:
November 2nd, 2012 at 2:41 pm
I’ve tried to fix it and uploaded the new version of the indicator. Please download again and test it. Let me know if it works for you. By the way, it would really help if you could tell which version you are using – MT4 or MT5.
▼Reply
marketmaster Reply:
November 2nd, 2012 at 3:43 pm
hello admin,
i downloaded the indicator from the link you have above this page and it is still not working with the eurjpy.uni pair
im using the mt4 platform
thank you very much for your time.
▼Reply
admin Reply:
November 2nd, 2012 at 4:44 pm
What broker are you using?
▼Reply
marketmaster Reply:
November 2nd, 2012 at 4:54 pm
universal fx
▼Reply
i can give you an email if you want to contact them
▼Reply
admin Reply:
November 2nd, 2012 at 5:21 pm
No need to :-).
The indicator should be working now. Try downloading and compiling it again. Do not forget to add USDJPY.uni to your Market Watch window.
▼Reply
marketmaster Reply:
November 5th, 2012 at 11:42 am
sorry admin but the indicator still doesnt work with the eurjpy.uni
could you open a demo account with universal fx and try to make work the position size calculator with those pairs like eurjpy usdjpy etc?
thank you very much
▼Reply
admin Reply:
November 5th, 2012 at 4:35 pm
I did try that before uploading the current version. It is working as seen on the screenshot:

What happens when you try to do attach it to your EUR/JPY chart?
▼Reply
marketmaster Reply:
November 5th, 2012 at 5:15 pm
im trying to add a screen shot too but i dont know how.
basically the position size calculator is alway 0.00 for me meanwhile you have 0.08 on your screen shot and the pop up window comes up with two messages:
…. failed to detect a proper currency pair for pip valuation
…. Try adding all the available currency pairs to market watch
i dont know if im dowloading the indicator from an older link or im doing something wrong when setting it up
thanks you are being very kind
▼Reply
admin Reply:
November 5th, 2012 at 5:23 pm
Please make sure of the following:
1. You download it from here:
https://www.earnforex.com/mt4-forex-indicators/PositionSizeCalculator.mq4
2. Its size is exactly 10809 bytes.
3. If you are adding it to EURJPY.uni, you also need USDJPY.uni in the Market Watch window.
PS: Is your trading account in USD or some other currency?
▼Reply
marketmaster Reply:
November 5th, 2012 at 5:37 pm
finally it is working,
thanks a lot. my account is currently in euros but i tried with USD GBP and EUR.
It probably was that i was downloading the indicator from a non updated link.
thanks again, now i will tell my broker to convert my euros in GBP to try the indicator with a gbp account and i think i wont have any problems
admin Reply:
November 5th, 2012 at 5:46 pm
Good.
When you’ll have a GBP account, you’ll be needing GBPJPY.uni in Market Watch to be able to use the calculator on EURJPY.uni.
Does your MT 4 position sizing work for Gold and Silver as i always get 0.0. Thanks
▼Reply
admin Reply:
January 12th, 2013 at 6:54 am
That depends on how your Gold and Silver symbols are called in your broker.
▼Reply
Sorry to hash up an old post as I can see this was last touched almost 4 months ago but I have been using your calculator for quite some time and have just installed the indicator. It seems I am unable to change the reference price the calculator is using.
When I add the indicator to a chart (and pair) I only see the following fields:
Entry level
Stop loss
Risk
Account balance
Risk money
Position size
(There is no open space as described in a previous comment so it looks like it should be working)
However I have found that depending on what pair I am trading the position size it gives me can be wildly out from what I get if I use the online calculator which is telling me that it is not picking up the correct exchange rate for the pair I am on.
I am using a USD account but am trading multiple majors.
Any assistance you could give would be greatly appreciated as I am hoping to incorperate teh outputs from this indicator into my EA.
Regards
Ryan
▼Reply
admin Reply:
April 28th, 2013 at 8:14 am
It would really help if you could provide some examples of its calculations that you believe are incorrect. Please also let me know what platform you are using it in – MT4 or MT5?
▼Reply
ryan4all Reply:
April 28th, 2013 at 1:52 pm
I have just run some more tests manually and it looks like the issue is not with your indicator but rather with my EA that is not updating the chart properly so your indicator is still showing old lot size data.
I will confirm this when the market opens tomorrow but I think this is the issue.
Sorry about that and by the way this is an amazing indicator.
▼Reply
admin Reply:
April 28th, 2013 at 2:31 pm
No problem. Did you mean to say “MT4” in place of “EA”? If so, then the cause is that the markets are currently closed and even if you drag the lines on chart there is no tick event to recalculate the values.
▼Reply
This is the best tool for position management that I have found for MT4 but I do have a suggestion. Can the indicator show (as I move the SL and TP lines) the distance in pips from the entry point?
Thanks
▼Reply
admin Reply:
May 25th, 2013 at 1:34 pm
Thanks for suggestion! I will think about adding it.
▼Reply
Dear sir, I was wondering if it is possible to add a percent R calculation to your indicator. I was hoping you can so I can see what sort of return I have on trade and also as a reminder to not let my trade degenerate from ..for example a 3R to say back to a 1R or BE situation. I hope you understand what I am asking and really appreciate your time and consideration. Sincerely, Russ
▼Reply
admin Reply:
June 8th, 2013 at 10:09 am
I have just added reward/risk ratio calculation. I hope it does this for you. Please download the new version and set TakeProfitLevel input parameter to nonzero value to turn it on.
▼Reply
Great tool!
How do I set it to always show the take profit line?
Also, it would be great if the SL and TP in pips were shown too.
Congrats for the nice work!
▼Reply
admin Reply:
June 29th, 2013 at 6:33 pm
What do you mean by “set it to always show the take profit line”?
▼Reply
It would also be nice to see the SL without the spread and the Pip value
▼Reply
This looks like a great tool. However, when I move the entry or stop-loss lines it does not recalculate.
I downloaded it for Mt4, compiled it with no errors and then restarted mq4. I see the indicator on the top left and it seems to be pulling in the right pair info. I am only using some simple pairs such as EURUSD.
▼Reply
admin Reply:
August 6th, 2013 at 6:04 am
MT4 version will recalculate only on new price tick arrival even when you drag the levels. Also, the difference between old and new levels might not be sufficient to justify any change in the position size.
▼Reply
Would it be possible to add the following enhancement :
Stop Loss Calculator => Calculate Stop Loss (SL) as a percentage of the Entry Price and a specified price. For example, for a Short trade, user enters the High of the current candle and a percentage (e.g. 60%). Then the tool calculates the difference between the current candle’s High price and the current price, calculates 60 % of that value, subtracts the calculated value from the current price to get the SL. The position size is then calculated as per usual.
▼Reply
Andriy Moraru Reply:
January 26th, 2014 at 8:46 am
I aim to implement only those changes that will be useful to many if not all users of the calculator. There are millions ways to modify this tool according to each trader’s liking and preferences. Your proposed change is just one of them.
▼Reply
This indicator is exactly what I was looking for. The others I found are messy but this is clean and perfect. Just one thing, is it possible to convert this from an indicator to an EA? I’d like the lot size to automatically recalculate itself without having to hit refresh after you readjust the lines.
▼Reply
Andriy Moraru Reply:
February 20th, 2014 at 11:47 am
You don’t need to hit refresh for it to recalculate itself after readjusting the lines. It will recalculate immediately in MT5 and it will recalculate on new tick in MT4.
▼Reply
I would be appreciate if anybody could give me a tip what’s wrong with my tool: I set the indicator to indicators(MQL/Data Folder), ex4 file; if I drag the indicator the first time on chart with desired entry/stop it is fine but setting new levels (new digits) it doesn’t change at all: I need to drag entry/stop lines to get new position size and this is the only way it works?
Mariusz
▼Reply
Andriy Moraru Reply:
March 19th, 2014 at 10:41 am
“but setting new levels (new digits) it doesn’t change at all” – How do you do that? How do you set new levels?
▼Reply
Hi I have same problem I done same as mariusz on first time use on GBPUSD was ok when i have tried on EU or others symbols I have same lines /blue ,yellow green /on same price levels as GBPUSD however I tried retype EU or others price levels i can send screen shot if you want . any help appreciate
▼Reply
the problem its on MT4 One Financial broker but i have tried mt4 oanda runs very well, that may be issue of brokers.
▼Reply
Problem solved I was using template /once i set chart with indicators/ and after that i was importing to new charts with same settings as first was. And it can not be done because you cant rewrite price levels properly /maybe some bug/.Now Im placing indicator position size calculator one by one to every single chart manually and working great. Thank you for sharing .
▼Reply
Andriy Moraru Reply:
March 24th, 2014 at 1:40 pm
Yes, you are right. Template also copies the line objects. When you apply it to a new chart, the lines are used by the indicator to set the levels. That’s why the price levels on EUR/USD were the same as on GBP/USD.
▼Reply
Hi Andriy,
Sorry to bother you. I’ve been using the position sizing indicator today, it’s fantastic. I appreciate this is off-topic for the comments section of this blog.
Is there a way to set the Target Profit to come in ‘near’ a High[0] or Low[0], at the moment it places the TP on the chart miles away in space.
Does the formula for the position size have a factor of safety in it for slippage or something similar? My calculations do not match the output of the indicator (for something as simple at 10 pips of 1% risk eur/usd).
Thank you for your effort and time,
Cheers
Andrew
▼Reply
Andriy Moraru Reply:
April 11th, 2014 at 2:00 pm
Take-Profit is set either to the rate where the TP line already exists on chart (probably, your case) or to the rate given in the input parameter.
TP has little to do with position size calculation, so I do not plan to leave it on as default.
▼Reply
Hi Andriy,
I just downloaded the ‘ PositionSizeCalculator.mq5 ‘ file from the link “read more” at the top of the current post.
Compiling it from the indicator file in the MQL5 repertory, I ended with the following error in the terminal description “EX5 write error”.
Could you please tell me how to correct the error?
Many thanks for any help you can provide, and for the great posts!
Cosmo
▼Reply
Andriy Moraru Reply:
August 31st, 2014 at 5:12 pm
Please make sure that you have copied it to the correct folder (use File->Open Data Folder in MetaTrader) and that your MetaEditor has the administrator rights to write to that folder.
▼Reply
Hi!
Is it possible to use this tool also for shorting, so that SL is higher than the current price? Now it always kind of a excpets that I’m opening a buy- trade…
▼Reply
Andriy Moraru Reply:
September 25th, 2014 at 2:09 pm
Of course, you can move stop-loss above the entry level and it will calculate position size for the sell order.
▼Reply