-
Using Points means code breaks on 4 digit brokers, exotics (e.g. USDZAR
where spread is over 500 points,) and metals. Compute what a PIP is and use it,
not points.
How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum
Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum - Print out your values to the precision you want. Do NOT use NormalizeDouble, EVER. For ANY Reason. It's a kludge, don't use it. It's use is always wrong
- SL/TP (stops) need to be normalized to tick size (not Point.) (On 5Digit Broker Stops are only allowed to be placed on full pip values. How to find out in mql? - MQL4 and MetaTrader 4 - MQL4 programming forum) and abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial and that requires understanding floating point equality Can price != price ? - MQL4 and MetaTrader 4 - MQL4 programming forum
- Open price for pending orders need to be adjusted. On Currencies, Point == TickSize, so you will get the same answer, but it won't work on Metals. So do it right: Trailing Bar Entry EA - MQL4 and MetaTrader 4 - MQL4 programming forum or Bid/Ask: (No Need) to use NormalizeDouble in OrderSend - MQL4 and MetaTrader 4 - MQL4 programming forum
- Lot size must also be adjusted to a multiple of LotStep and check against min and max. If that is not a power of 1/10 then NormalizeDouble is wrong. Do it right.
- Using Points means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
How to manage JPY pairs with parameters? - MQL4 and MetaTrader 4 - MQL4 programming forum
Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum
Many thanks @whroeder1 for these links. That's a lot of really helpful information! :)
Could you please explain what Digits.pips is all about? I put that code in a class and the compiler says:
'.' - variable expected
Is the notation of "pips" being a property of "Digits" an EA thing only?
EDIT: Added into an EA and got the message:
'.' - semicolon expected WWaves.mq4 23 11
Hi All,
I wonder if someone can put me on the right track for something that should and probably is very straightforward. However, my maths is not good so, here it is.
I'm trying to take the close of two different bars and see whether the difference falls in or out of the scope of a "reversal" value.
Last bar close: 1.25148
Current bar close: 1.2515
Difference: 0.00002
Reversal value: 10 pips
Using the following code:
Without using NormalizeDouble, the value is: 2.000000000013102e-05
The broker I am using is a 5 digit broker.
I don't understand these long numbers with the scientific notation. I want to work out whether the difference between two close values is inside, equal to, or outside of the reversal pip value.
Can anyone very kindly give me an example of the kind of expression I would need to achieve this?
Thanks in advance.
Could you please add a printf() to check high/close values ? I'm not sure it's correctly handled since the difference isn't 2 in the example you gave :/
Pre-Build 600 code (February 3, 2014) Can't use periods in variable names. Just rname it (DigitsPips, or Digits_pips.)
Ah, thanks for confirming. I'd already done what you suggested but just wondered whether I was missing something! :)
It's not necessary to work with the instrument's "pip" step. I mostly use the tick-size as the MQL built-ins all use tick-size. eg. Tick Value. In any regards, since you like to use OOP I made a class library for easily rounding doubles to the correct values so you don't have to constantly call the functions associated with floating point rounding.
CDouble lastBarHighClose =_lastBarHigh.BarClose(); CDouble barClose = bar.BarClose(); CDouble result = lastBarHighClose-barClose; printf("Result = %s",DoubleToString(result.AsRoundedTick()));
or
double lastBarHighClose =_lastBarHigh.BarClose(); double barClose = bar.BarClose(); CDouble result(PRECISION_TICK_SIZE); result = lastBarHighClose-barClose; printf("Result = %s",result.ToString());
It's not necessary to work with the instrument's "pip" step. I mostly use the tick-size as the MQL built-ins all use tick-size. eg. Tick Value. In any regards, since you like to use OOP I made a class library for easily rounding doubles to the correct values so you don't have to constantly call the functions associated with floating point rounding.
or
Hey @nicholishen - the library looks fantastic! Thanks for pointing it out and it's now in my build :)
Cheers --G
It's not necessary to work with the instrument's "pip" step. I mostly use the tick-size as the MQL built-ins all use tick-size. eg. Tick Value. In any regards, since you like to use OOP I made a class library for easily rounding doubles to the correct values so you don't have to constantly call the functions associated with floating point rounding.
or
Hey @nicholishen - just a quick question. If as a result of using (CDouble) result.ToString(), I get a value of, say, 0.00025 - is there a method on CDouble that will convert that value into 2.5 (pips)?
Hey @nicholishen - just a quick question. If as a result of using (CDouble) result.ToString(), I get a value of, say, 0.00025 - is there a method on CDouble that will convert that value into 2.5 (pips)?
I thought about it and then decided that I didn't want to own that functionality if you know what I mean. You can easily make a subclass to handle that...
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All,
I wonder if someone can put me on the right track for something that should and probably is very straightforward. However, my maths is not good so, here it is.
I'm trying to take the close of two different bars and see whether the difference falls in or out of the scope of a "reversal" value.
Last bar close: 1.25148
Current bar close: 1.2515
Difference: 0.00002
Reversal value: 10 pips
Using the following code:
Without using NormalizeDouble, the value is: 2.000000000013102e-05
The broker I am using is a 5 digit broker.
I don't understand these long numbers with the scientific notation. I want to work out whether the difference between two close values is inside, equal to, or outside of the reversal pip value.
Can anyone very kindly give me an example of the kind of expression I would need to achieve this?
Thanks in advance.