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
Had a quick look (haven't done any digging yet) , found the point reference that you're calculating.
Try "throwing it out" and putting stupid Point. Maybe that's the problem (point through MarketInfo may not always come out the way you want?).
It's always supposed to...
although you can try to normalise it too =)
and it's not always acceptable - expert may trade on several pairs, and the point may be different...
Suppose orderstoploss = 1.29211 (5 digits after the decimal point)
bid=1.29716 (also 5 digits )
TrailingStop = 50
point =0.001
then (bid - TrailingStop * point)=1.29216>1.29211
True, this requires that digits suddenly become 5
And also
can be painlessly replaced with
I think it is not necessary to check on absence of stop loss level when trailing.
Actually it is, I'm correcting myself. If we set a stop loss only when there is a profit, and if not we are willing to wait for a margin call.
I have not found anything else. On which pair did your trailing stop work incorrectly and was there any strong movement?
I am converting everything to integer values for comparison purposes. I store and use the given values wherever I can (in the array).
use the given values (in arrays, variables, etc.)
I.e. variables of the int type may take values from -2147483648 to 2147483647.
This dimensionality is quite suitable for crosses.
Correspondingly, 1.2999 and 1.3000 can be cast to 12999 and 13000, and then they can be safely compared,
without fear of any periodic screw-up.
I've sketched an example here :)
here
output:
shiftpoint EURUSD,H1: Real Double Value = 1.29999999
shiftpoint EURUSD,H1: Shift Point Value = 13000
shiftpoint EURUSD,H1: Restored Value = 1.3000
at
Alternatively.
Hi.
I bring everything to whole numbers for comparison
2dev:
You are right - this is a fundamental problem, it is dangerous to compare floating point numbers.
In important places, always bring numbers to a certain precision via Normalize().
Standardize on type double (8 bytes).
By the way, we force normalize all passed prices in trade queries to avoid errors.
You can send a request for a stop loss as 1.2932461, but it will be set as 1.2932.
Please check if this is the error in trying to re-set the stop at the same price?
3 people were watching =)) Renat came and just pointed his finger at the error =)))
I will check now, of course, but most likely this is the case... I haven't normalized "bid - TrailingStop * point", and this very construction is involved in order modification...
we are not attentive, gentlemen ;)
do you mean the Normalize() that Begun suggested?
do you mean the Normalize() that Begun suggested?
Sorry, I meant the standard NormalizeDouble.