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

 
   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderMagicNumber()!=MAGIC_3 || OrderSymbol()!=SMB_) continue;        //  здеся отсеиваются ордера не со своим магиком
      if(OrderMagicNumber()==MAGIC_3 && OrderSymbol()==SMB_)                     //  здеся отсеиваются ордера не со своим магиком
        {
         if(OrderType()==OP_SELL)
           {
            ticket=OrderTicket();OpenPrice=OrderOpenPrice();SL=OrderStopLoss();TP=OrderTakeProfit();comm_=OrderComment();
        //    if( comm_ != (DoubleToString(MAGIC_3,0)+" Uni OP_SeLL") || comm_ != (DoubleToString(MAGIC_3,0)+" UNI OP_SELLSTOP") ) return(0);
            RefreshRates();
            //+------------------TAKE НА SELL------------------------------------+ берёт несвой магик
            if(TP==0)//|| SL==0)   потому и здесь закомментировано || SL==0   поменял || на &&
              {
               TP    = OpenPrice - TakeProfit*Point;
               SL    = OpenPrice + 2*TakeProfit*Point;
               Color = clrViolet;
               Print(MAGIC_3," TAKE НА SELL ticket: ",ticket,", PR ",OpenPrice," SL: ",SL," TP: ",TP," Bid: ",Bid_);
               MODE_POS_b(ticket,OpenPrice,SL,TP,Color);
              }
            RefreshRates();
            //+------------------ОТКРЫТИЕ BUYSTOP--------------------------------+
            if(SchBuyStop_b(MAGIC_3,SMB_)==0 && SchSell_b(MAGIC_3,SMB_)==2)
              {
            if( SL==0 )return(0);
               OP_CMD_ = OP_BUYSTOP;
               Price   = NormalizeDouble(SL,Digits);
               SL      = 0;
               TP      = 0;
               lts     = SchSellLots_b(MAGIC_3,SMB_)*2;
               lts     = MathRound(lts/LotStep)*LotStep; // округление объема до ближайшего допустимого
               Color   = clrYellow;   //clrGreenYellow
               comm_   = DoubleToString(MAGIC_3,0)+" UNI OP_BUYSTOP";
               Print(MAGIC_3," OP_BUYSTOP:PR  ",Price," SL: ",SL," TP: ",TP," lts: ",lts," Ask: ",Ask_);
               res=bool_OP_b(SMB_,OP_CMD_,lts,Price,SL,TP,comm_,MAGIC_3,Color);
              }
            //+------------------ОТКРЫТИЕ SELLLIMIT------------------------------+
            if(SchSellLimit_b(MAGIC_3,SMB_)==0 && TP>0 && SchSell_b(MAGIC_3,SMB_)==1)
              {
               OP_CMD_ = OP_SELLLIMIT;
               Price   = TP + 2*Point*TakeProfit;
               Price   = NormalizeDouble(Price,Digits);
               TP      = TP + Point*TakeProfit;
               SL      = NormalizeDouble(SL,Digits);
               lts     = MathRound(SchSellLots_b(MAGIC_3,SMB_)/LotStep)*LotStep; // округление объема до ближайшего допустимого
               Color   = clrMediumSpringGreen;
               comm_   = DoubleToString(MAGIC_3,0)+" UNI OP_SELLLIMIT";
               Print(MAGIC_3," OP_SELLLIMIT:PR  ",Price," SL: ",SL," TP: ",TP," lts: ",lts," Ask: ",Ask_);
               res=bool_OP_b(SMB_,OP_CMD_,lts,Price,SL,TP,comm_,MAGIC_3,Color);Sleep(1000);
              }
           }
        }
      //   break;
     }
 
Alexander Boltunov:

Hi all! Could you please tell me how to set the condition of price crossing a horizontal line? And how to make this function with maximum accuracy (that would react on every tick)?

Thank you in advance))

I have added deletion of my line in OnDeinit
Files:
-LINE.mq4  6 kb
 
Artyom Trishkin:

What moose?

Can we not use jargon? It's not like we're at school at recess discussing who has the cooler "adics", "yo"...

Stoploss
 
ZZuretc:

if(OrderMagicNumber()!=MAGIC_3 || OrderSymbol()!=SMB_) continue; // here the orders that do not have a magic number are removed
if(OrderMagicNumber()==MAGIC_3 && OrderSymbol()==SMB_) // here the orders that do not have a magic number are removed

Screening twice seems to be excessive

 
STARIJ:

Screening twice seems excessive

but they don't get in, and the bypass is set to one, and the selimit is set to several
 
ZZuretc:
but it's not theirs that gets through, and the bypass is set to one and the selimit to several
Try running the debugger by pressing F5 in MetaEditor. There you can monitor the values of the variables
 
STARIJ:
Try running the debugger by pressing F5 in the MetaEditor. You can track variable values there

I've been debugging it for a month, can't debug it. Here's some smart advice from you, from seasoned experts

 
kaktyzzz:

Greetings, help decipher the deletion of objects, supposedly objects with names like Incl005_011 should be deleted, but they are not deleted ((

The piece of text you posted is a decompiled one. It is treated negatively here. Penalty = ban. Please remove it.
 
STARIJ:
the piece of text you posted is a decompilation. It is treated negatively here. Punishment = ban. Delete it.
How am I supposed to know if it's decompiled or not, I deleted it.
 
ZZuretc:
The horizontal line stands on a certain VALUE. Suppose if(Bid>=0.8765){return(0);}

Thank you!