Just a glimps of the main idea
bool DoNotTradeFlag = false; for(int k=OrdersHistoryTotal()-1;k>=0;k--) { if((OrderSelect(k,SELECT_BY_POS,MODE_HISTORY))&&(OrderSymbol()==Symbol())&&(OrderMagicNumber()==MagicNumber)) { if(MathAbs(OrderOpenPrice() - Bid) < XPips*Point) DoNotTradeFlag = true; } } if(!DoNotTradeFlag) Trade .....
Of course there is many more specific things in order to produce a stable code...
Thank you Cyberfx.
The "MathAbs" was what I needed and was not aware of.
WorstCases The "MathAbs" was what I needed and was not aware of.
In other words, you haven't been bothered to learn the Book, the Documentation, or the lessons.

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
Hello folks,
I have a simple script to open an order.
I'd like to add a safety which will prevent a new order to be placed, if another Order of the same type is within a certain distance.
Example in case of a Buy Order (I know this is not real code below, but this should explain what I'm looking for):
Can anybody help me out here, please?
Thank you.
WorstCases