Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1232

 
Can you tell me how to remove my own thread from the forum?
 
Сергей Таболин:
Can you tell me how to remove my own thread from the forum?

Nothing. What's the topic?

 
Artyom Trishkin:

Nothing. What's the topic?

https://www.mql5.com/ru/forum/348294

MQ5::Вопрос по свечному индикатору.
MQ5::Вопрос по свечному индикатору.
  • 2020.08.04
  • www.mql5.com
Привет всем! Пока меня окончательно и пожизненно не забанили, хочу успеть задать вопрос по индикатору...
 

Thank you ))))

 

Hi, I'm trying to make the function

//-------------------------------------------------------------------------------
//                      Функция модификации позиции,безуыток, трейлинг-стоп 
//-------------------------------------------------------------------------------+ 
                  
bool Modi_Traili(int select,int pool=MODE_TRADES,ulong magic=-1) 
{ 
//   double Profit_On =OrderProfit();                  // Профит открытой позиции             
   double Price_Open =0;                         // Цена открытой позиции
   string sym =Symbol(),er;
   int i,cnt=0, k=OrdersTotal(),op=-1,mn=-1;
   double Market_Pi=0, oop=0, point=0, pp=0;
   bool loop = false;
//----------------------------------
     if (sym=="") sym=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_TICKET, MODE_TRADES)) {
      if ((OrderSymbol()==sym || sym=="") && (op<0 || OrderType()==op)) {
        if (OrderType()==OP_BUY && (mn<0 || OrderMagicNumber()==mn)){             
          int  Ticket=OrderTicket(); 
            Price_Open = OrderOpenPrice();                                           
            Market_Pi=MarketInfo(OrderSymbol(), MODE_ASK);
            point=MarketInfo(OrderSymbol(), MODE_POINT);
            if (point==0) if (StringFind(sym, "JPY")<0) point=0.0001; else point=0.01;
            if (point==0) if (StringFind(sym, "XAU")<0) point=0.0001; else point=0.001;
             double Sorri=MathRound(MathAbs(Market_Pi-Price_Open)/point);   
              Print("Ticket==",Ticket,"Sorri = ",Sorri,"Price_Open = ",Price_Open,"mi = ",Market_Pi);
             if(Sorri >Deta && OrderProfit()>0)
            {
//            Print("Ticket==",Ticket,"Sorri = ",Sorri,"Price_Open = ",Price_Open,"mi = ",Market_Pi);
 //--------------------------------------------------------------------------------------------------
     while (!loop)                              // Цикл модификации  
     {     
     double TP = NormalizeDouble(Ask+TProfit*Point,Digits);  
     double SL=NormalizeDouble(Ask+(2+MarketInfo(OrderSymbol(), MODE_SPREAD)/point),Digits); 
           Alert ("М-  -  -я ",Ticket,". Ждём ответ..");
          bool Ans=OrderModify(Ticket,Price_Open,SL,TP,0);    //Модифи его!
//--------------------------------------------------------------------------------
   if (Ans==true)                      // Получилось :)
              {
               Alert ("Ордер ",Ticket,TP," модифицирован:)");
               break;                           // Из цикла модифи.
              }
            //--------------------------------------------------- 7 --------------------
            int Error=GetLastError();           // Не получилось :(
            switch(Error)                       // Преодолимые ошибки
              {
               case 0  : loop = true; break; 
      
       case 4  : er=("Торговый сервер занят");
       case 135: er=("Цена изменилась");
       case 137: er=("Брокер занят");
       case 138: er=("Новые цены");
       case 146: er=("Подсистема торговли занята. Пробуем ещё..");
        Message(er);
         Sleep(2);                         // Простое решение
        RefreshRates();                     // Обновим данные
          continue;
       case 136: er=("Нет цен");
       Message(er);
          while(RefreshRates()==false)        // До нового тика
           Sleep(5);                        // Задержка в цикле
           cnt++; 
           continue;
       
        default:er=StringFormat("Ошибка: %d",Error);             // Другие варианты
        Message(er);
        loop = true;                  // Выход из while
        break;                             // Выход из switch
          }
//--------------------------------------------------------------------------------          
        } // Окончание while
       }
      }   // Окончание if
    
        if (OrderType()==OP_SELL &&(mn<0 || OrderMagicNumber()==mn))
        {
            int Ticket=OrderTicket(); 
            Price_Open = OrderOpenPrice(); 
            Market_Pi=MarketInfo(OrderSymbol(), MODE_BID);
            point=MarketInfo(OrderSymbol(), MODE_POINT);
            if (point==0) if (StringFind(sym, "JPY")<0) point=0.0001; else point=0.01;
            if (point==0) if (StringFind(sym, "XAU")<0) point=0.0001; else point=0.001;
              double Sorri=MathRound(MathAbs(Price_Open-Market_Pi)/point);    //+MarketInfo(OrderSymbol(), MODE_SPREAD);
             if(Sorri >Deta && OrderProfit()>0)
            {
            Print("So = ",Sorri,"Price_Open = ",Price_Open,"Mi = ",Market_Pi);
            Comment(Ticket);
            while (!loop)                              // Цикл модификации  
     {     
     double TP = NormalizeDouble(Ask+TProfit*Point,Digits);  
     double SL=NormalizeDouble(Bid-(2+MarketInfo(OrderSymbol(), MODE_SPREAD)/point),Digits); 
           Alert ("Мод------я ",Ticket,". Ждём ответ..");
           bool Ans=OrderModify(Ticket,Price_Open,SL,TP,0);    //Модифи его!
//--------------------------------------------------------------------------------
   if (Ans==true)                      // Получилось :)
              {
               Alert ("Ордер ",Ticket,TP," модифицирован:)");
               break;                           // Из цикла модифи.
              }
            //--------------------------------------------------- 7 --------------------
             int Error=GetLastError();           // Не получилось :(
            switch(Error)                       // Преодолимые ошибки
              {
               case 0  : loop = true; break; 
      
       case 4  : er=("Торговый сервер занят");
       case 135: er=("Цена изменилась");
       case 137: er=("Брокер занят");
       case 138: er=("Новые цены");
       case 146: er=("Подсистема торговли занята. Пробуем ещё..");
        Message(er);
         Sleep(2);                         // Простое решение
        RefreshRates();                     // Обновим данные
          continue;
       case 136: er=("Нет цен");
       Message(er);
          while(RefreshRates()==false)        // До нового тика
           Sleep(5);                        // Задержка в цикле
           cnt++; 
           continue;
       
        default:er=StringFormat("Ошибка: %d",Error);             // Другие варианты
        Message(er);
        loop = true;                  // Выход из while
        break;                             // Выход из switc}
        }
                      
            }
          }//
       }
      }
      }
     } //--------------------------Выход из цикла for
  
  return(true);
}

