I dont know why I cant figure this out right now but if someone could help me straighten my code out i would appreciate it.
I am trying to calculate Lot size by the amount of pips inbetween my future SL which is the previous bar high and current bid/ask price.
Here is what I have and is giving me error 131
I am on a 5 digit broker and the value of RiskPercent is a externdouble set at 0.02
Thank you
Still trying to figure this out, Anyone able to help?
Thanks
The method you are using to calculate the amout of equity at risk will be incorrect on all but a few currency pairs.
The first issue, IMO, that you need to address with your risk-management routines is to understand how to correctly compute the value of a pip as a function of the price. This needs to be done and done properly before you can ever hope to leverage this data into a correct money management algorithm based on equity at risk (EaR, aka value at risk or VaR).
For example, 50pips is not 50pips on USDJPY if your account is USD denominated. The value of those 50pips depends on the USDJPY price itself. If USDJPY is 80.00 then the value of USDJPY going from 80.00 to 80.50 is very different from the value of the USDJPY going from 120.00 to 120.50.
To understand how a pip's value depends on the underlying financial asset's reference price (e.g. bid or ask) you need to understand that a currency pair is created by pairing a "base" currency with a "counter" (aka quote) currency, and it is important to understand how that relates to the account's denomination.
So a currency pair fits the generic description of base/counter or if the slash "/" is left out then it becomes the string basecounter.
In my example above, USDJPY, the currency USD is the base and the curreny Yen (JPY) is the counter. base/counter = USD/JPY = USDJPY
If you are talking about the Euro pairs then the Euro becomes the "base" and we have EURUSD. EUR = base, USD = counter. Now price per pip changes from the case of USDJPY.
And things get even more complicated when you deal with currency pairs for which the account's denomination is neither the base nor the counter. EURGBP for example when you have a USD-based account.
But complicated does not mean intractable. I have worked out all these relations and implemented them into MQL4, the codes are here in the forums, search for my recent posts and you will find them.
I have also uploaded code that does exactly what you aim to do "over-all" in your opening post to the thread, but in my opinion if you want your code to work and be fundamentally correct then you need to address the holes in your grasp of the fundamentals.
I will gladly assist you with this learning process here in this thread if you like. If you just want the easy route "peoples make my code works for me pleaze!" then I probably won't be the person to help you with that, I'll leave the pro-bono codework to others in the community.
The method you are using to calculate the amout of equity at risk will be incorrect on all but a few currency pairs.
The first issue, IMO, that you need to address with your risk-management routines is to understand how to correctly compute the value of a pip as a function of the price. This needs to be done and done properly before you can ever hope to leverage this data into a correct money management algorithm based on equity at risk (EaR, aka value at risk or VaR).
For example, 50pips is not 50pips on USDJPY if your account is USD denominated. The value of those 50pips depends on the USDJPY price itself. If USDJPY is 80.00 then the value of USDJPY going from 80.00 to 80.50 is very different from the value of the USDJPY going from 120.00 to 120.50.
To understand how a pip's value depends on the underlying financial asset's reference price (e.g. bid or ask) you need to understand that a currency pair is created by pairing a "base" currency with a "counter" (aka quote) currency, and it is important to understand how that relates to the account's denomination.
So a currency pair fits the generic description of base/counter or if the slash "/" is left out then it becomes the string basecounter.
In my example above, USDJPY, the currency USD is the base and the curreny Yen (JPY) is the counter. base/counter = USD/JPY = USDJPY
If you are talking about the Euro pairs then the Euro becomes the "base" and we have EURUSD. EUR = base, USD = counter. Now price per pip changes from the case of USDJPY.
And things get even more complicated when you deal with currency pairs for which the account's denomination is neither the base nor the counter. EURGBP for example when you have a USD-based account.
But complicated does not mean intractable. I have worked out all these relations and implemented them into MQL4, the codes are here in the forums, search for my recent posts and you will find them.
I have also uploaded code that does exactly what you aim to do "over-all" in your opening post to the thread, but in my opinion if you want your code to work and be fundamentally correct then you need to address the holes in your grasp of the fundamentals.
I will gladly assist you with this learning process here in this thread if you like. If you just want the easy route "peoples make my code works for me pleaze!" then I probably won't be the person to help you with that, I'll leave the pro-bono codework to others in the community.
Great I appreciate the help, I will look into your previous posts and see if I can figure it out on my own if I have questions I will come back and ask.
Thank you
Take a look at this post and the links therein: https://www.mql5.com/en/forum/128707
//< 7.7.2. and //< 7.7.3. in https://www.mql5.com/en/code/8700
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I dont know why I cant figure this out right now but if someone could help me straighten my code out i would appreciate it.
I am trying to calculate Lot size by the amount of pips inbetween my future SL which is the previous bar high and current bid/ask price.
Here is what I have and is giving me error 131
I am on a 5 digit broker and the value of RiskPercent is a externdouble set at 0.02
Thank you