
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
Hi,
I guess I’m struggling with this bit - “Then you calculate the account value from it”. How?
Yes understood.
So if I want to put a stop loss n ticks or points away from an entry how would you go about calculating the price? Or more specifically if I have an entry at P1 and stop at P2 and wanted to a monetary risk of £100 say how would you calculate the lot size?
Aren't you mixing ticks and points in your first line? Fernando nicely pointed out that point and tick size can be different?
Aren't you mixing ticks and points in your first line? Fernando nicely pointed out that point and tick size can be different?
Yes, no....
Well, If you get these values from the symbols specifications, yes, Fernando's statement is reference here. - In this case I was refering to ticks and points as the same value, the smallest change in the least significant digit on the price.
- I use them synonymously here.... :-)
BTW, I loked up the formula for the volume in my code:
Long:
and Short:
And for reference here the formulas for the price:
Symbol Currency tick value:
Account currency tick value:
You could argue using ask, depending on the direction, and how you take spread into account, but for me, I stick to bid price and manage spread later.
These are all only code snippets, but should give enough details on how to go forward with oyur work. - Maybe you can put together a full function and post it here for others to "copy and paste".
EDIT:
As a sidenote, all calculations are always refering to one standard lot of the symbols contract definition.
Yes, no....
Well, If you get these values from the symbols specifications, yes, Fernando's statement is reference here. - In this case I was refering to ticks and points as the same value, the smallest change in the least significant digit on the price.
- I use them synonymously here.... :-)
BTW, I loked up the formula for the volume in my code:
Long:
and Short:
And for reference here the formulas for the price:
Symbol Currency tick value:
Account currency tick value:
You could argue using ask, depending on the direction, and how you take spread into account, but for me, I stick to bid price and manage spread later.
These are all only code snippets, but should give enough details on how to go forward with oyur work. - Maybe you can put together a full function and post it here for others to "copy and paste".
EDIT:
As a sidenote, all calculations are always refering to one standard lot of the symbols contract definition.
Thanks Dominik,
I will review and get back to you.
Cheers,
Ed
Yes, no....
Well, If you get these values from the symbols specifications, yes, Fernando's statement is reference here. - In this case I was refering to ticks and points as the same value, the smallest change in the least significant digit on the price.
- I use them synonymously here.... :-)
BTW, I loked up the formula for the volume in my code:
Long:
and Short:
And for reference here the formulas for the price:
Symbol Currency tick value:
Account currency tick value:
You could argue using ask, depending on the direction, and how you take spread into account, but for me, I stick to bid price and manage spread later.
These are all only code snippets, but should give enough details on how to go forward with oyur work. - Maybe you can put together a full function and post it here for others to "copy and paste".
EDIT:
As a sidenote, all calculations are always refering to one standard lot of the symbols contract definition.
Hi Dominik,
Thanks once again for posting the detailed post. I see that you are using the contract size and symbol digits in your tick value calculation which you get from the symbol specification. I can't see how your calculation would work for say the following instrument from AMP Global:
I did something similar in my code before and it was working fine with the instruments I was trading because they were FX where point size=tick size and were relatively straight forward but I can't see how your code would handle the above symbol correctly?
Many thanks,
Ed
Hi Dominik,
Thanks once again for posting the detailed post. I see that you are using the contract size and symbol digits in your tick value calculation which you get from the symbol specification. I can't see how your calculation would work for say the following instrument from AMP Global:
I did something similar in my code before and it was working fine with the instruments I was trading because they were FX where point size=tick size and were relatively straight forward but I can't see how your code would handle the above symbol correctly?
Many thanks,
Ed
That is correct, it does not work, this is because the specifications on this symbol are different.
As you can see, there is a different calculation mode specified for this symbol. - Originally you asked for CFD specs. But here the formula is different.
Here is my code for giving the correct results, although, I was not able to test all of the implementations. I marked untested in red.
For reference, I have taken the calculation formulas from the documentation:
https://www.mql5.com/en/docs/constants/environment_state/marketinfoconstants#enum_symbol_info_integer
EDIT:
As you will notice, on Futures* you need to rely on the value TICK_VALUE, since it is the only reference given for the unterlying asset, there is no other way inside of MQL to determine the value, except, of course, taking a test-position and calculation the resulting values from the resulting deals.
I guess aone approach could be to have a script that determines these values by testing them with a position, then entering them into the inputs of the EA, but in fact, I would assume, the values given on Futures* should be consistent with brokers, circumventing the aforementioned problem of unknown currency applied to the given TICK_VALUE.
Basically, it is important to understand the underlying contracts, and futures are different from CFDs or Forex. - IE try to calculate the correct margin with the given specifications by the broker "FXflat", you will see, I really had some difficulties understanding how it works, and to make it work across different brokers. But once you understand, its hard to not understand, and even harder to think of a different way of doing it.
Thanks Dominik,
Yes that is what I thought. I have to admit I seem to have bypassed the documentation (always a bad idea) and calculated using something that worked for FX. I will now get to work and base the calculations on the documentation. As you say where tick value is used in the calculation, like for exchange futures, hopefully it will be in account currency. I will check using the AMP global example I posted above.
It seems that for the calculation types that don't use tick value the brokers just output the value which could either be in account currency or profit. I'm hoping where it is required it comes out in account currency otherwise there is no standard and it's impossible to use.
Thanks for your help.
Cheers,
Ed