Move stop to Breakeven if the current price has exceeded the open price by

Deta 

pips. I'm getting an error 4051. All the tankbuilding is in the file(if you need it).WMA indicator is used. Not mine, hopefully not broken.

Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Технические индикаторы требуют для своих расчетов указания значений цен и/или значений объемов, на которых они будут считаться. Существуют 7 предопределенных идентификаторов перечисления ENUM_APPLIED_PRICE, для указания нужной ценовой базы расчетов. Если технический индикатор для своих расчетов использует ценовые данные, тип которых задается...
Files:
v5mz03.mq4  52 kb
WMA.mq4  10 kb
 
Galim_V:

Hi, I'm trying to make the function

Move stop to Breakeven if the current price has exceeded the open price by

pips. I'm getting an error 4051. All the tankbuilding is in the file(if you need it).WMA indicator is used. Not mine, hopefully not broken.

Invalid function parameter. At a guess you don't have a check for minimum stop orders. Add it, it's a mandatory check for the marketplace.

......

double TP = NormalizeDouble(Ask+TProfit*Point,Digits);  
double SL=NormalizeDouble(Bid-(2+MarketInfo(OrderSymbol(), MODE_SPREAD)/point),Digits); 
TP=New_Stop(TP);
SL=New_Stop(SL);
......
double New_Stop(double Parametr) // Проверка стоп-прик.
  {
   double Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL);// Миним. дистанция
   if(Parametr<Min_Dist) // Если меньше допуст.
     {
      Parametr=Min_Dist;                        // Установим допуст.
      Alert("Увеличена дистанция стоп-приказа или цены открытия отложенных ордеров.");
     }
   return(Parametr);                            // Возврат значения
  }
 
Valeriy Yastremskiy:

Invalid function parameter. At a glance, you don't have a check for minimum stop orders. Add it, it's a mandatory check for the marketplace.

Thank you! I'll have a look.

 

how in an indicator working in M1 to get data from D1, if the indicator is based on formulas and there is no call of standard indicators such as =iMA(Symbol(),Period(),....

how do I calculate?

 
Good day to all. I have faced this situation on my Demo account (not on real account)). Several positions were closed by the Expert Advisor when it reached a certain level of cumulative profit, supposedly positive, while all positions were sitting in a good loss, the event occurred at 2-50 on the server (does not look like a transfer of positions). The Expert Advisor (made by me) calculates the total profit of all open positions and compares it with a predefined value, i.e. the picture of bars in the window is as if not involved, although it shows a slight movement in the direction that provides profit. The Expert Advisor works on a timer that was set to 100ms. I do not exclude the broker idea as the same Expert Advisor of another broker with the same settings but working with ticks of the price has easily lost profit. I had a reserve on my account, the Expert Advisor reported closing from the profit attainment block.Maybe someone has some ideas what could have gone wrong.
 
Evgeny Vlasov:
Good day all. I ran into such a situation on a demo account (not on the real one)). Several positions were closed by the Expert Advisor when it reached a certain amount of cumulative profit, supposedly positive, while all positions were sitting in a good loss, the event occurred at 2-50 on the server (does not look like a transfer of positions). The Expert Advisor (made by me) calculates the total profit of all open positions and compares it with a predefined value, i.e. the picture of bars in the window is as if not involved, although it shows a slight movement in the direction that provides profit. The Expert Advisor works on a timer that was set to 100ms. I do not exclude the broker idea as the same Expert Advisor of another broker with the same settings but working with ticks of the price has easily lost profit. I had a reserve on my account, the Expert Advisor reported closing from the profit attainment block.Maybe someone has some ideas what could have gone wrong.

That's for you in the telepath branch)))) It was here somewhere.)

And on the subject... I DON'T KNOW. No code, no market, no nothing... Definitely telepaths))))