expert advisor - miscellaneous questions - page 41

 

Stupid things today I tried few times old version EA it closes all Open Orders.
Now I confused.

---

But anyway I use MarketInfo() instead of simple Bid, and Ask.

 

Usually i try all of it to discover what works best.

I have one script that closes all order when need be.

         for(int order=0; order<=OrdersTotal()-1; order++)
           {
            bool selected=OrderSelect(order,SELECT_BY_POS);
              {
               if(selected==1)
                 {
                  bool close=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,clrNONE);
                 }
              }
           }
But as you can see nothing gets checked so it for manual implementation where you can visually verify that the orders are closed or not.
 
whroeder1:
  1. In the presence of multiple orders (one EA multiple charts, multiple EA's, manual trading)
Max Enrik: RefreshRates() I do not understand where could I put it.
You ask the question, you get the answer, and you ignore it and ask again. No down, no RefreshRates.

 
whroeder1:
You ask the question, you get the answer, and you ignore it and ask again. No down, no RefreshRates.

Why I asked again. Sorry I did not understand below sentence. ( I can't translate it. )

  • You must RefreshRates after sleep and between multiple server calls if you want to use the Predefined Variables (Bid/Ask) or OrderClosePrice() instead.
 

@Marco

After I replaced, JPY does not shows correct price and does not open order.

 
Do you have the code snippet.
 
Marco vd Heijden:
Do you have the code snippet.

Here you go.

void buyorder()
 {
  Ticket = OrderSend( _Symbol, OP_BUY, lotsize, MarketInfo(OrderSymbol(),MODE_BID), slippage, sl, tp, "trade panel", magic, 0, clrRed );
  return;
 }
 
Ticket = OrderSend( _Symbol, OP_BUY, lotsize, MarketInfo(OrderSymbol(),MODE_BID), slippage, 
  1. You can not use any Trade Functions unless you have an order selected.
  2. Check your return codes What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
 

#1  Could I use  Bid  instead of MarketInfo?
#2  Could I write it like below?

void buyorder()
 {
  Ticket = OrderSend( _Symbol, OP_BUY, lotsize, Bid, slippage, sl, tp, "trade panel", magic, 0, clrRed );
   if( Ticket < 0 )
   {
      Print("OrderSend failed with error: ", GetLastError() );
      return;
   }
  return;
 }
 

Only for the chart symbol.

Ask, Bid, _Period,_Symbol,Symbol(),Period()

These are all related to the chart symbol.

Use MarketInfo when you are working with symbols other then the chart symbol.

Reason: