Immediately "OP_BUY" EURUSD, when USDCHF order is opened by EA

To add comments, please log in or register
Chanon Chaichanachot
272
Chanon Chaichanachot  
   //=====Hedge EU when UC is opened by EA=======
   for(int pos1 = OrdersTotal()-1; pos1 >= 0 ; pos1--) 
   if (OrderSelect(pos1, SELECT_BY_POS, MODE_TRADES) && OrderSymbol()== "USDCHF")
   {
   if (OrderType()==OP_BUY || OrderType()==OP_SELL)
   ticket=OrderSend("EURUSD",OP_BUY,Lot,Ask,30,0,0,"",0,0,Green);  
   }
   //============================================

I'm trying to code a search for open USDCHF order, and immediately send market BUY of EURUSD, but can't get it to work.

I mostly cut and paste my code, beginner here.  guidance would be much appreciated.

Ubzen
5298
Ubzen  
getting:

I'm trying to code a search for open USDCHF order, and immediately send market BUY of EURUSD, but can't get it to work.

I mostly cut and paste my code, beginner here.  guidance would be much appreciated.

Don't cut and paste code. I recommend the Book.
William Roeder
18282
William Roeder  
  1. Since there are no slaves here, you have only three choices: Search for it, learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt and the nature of your problem.

  2. Your code does exactly what your title says, it opens a EU when it finds an open UC. No where does it check if it has already done that.
To add comments, please log in or register