[ARCHIVE] Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 3. - page 564

 

I have already given you the code to remove the exp from the chart. Since there can only be one (per chart), calling this function with its own handle will cause the exp to delete itself

 
FAQ:


...to give a command to himself to be removed


Thanks, it works.

P.S..

#include <WinUser32.mqh>
 
It goes without saying. When working with imported functions, remember to connect exports from the relevant applications.
 
Help, why isn't it working?

Thank you.

//-----
  static bool First = true;
  static int PreOrdersTotal = 0;
  int NowOrdersTotal = CountTrades();
  if(First)
  {
    PreOrdersTotal = NowOrdersTotal;
    First = false;
    return(0);
  }
  if(UseSound == true && NowOrdersTotal < PreOrdersTotal) {PlaySound(CloseSound);}
  PreOrdersTotal = NowOrdersTotal;
//-----

 
FAQ:

Close your window, give yourself a command to delete...

PostMessageA(WindowHandle(Symbol(),Period()), WM_COMMAND, 33050, 0);

So, MQL4 does not provide a standard way to terminate the Expert Advisor. Only through a direct use of Win32 API.

Got it, thanks.

 
takeda:

So, MQL4 does not provide a standard way to terminate an Expert Advisor. Only by direct use of Win32 API.

I see, thank you.

Library. Lots of useful functions for MT4 management. Including removal of the Expert Advisor is there.
 
Zhunko:
Library. Lots of useful functions for MT4 management. Including removal of Expert Advisor is there.

Took a look (so far in a cursory manner). Wonderful library!

Thank you!

 

Good afternoon.

Order modification works partially, help me to figure out what the problem is.

Code and log attached. I have written in the log what works and what doesn't.....

void AllSellLockBuyModifi()
{
 double sell_sl = 0.0;
 double sell_tp = NormalizeDouble((AllAvP()-TakeProfit*Point),Digits);
 int spread = MarketInfo(Symbol(),MODE_SPREAD);
 double lock_buy_tp = NormalizeDouble((LastSellLockBuyAvP()+TakeProfit*Point),Digits);
 double last_sell_sl = NormalizeDouble((lock_buy_tp+spread*Point),Digits);
 double lock_buy_sl = NormalizeDouble((sell_tp-spread*Point),Digits);     
 Print("AllAvP = ",AllAvP()," sell_tp = ",sell_tp," lock_buy_tp = ",lock_buy_tp," last_sell_sl = ",last_sell_sl," lock_buy_sl = ",lock_buy_sl);
 for (int i = 0; i <= OrdersTotal(); i++)
    {
     OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
     if (OrderSymbol()!=Symbol())continue;
     if (OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber)
     if (OrderType()==OP_SELL)
       {Print("Find Sell Order");
        if (OrderOpenPrice()==!LastSellPrice()) sell_sl = 0;
        if (OrderOpenPrice()==LastSellPrice()) sell_sl = last_sell_sl;
        Print("Мод-ция ордера SELL № ",OrderTicket());
        OrderModify (OrderTicket(),OrderOpenPrice(),sell_sl,sell_tp,0,CLR_NONE);
        error=GetLastError();
        if (error != 0) Print("Мод-ция ордера SELL № ",OrderTicket()," ошибка № ",error);
       }         
         else 
             { Print("Find BUY Order");       
              if (OrderType()==OP_BUY)
                {
                 Print("Мод-ция ордера LOCK BUY");
                 OrderModify (OrderTicket(),OrderOpenPrice(),lock_buy_sl,lock_buy_tp,0,CLR_NONE);
                 error=GetLastError();
                 if (error != 0) Print("Мод-ция ордера LOCK BUY № ",OrderTicket()," ошибка № ",error);
                }
             }
    }
 return(0);
}
Files:
log.txt  4 kb
 
TEXX:

Good afternoon.

Order modification works partially, help me to figure out what the problem is.

Code and log attached. In the log I've written what works and what doesn't.....


For a start, correct these lines:

for (int i = 0; i <= OrdersTotal(); i++)
    {
     OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

on these:

for (int i = 0; i < OrdersTotal(); i++)
   if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
    {
 
PapaYozh:


For a start, correct these lines:

to these:


didn't help...