Download MetaTrader 5

using _Point?

To add comments, please log in or register
sentinelx
44
sentinelx  

Hello,

I am coding a condition for buy like this:- bool Buy_Condition1 = (p_close > hand1[1])  && (p_close - hand1[1] > 20*_Point)

But upon backtesting, position gets opened with (p_close > hand1[1]) even if the second condition has not been true yet.

I want there to be a distance of atleast 20pips between my indicator handle value and bar close price. Can anyone point mistake in my code condition please? 

Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
Documentation on MQL5: Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants
  • www.mql5.com
Standard Constants, Enumerations and Structures / Indicator Constants / Price Constants - Documentation on MQL5
enbo lu
Moderator
1956
enbo lu  


try this: bool Buy_Condition1 = ( (p_close > hand1[1])  && (p_close - hand1[1] > 20*_Point) );

sentinelx
44
sentinelx  
luenbo:


try this: bool Buy_Condition1 = ( (p_close > hand1[1])  && (p_close - hand1[1] > 20*_Point) );

thanks for replying luenbo,

In my code i am using this exact bracket and semi colon placement as you have shown, the syntax in my code is all correct because i do not have any error or warning in compilation, i missed them posting in my message, sorry about that.

But the problem is that (p_close-hand1[1]>20*_Point) part is not showing in the working of this code. Any suggestion about it will be most welcome.

thanks again luenbo. 

kaloian kaloianov
445
kaloian kaloianov  

if you have not sloved your problem yet try to normalize p close values to 5 digits..check doubletostr funaction and normalize double.

Paul Anscombe
4288
Paul Anscombe  

Don't forget that a point is not necessarily the same size as a tick.

 

IE: for most 5 digit brokers  a pip is  0.0001 on eurusd and a point is 0.00001  so 20 pips would be  200 points

 

 

To add comments, please log in or register