The function MySelect () should be placed outside of any other function.
I have made some adjustments to your code, but am not claiming that it will do what you want. I'm not totally sure what you want it to do.
Note that as you give the variable ePool=MODE_TRADES, it will always != MODE_HISTORY
int start() { //---- double pips2dbl, pips2points, Digits.pips; if(Digits % 2 == 1) // DE30=1/JPY=3/EURUSD=5 forum.mql4.com/43064#515262 { pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } ////// bool validGap = true; // Assume ok. for(int iPos = OrdersTotal()-1; iPos >= 0 ; iPos-- ) { if( MySelect(iPos, SELECT_BY_POS) ) if( MathAbs( OrderClosePrice() - OrderOpenPrice() ) < 30*pips2dbl) validGap = false; } //---- return(0); } //+------------------------------------------------------------------+ // extern int magic.number bool MySelect(int iWhat, int eSelect, int ePool=MODE_TRADES) { if(!OrderSelect(iWhat, eSelect, ePool) ) return (false); if(OrderMagicNumber() != magic.number ) return (false); if(OrderSymbol() != Symbol() ) return (false); if(ePool != MODE_HISTORY ) return (true); return(OrderType() <= OP_SELL); // Avoid cr/bal forum.mql4.com/32363#325360 // https://forum.mql4.com/30708 // Never select canceled orders. }
The function MySelect () should be placed outside of any other function.
I have made some adjustments to your code, but am not claiming that it will do what you want. I'm not totally sure what you want it to do.
Note that as you give the variable ePool=MODE_TRADES, it will always != MODE_HISTORY
Hi GumRai, how do I get the value of magic.number or I just set it as
int magic.number;
Hi GumRai, how do I get the value of magic.number or I just set it as
int magic.number;
I assumed that as you included //extern int magic.number
in your code, then it is one of the input parameters

- 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 guys.. I need some help here.
Previously I ask a similar question and i got this reply below.. however when I try compile, there quite a lot of errors as the variables are not fully declare and I not sure if its work below.
Just to ask how do I create a code or function that do the following.
Example I got 1 trades of EUR/USD running
Trade 1 at 1.3030, 1.3065, 1.3090
If the EA want to create a new trade,it must make sure there is 30 pips gap difference on all running trades ( means the Highest & Lowest Price Trade must have 30 pips gap with the next open position )
so the acceptable trade will be anything > 1.3010 or < 1.3120 (30 pips from 1.3030[Minimum] and 30 pips from 1.3090[Max])
Thanks for helping..
Below is a code that someone post to me earlier on a few weeks ago but I trying integrate now and got some list of errors like
Error result..