Errors, bugs, questions - page 873

 
mario065:

Hello Reshetov,

For you it's "What the hell?", for me it's the condition when I have to make a call to the modification function.

If you looked at the code, you wouldn't have written it.

The code does:

  double Open = NormalizeDouble(PositionGetDouble(POSITION_PRICE_OPEN),4);
  double SL   = NormalizeDouble(PositionGetDouble(POSITION_SL),4);
  double TP   = NormalizeDouble(PositionGetDouble(POSITION_TP),4);

What good is it if it's there? For which position do you calculate this shit? Try using Print() or debugger to see what values of variables SL, TP and Open are there before if() and what values the open position has in the log.
 

Thank you Reshetov,

Done:

  double buy_trail = 0;
  double sel_trail = 0;
  double SL,TP,Open;
  if(PositionSelect(Symbol())){
    if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
      {
      Open = PositionGetDouble(POSITION_PRICE_OPEN);
      SL   = PositionGetDouble(POSITION_SL);
      TP   = PositionGetDouble(POSITION_TP);
      Bid  = SymbolInfoDouble(Symbol(),SYMBOL_BID);
      buy_trail = NormalizeDouble(Bid - Open,Digits());
      if(buy_trail > MStop)
       {
        if(NormalizeDouble((Bid - MStop),Digits()) >= Open && Open > SL)
          {
           ModifyPosition(Symbol(),Open,TP);
          }
          if(NormalizeDouble((Bid - MStop),Digits()) > SL && Open <= SL)
           {
            ModifyPosition(Symbol(),NormalizeDouble((SL + 0.001),Digits()),TP);
           }
        }
      }
    if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
      {
      Open = PositionGetDouble(POSITION_PRICE_OPEN);
      SL   = PositionGetDouble(POSITION_SL);
      TP   = PositionGetDouble(POSITION_TP);
      Ask  = SymbolInfoDouble(Symbol(),SYMBOL_ASK);
      sel_trail = NormalizeDouble(Open - Ask,Digits());
      if(sel_trail > MStop)
       { 
        if(NormalizeDouble((Ask + MStop),Digits()) <= Open && Open < SL)
          {
           ModifyPosition(Symbol(),Open,TP);
          }
          if(NormalizeDouble((Ask + MStop),Digits()) < SL && Open >= SL)
           {
            ModifyPosition(Symbol(),NormalizeDouble((SL - 0.001),Digits()),TP);
           }
        }
      }
     }

The modification function itself:

//+------------------------------------------------------------------+
//| Modify position.                                                 |
//+------------------------------------------------------------------+
bool ModifyPosition(const string symbol,double StopLoss,double Takeprofit){
//---- обявяване на структурата и резултата на търговското искане
   MqlTradeRequest request={0};
   MqlTradeResult result={0};
//---- структурна инициализация на  търговското искане MqlTradeRequest за модифициране на  позиция
   request.action       = TRADE_ACTION_SLTP;
   request.symbol       = symbol;
   request.sl           = StopLoss;
   request.tp           = Takeprofit;
   string word          = "";
   StringConcatenate(word,
                     "<<< ============ Modifyposition():   Модифицираме позицията  ",
                     symbol," ============ >>>");
   Print(word);
//---- модифицираме позицията и  проверяваме резултата от търговското искане
   if(!OrderSend(request,result) || result.deal==0)
     {
      Print("Modify error =", GetLastError());
      return(false);
     }
   return(true);
  }

Okay, now it's not finding positions.

Got rid of : ERR_TRADE_SEND_FAILED - 4756

Now it's 4753 - Position not found.

Sometimes it works, but there is such a bug that did not find the position.

 
mario065:

Thank you Reshetov,

Done:

The modification function itself:

Okay, now it's not finding positions.

Got rid of : ERR_TRADE_SEND_FAILED - 4756

Hour 4753- Item not found.

Sometimes it works, but there is such a bug that did not find the position.

You'd better use ready-made trade classes. See How to Use the Standard Library Trade Classes When Writing an EA

For example, modify positions for a symbol:

//--- Класс CTrade
#include <Trade\Trade.mqh>

//--- Объект класса CTrade
CTrade mytrade;



void OnTick() {
...
  if (myposition.Select(_Symbol))
  {
    int newStoploss = 250;
    int newTakeprofit = 500;
    double SL = mysymbol.Ask() – newStoploss*_Point;    
    double TP = mysymbol.Ask() + newTakeprofit*_Point;  
    // модифицируем открытую позицию по этому символу
    mytrade.PositionModify(_Symbol,SL,TP);
  }
...
}
It comes out very short and clear.
 

I got it.

Yedelkin helped. Here's the code.

Thanks :)

Files:
 

unblock my IP (I'm currently getting one on my home computer:

403 - запрещено. Доступ запрещен.
Предоставленные учетные данные не дают права на просмотр этого каталога или страницы.

).

I have also lost authorisation in the cloud and in the signal services, and by the way, one real account is using (used to, because now there is no authorisation) the signals.

Runs up to 10 terminals + browser. I have not downloaded site, did not break it, etc. - I didn't do anything contrary to forum rules.

 
notused:

unban my IP (I'm currently getting one on my home computer:

).

I have also lost authorisation in the cloud and in the signal services, and by the way, one real account is using (used to, because now there is no authorisation) the signals.

Runs up to 10 terminals + browser. I have not downloaded site, did not break it, etc. - I haven't done anything inconsistent with the rules of this forum.

Same problem, with about 14-00 Kiev, the moderator said that I'm not in the ban, then what is the reason?

 
notused:

unban my IP (I'm currently getting one on my home computer:

).

I have also lost authorisation in the cloud and in the signal services, and by the way, one real account is using (used to, because now there is no authorisation) the signals.

Runs up to 10 terminals + browser. I have not downloaded site, did not break it, etc. - I didn't do anything contrary to forum rules.

Strange? After all, if I'm banned, and even by IP, then I guess I can't talk on the forum either?
 
Reshetov:
Strange? After all, if in the ban, and even by IP, then it would be impossible to communicate on the forum, too?

The moderator said that not in the ban because I go under my nickname, and IP changed via auto hide ip, but it's only a mask, terminals still run under the native and the signals are not transmitted!

Admins respond!

 
remjte:

The moderator said that not in the ban because I go under my nickname, and IP changed via auto hide ip, but it's only a mask, terminals still run under the native and the signals are not transmitted!

Admins respond!

Better go to servicedesk. Although, probably can not, if you have a profile blocked?
 
Reshetov:Reshetov:
Better contact Service Desk

I'm logging in from a different IP. But the account is not banned - it is the IP that is banned. I wrote to the service-desk, I will wait for what they will say tomorrow.

Reason: