Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 468

 
Trader7777:
tell me, is it possible to close an order knowing only its ticket? if so, how?

You can. OrderSelect with a known ticket, then the standard OrderClose command, enter the ticket as the first parameter.
 
Trader7777:
tell me, is it possible to close an order knowing only its ticket? if so, how?

select an order

      OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES);

close the order

   bool   fc;
   color  clClose;
   double ll,pa,pb,pp;
   int    err,it;
   string Autor=" Автор функции для шаблона : www.expforex.com";

   if(OrderType()==OP_BUY || OrderType()==OP_SELL)
     {
      for(it=1; it<=5; it++)
        {
         RefreshRates();
         pa=MarketInfo(OrderSymbol(), MODE_ASK);
         pb=MarketInfo(OrderSymbol(), MODE_BID);
         if(OrderType()==OP_BUY)
           {
            pp=pb;
              } else {
            pp=pa;
           }
         ll=OrderLots();
         fc=OrderClose(OrderTicket(), ll, pp, 1, clClose);
         if(fc)
           {
            break;
           } 
           
        }
     }
 
beginner:

Trying to get the values of the current candle as in the textbook

I get every tick

on the current candle values at the open price

how to get the real values

Close[0]!=rates[0].close????


void OnTick()
  {
//---
   MqlRates rates[];
   ArraySetAsSeries(rates,true);
   int copied=CopyRates(Symbol(),0,0,100,rates);
   if(copied>0)
     {
      Print("Скопировано баров: "+(string)copied);
      string format="open = %G, high = %G, low = %G, close = %G, volume = %d";
      string out;
      int size=fmin(copied,10);
      for(int i=0;i<size;i++)
        {
         out=(string)i+":"+TimeToString(rates[i].time);
         out=out+" "+StringFormat(format,
                                  rates[i].open,
                                  rates[i].high,
                                  rates[i].low,
                                  rates[i].close,
                                  rates[i].tick_volume);
         Print(out);
        }
     }
   else Print("Не удалось получить исторические данные по символу ",Symbol());
 
Vladon:

select an order

close the order


You are misleading people. What if it is already closed? Are we going to make mistakes? MODE_TRADES is ignored when it is selected by ticket, you don't need to enter it in the command at all. To know that the order selected by the ticket is still in the market, we should check its close time - compare it with zero, and close only when this time is equal to zero. There is no other way.
 

Folks. Could you please tell me. A robot that will not open orders...

That is, if the trader makes a mistake in the price direction. Then the robot will average. Spc.

If the code of this EA is not that big. If the code of this EA is not that big, then it can be sent directly to the post please.

 

Can anyone be aware of this:

after the update (2-3 days ago) there is a tonal sound when opening the terminal. (like before on TV if the channel is prophylactic)

Tried disabling all sounds, reinstalling - nothing helps. The old version (where I have not yet had time to make an update this does not exist)

On my nerves. How to cure who knows?

 
Zolotai:

Folks. Could you please tell me. A robot that will not open orders...

That is, if the trader makes a mistake in the price direction. Then the robot will average. Spc.

If the code of this EA is not that big. If the code of this EA is not that big, then it can be sent directly to the post please.


They will give you a hint. Just tell me how to average without opening orders first?
 
Unimaks:

Can anyone be aware of this:

after the update (2-3 days ago) there is a tonal sound when opening the terminal. (like before on TV if the channel is prophylactic)

Tried disabling all sounds, reinstalling - nothing helps. The old version (where I have not yet had time to make an update this does not exist)

On my nerves. How to cure who knows?



I have the same situation, so far only Mute saves the day.
 
Unimaks:

Can anyone be aware of this:

after the update (2-3 days ago) there is a tonal sound when opening the terminal. (like before on TV if the channel is prophylactic)

Tried disabling all sounds, reinstalling - nothing helps. The old version (where I have not yet had time to make an update this does not exist)

On my nerves. How to cure who knows?



What kind of sound is it? Listen to all sound files in the terminal folder, is it there at all (if so, rename or move it)? What operating system, what build of the terminal, what antivirus (maybe it's the one squealing)?
 
evillive:

They will tell you. Just tell me how to average without opening orders first?


My apologies. I wanted to say that the first order was opened by itself. It will not open. Only after the trader has opened it and the price has not moved in his direction.

That's when the robot comes in and tries to average.