Bet Size Calculator

Discussion in 'MetaTrader Indicators' started by Maverick, Jan 25, 2015.

  1. Maverick

    Maverick Master Trader

    323
    2
    59
    I am not suggesting there is anything wrong with your calculations when using your indicator with "Lots" and I realize you do not want to individually tailor the indicator for me personally BUT surely I cannot be the only trader who wants to use this on a Spreadbetting account.

    For whatever reason the Pos. size (0.15) does in no way relate to a Bet Size (£0.82) used in Spread Betting and for the life of me I cannot figure out how it arrived at 0.15.

    In this true example I have added the currency symbol and two decimal places for clarity but are not required in practice.

    Entry Lvl: ........ 0.98000
    Stop Loss: ....... 0.98500
    Take Profit: ...... 0.96500
    Acc. Balance: ... £4,000.00
    Risk: ............... 1.00%
    Risk money: ...... £40.00
    Reward: ........... £120.00
    Reward/Risk: ..... 3.0
    Pos. size: ......... 0.15

    Stop Loss minus Entry Lvl = 50 pips
    Entry Lvl minus Take Profit = 150 pips

    Risk Money/pips = 40.00/50 = £0.80 bet size
    Reward/pips = £120.00/150 = £0.80 bet size

    So if my SL is taken out when it goes back 50 pips then I will lose 50 * £0.80 = £40.00
    But if I reach my TP then I will win 150 * £0.80 = £120.00 @ 3 to 1 odds


    Unfortunately, changing text and colours in metaeditor is my absolute limit when it comes to editing MQL4. I tried and tried to get my head round 'Graphical Object Manipulation' when I wanted to change the layout but reluctantly gave up and put the indicator back in a corner collecting dust. Ever since I joined this forum and helped with the development I have wanted to use this indicator in my trading BUT to date haven't placed one single trade with it. WHY ? - because I don't trade with lots - I trade with £'s.

    Should I possibly start a new thread for "Bet Size Indicator" for all those Spreadbetters searching for it ?

    Attached is MY Bet Size version which I have looked and looked at trying to figure it out. Would have thought it would come under the heading "Calculates risk size and position size. Sets object values." - H'mmm - How many lines of code would it mean changing ?

    Please put me out of my misery.

    .
     

    Attached Files:

  2. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    I cannot explain anything about the 0.15 calculation result here because I don't know what currency pair was used in that example.

    As for the bet size calculator, I will gladly code it, but I need to know the exact rules it is working on. In your example, you are dividing risk money by pips to get the bet size. Does it depend on the quote currency of the currency pair you are trading with? It would also help if you could direct me to the demo platform of the spread betting broker you are trading with, so I could do the tests.
     
  3. Maverick

    Maverick Master Trader

    323
    2
    59
    Fortunately the demo account I took the figures from was as I left it on AUDCAD

    As far as I am aware the Currency Pair doesn't come into it - Every pair I have tested works out the same because Spreadbetters are not buying Lots but betting which way the market will go - any market.

    ETX is my broker http://www.etxcapital.co.uk/landing/spreadbetting/ and this landing page will also give you an insight into what spreadbetting is all about. But if all you want is the MT4 platform then go here https://cdn.monecor.com/Downloads/etxcapital4setup.exe

    I truly appreciate your help with this - Thank you :)

    PS Whilst you have got the hood up - Could you please change "Reward/Risk: ..... 3.0" to RewardOdds: ..... 3.0 /1 (without the dots)

    I could have changed the text but wasn't sure about adding /1

    .
     
    Last edited: Jan 26, 2015
  4. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    The MT4 demo seems to be the usual spot Forex demo. Do they have some separate platform for spread betting?
     
  5. Maverick

    Maverick Master Trader

    323
    2
    59
    H,mmm - The live account does offer more indices, currencies & commodities to trade, with them all having an SB suffix. As far as I know they still work the same - You are simply betting on the direction as opposed to buying or selling lots. The structure of the Live and Demo charts looks identical - at least to me !

    Basically, just betting how many pips it will move up or down (if only it was that easy) at so many £'s a pip.

    For what it's worth - PositionSizeCalculator_sepwind does work on both the Demo and Live charts except for the wrong BetSize.

    .
     
  6. Maverick

    Maverick Master Trader

    323
    2
    59
    Apologies - I am now told by a friend that the DEMO MT4 is NOT the same as the LIVE MT4. You can only spreadbet with a LIVE account - Sigh

    Beyond me as to why :confused:

    To be honest I have had little to do with the ETX Demo - I learnt with another broker.

    .
     
  7. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    Try the attached bet size calculator. It might show a bet size divided by 10 if your broker does not quote currency pairs in spread betting format.

    Please let me know if it works.
     

    Attached Files:

  8. Maverick

    Maverick Master Trader

    323
    2
    59
    See Attached Spread Sheet

    Order of events according to Maverick :cool:

    1) Enter/Adjust Variables = EL - SL - TP - Acc Bal - Risk %. Five inputs only - NOTHING ELSE

    2) Calculate Risk Money = Acc Balance * Risk Percent

    3) Calculate Bet Size = Risk Money * Pips Moved (EL - SL) or (SL - EL) BUY or SELL

    4) Calculate Reward Money = Bet Size / Pips Moved (TP - EL) or (EL - TP) BUY or SELL

    5) Calculate Reward/Risk = Reward Money / Risk money


    For whatever reason it sometimes gets stuck on the previous charts inputs. I seem to remember Position Size Calculator used to do the same - before Enivid fixed it :D

    The way I figure it - it's all about how many decimal places are used in the calculations.

    Can't figure out how your calculations know whether it's a BUY or SELL or if it's 5 or 3 decimal places (pips * 100 or pips * 1000 for pips moved).

    Should the Risk Money round UP or DOWN - it's UP at the moment - H'mmm

    For whatever reason the Horizontal Line Parameters are to 6 decimal places which can seriously effect the calculations. Obviously doesn't work in harmony with the chart instrument.

    Doesn't work on Indices OR Commodities only Currencies - Should work on any OHLC chart in Mavericks humble opinion ;)

    PS . . . I don't suppose it's possible to tweak the MT4/MT5 so that the Horizontal Line Decimal Place matches the Instruments Decimal Place ?

    .
     

    Attached Files:

    Last edited: Jan 30, 2015
  9. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    That's how it does it.

    That's probably because there are leftover lines from the previous instances. You either set DeleteLines to true when attaching it the next time or delete the lines manually.

    It cannot do that automatically. That's why I added DecimalMultiplier input parameter. Setting it to 10 should usually work, unless you are trading something exotic.

    Fixed.

    I cannot change how MT positions the lines, but the indicator rounds the value it reads from line to the decimal used by the current trading instrument. E.g. if you are trading USD/JPY and it's 123.456 and the lines is 123.456789, it will round it to 123.457.

    I have tried it on DXY and it worked.
     

    Attached Files:

  10. Maverick

    Maverick Master Trader

    323
    2
    59
    I think if we had the Bet Size to 3 decimal places it would at least take care of the JPY pairs.

    But, for whatever reason the 5 decimal places pairs aren't even close to my SS results.

    What if there was an option in the back office to choose between 3 and 5 decimal places - it already has to be installed alone on each individual chart and you have to open the back office to enter TP anyway.

    On each installation you have to Open Back Office and 1) Enter TP 2) Choose Window 3) Choose 3 or 5 decimal place . . . Easy Peasy.

    NOTE: spotted some bad maths in the xls . . . Hence updated version

    .
     

    Attached Files:

  11. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    Why would Bet Size on JPY pairs need 3 decimal places?

    You can control decimal places in the currency pair via DecimalMultiplier input parameter. It does not matter how many decimal places there are in the currency pair 3 or 100. It has nothing to do with the number of decimal places in the output Bet Size.

    If you think that something is calculated incorrectly, please provide examples because otherwise it is hard to fix anything.
     
  12. Maverick

    Maverick Master Trader

    323
    2
    59
    That is why I attached my spreadsheet with 12 examples - 3 BUY and 3 SELL @ 3 decimal places and 3 BUY and 3 SELL @ 5 decimal places

    Referring to my attached SS:

    AUDJPY BUY. . . Enivid = 0.14 . . . Maverick = 1.42
    AUDJPY SELL . . Enivid = 0.21 . . . Maverick = 2.14

    GBPJPY BUY . . . Enivid = 0.02 . . . Maverick = 0.18
    GBPJPY SELL . . Enivid = 0.02 . . . Maverick = 0.16

    EURHUF BUY . . . Enivid = 0.03 . . . Maverick = 0.31
    EURHUF SELL . . Enivid = 0.02 . . . Maverick = 0.16


    I can already hear you saying "Do pennies really matter" - All I am saying is if you had 3 decimal places then it would show the full amount - granted the decimal point would need moving one place to the right - but at least all the figures would be showing and not rounded up.

    Now the 5 decimal point pairs which I had to increase the Risk Percent to get any reading. But for whatever reason aren't even close - Hence my suggestion to select either 3 or 5 decimal places in the back office. Whilst doing so it might be an idea to have a 4 decimal place option to cover all eventualities.

    EURAUD BUY. . . Enivid = 0.04 . . . Maverick = 2.98
    EURAUD SELL . . Enivid = 0.03 . . . Maverick = 2.87

    EURMXN BUY . . . Enivid = 0.01 . . . Maverick = 0.69
    EURMXN SELL . . Enivid = 0.01 . . . Maverick = 1.24

    AUDCHF BUY . . . Enivid = 0.01 . . . Maverick = 1.19
    AUDCHF SELL . . Enivid = 0.01 . . . Maverick = 0.89

    I have checked, re-checked and checked my maths again - BUT still I can't improve on the above figures.

    I have absolutely NO IDEA what a "DecimalMultiplier" is in this context

    .
     

    Attached Files:

    Last edited: Jan 31, 2015
  13. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    It looks like you are not using the latest version attached in this post.

    As you can see in the attached screenshot, it gives the same 1.42 in your AUD/JPY example.

    If your broker's EUR/USD quote looks like 1.xxxxx and USD/JPY like 123.xxx, then DecimalMultiplier = 10 is OK. If your EUR/USD quotes are like 1.xxxx, then DecimalMultiplier should be 1. With currencies, it is easy - 5/3 digits, DecimalMultiplier = 10; 4/2 digits, DecimalMultiplier = 1. With exotic instruments, it can be more difficult. For example, if your spread betting platform treats cents as points in Gold trading, while MT4 platform quotes Gold as 1234.xxxx, you would need to set DecimalMultiplier = 100.
     

    Attached Files:

  14. Maverick

    Maverick Master Trader

    323
    2
    59
    I have added ALL of the above to the mq4 and assume it will always revert back to it's 5/3 default when added to a new chart.

    Have taken the liberty of adding a space to Entry Level, Stop Loss and Take Profit - Makes it look tidier (in my opinion). IN FACT to make it even tidier I have now changed Entry Level to Open Level - More balanced - Need a 4 letter word to replace Reward now - H'mmm

    My broker lists Gold XAUUSD to 3 decimal places. So I assume it treats it the same as JPY.

    Indices are all to 1 decimal place whilst commodities are either 2 or 3 with the exception of Cocoa which is 0

    With Spreadbetting all charts are equal . . . Just charts with different names

    How do you calculate the Reward Money - With my equation I needed the Bet Size to calculate - Yours remains constant regardless of Bet Size.

    Tried different DM settings on Cocoa - Probably easier if I don't bother with Cocoa.


    COCOA when DM = 1

    Reward Money = 18.18
    Reward Risk = 6.7
    Bet Size = 0.18

    18.18/6.7 = 0.18

    COCOA when DM = 10

    Reward Money = 18.18
    Reward Risk = 6.7
    Bet Size = 1.80

    18.18/6.7 = 2.71

    COCOA when DM = 100

    Reward Money = 18.18
    Reward Risk = 6.7
    Bet Size = 18.00

    18/6.7 = 2.69

    COCOA when DM = 1000

    Reward Money = 18.18
    Reward Risk = 6.7
    Bet Size = 180.03

    18.18/6.7 = 2.71
     

    Attached Files:

    Last edited: Jan 31, 2015
  15. Maverick

    Maverick Master Trader

    323
    2
    59
    If you increased the Risk Percent too much is there anyway of it showing Margin Call - Similar to it showing Invalid TP. But could be eased by reducing Stop Loss.

    Your probably going to say Margin varies from broker to broker BUT if it's in MT4 surely the indicator could find it

    Just an idea :)

    And there's more . . .

    What about adding the following to the INPUT page

    5/3 digits, DM = 10
    4/2 digits, DM = 1

    I'm thinking of when every Spreadbetter wants a copy and your sick of telling them to read the thread


    .
     
    Last edited: Jan 31, 2015
  16. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    "Gain"

    We know that we will lose exactly "Risk Money" with a given "Stop-Loss", that means that we can calculate "Reward Money" as "Risk Money" * ("Take-Profit" / "Stop-Loss"). It will remain constant regardless of Bet Size only if you change DM.

    That's what I would use in this case. Though I am not sure why you wrote that 18.18/6.7 = 0.18...
     
  17. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    I would gladly do it if I could find some MT4 with spread betting demo account to test it. Because it is not calculated the same way as in spot Forex from what I see in my IG demo.

    It is not that simple - I mean "5/3 digits" does not always imply "DM = 10", or "4/2 digits" means "DM = 1". It depends on what your broker calls a point in a particular trading instrument. If that was that simple, I would just make it detect it automatically.

    If I add that as a description of the input, it will confuse traders even more.
     
  18. Maverick

    Maverick Master Trader

    323
    2
    59
    The reason I like this version

    Going by the interest this indicator would appear to be generating I decided to post some Screen Shots.

    Good job I did . . . There is a problem with it installed in Window 0 . . . Window 1 is still opening

    The reason I like this version . . . Separate Window :)

    You can close it when not needed (Dormant) and can even slide the lines out of view.

    Enivid

    1) When Widow 1 first opens it is always too big at first. Is this adjustable ?

    2) When you engage one click trading it doesn't move out of the way - I have used other indicators that do move with the drop down. For the SS I had to increase Y to 80


    .
     

    Attached Files:

  19. Enivid

    Enivid Administrator Staff Member

    8,766
    310
    114
    I don't think it's possible. It looks like the height depends on the size of the current chart.

    Send me an example of such an indicator and I will see what can be done.
     
  20. Maverick

    Maverick Master Trader

    323
    2
    59
    There is a solution

    I followed this LINK and was able to open another LIVE account without depositing a single penny - it needs verifying to deposit monies. If you don't want to open a dummy LIVE account of your own for whatever reason - tell me how I can private message you my new log in details

    I was trying to show that Risk Money divided by Reward Risk = Bet Size

    Open zip - On reflection it might just be the name that moves - I will look for other alternatives - Tomorrow - Goodnight


    .
     

    Attached Files:

    Last edited: Feb 1, 2015

Share This Page