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

 
forexnew:
I have never worked with DLL. Would you happen to have a ready code?


Although, there is nothing particularly difficult, just a simple substitution of one file for another.

In order to make a DLL you need to program in a language other than MQL4. Some people write in C/C++. I wrote it in Delphi. All in all, it depends on your own needs.

When the DLL is ready, it is connected to the Expert Advisor as well as another library of MQL4. After that you can call the functions described in the DLL.

 
drknn:


I haven't done this kind of function, although if you look at it, there's nothing particularly complicated there - just a dumb replacement of one file with another.

You can make links in the file system to read the logs from the script.
 

Dear, does Igor Kim have a function which returns the opening price of the last open position https://forum.mql4.com/ru/38949/page5#434239

If it's not difficult, please write a function that returns the opening price of the first open position. I thought it would be enough in the line

t<OrderOpenTime()
To replace "<" with ">" but the result will not work.
 

Hello.

Please advise how to implement this function if at all possible.

Order 1 and TP is set accordingly. A pending order 2 is placed at the same time with the order. How to delete the pending when the TP of order 1 has triggered.

 
strongest:

Hello.

Please advise how to implement this function if at all possible.

Order 1 and TP is set accordingly. A pending order 2 is placed at the same time with the order. How to delete the pending when the TP of order 1 has triggered.


By calling the OrderDelete() trading function
 
What needs to be changed to make the trailing stop work in five digits? Increasing pips by a factor of 10 does not help.
//+------------------------------------------------------------------+
//|                                                   e-Trailing.mq4 |
//|                                           Ким Игорь В. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 12.09.2005 Автоматический Trailing Stop всех открытых позиций    |
//|            Вешать только на один график                          |
//| 21.01.2006 Параметр AllPositions                                 |
//+------------------------------------------------------------------+
#property copyright "Ким Игорь В. aka KimIV"
#property link      "http://www.kimiv.ru"

//------- Внешние параметры ------------------------------------------
extern bool   AllPositions   = False; // Управлять всеми позициями
extern bool   ProfitTrailing = True;  // Тралить только профит
extern int    TrailingStop   = 15;    // Фиксированный размер трала
extern int    TrailingStep   = 2;     // Шаг трала
extern bool   UseSound       = True;  // Использовать звуковой сигнал
extern string NameFileSound  = "expert.wav";  // Наименование звукового файла

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (AllPositions || OrderSymbol()==Symbol()) {
        TrailingPositions();
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Сопровождение позиции простым тралом                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  double pBid, pAsk, pp;

  pp = MarketInfo(OrderSymbol(), MODE_POINT);
  if (OrderType()==OP_BUY) {
    pBid = MarketInfo(OrderSymbol(), MODE_BID);
    if (!ProfitTrailing || (pBid-OrderOpenPrice())>TrailingStop*pp) {
      if (OrderStopLoss()<pBid-(TrailingStop+TrailingStep-1)*pp) {
        ModifyStopLoss(pBid-TrailingStop*pp);
        return;
      }
    }
  }
  if (OrderType()==OP_SELL) {
    pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
    if (!ProfitTrailing || OrderOpenPrice()-pAsk>TrailingStop*pp) {
      if (OrderStopLoss()>pAsk+(TrailingStop+TrailingStep-1)*pp || OrderStopLoss()==0) {
        ModifyStopLoss(pAsk+TrailingStop*pp);
        return;
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Перенос уровня StopLoss                                          |
//| Параметры:                                                       |
//|   ldStopLoss - уровень StopLoss                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStopLoss) {
  bool fm;

  fm=OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+
 
david2:
What needs to be changed to make the trailing stop work in five digits? Increasing it 10 times does not help.

Most likely the problem is the non-normalised prices.
 
PapaYozh:

The problem is likely to be non-normalised prices.
Sorry, but in addition to the terminal button, you should have pressed the additional confirmation in the EA window to allow the EA to trade.
 
Sancho77:

Dear, does Igor Kim have a function which returns the opening price of the last open position https://forum.mql4.com/ru/38949/page5#434239

If it's not difficult, please write a function that returns the opening price of the first open position. I thought it would be enough in the line

Replace "<" with ">" but the result does not work.

And to clarify? To choose the first one out of the open ones (those that are in the market) or the ones that are already closed? And if the first position was opened three years ago? Is it to be selected?

What's all this for anyway?

 

Hello Comrades!

Can you please advise whether I can determine whether the previous order was closed at Take Profit or not? If yes, how should I implement it programmatically?

I would be grateful for a link if this question has already been discussed