Open Order, only if existing is x pips away
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...
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.
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):
If price of any existing BuyOrder is less than x pips above/below Bid { Alert("There is another position already too close"); }Can anybody help me out here, please?
Thank you.
WorstCases