Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 784

 
Leonid123456:

for this EA last)). Actually, it worked. It was the last one)). The Expert Advisor is for testing... So, work for several currencies and manual trading (together) is not envisaged yet...

Can you give me some tips for the future, it would be nice to know how to do it right...

Thanks again.

It is more correct not to write unnecessary things. Why did you put in nested loops? After all, everything you need can be done in one loop with one order selection.

if(New_Bar)
{
OrderSend(Symbol(),OP_BUYSTOP,Lotpers,Ask+step,100,0,0,NULL,MagicNumber,0,DarkTurquoise);
OrderSend(Symbol(),OP_SELLSTOP,Lotpers,Bid-step,100,0,0,NULL,MagicNumber,0,Yellow);
}

 for(int b=0; b<OrdersTotal(); b++)
  {
   if(OrderSelect(b, SELECT_BY_POS) && OrderSymbol() == _Symbol && OrderMagicNumber() == MagicNumber)
    {
     lastlot = OrderLots();
   // Здесь надо в переменную засунуть тикет выбранного ордера
     if(OrderType() == OP_BUYSTOP||OrderType() == OP_BUY)
      orderprisebuy = OrderOpenPrice();
   
      if(OrderType() == OP_SELLSTOP||OrderType() == OP_SELL)
       orderprisecell = OrderOpenPrice(); 
         
        SL_VirtualCell = orderprisecell+step1*Point;
        SL_VirtualBuy = orderprisebuy-step1*Point;

                          /*  if(Mas_Tip[0] >0|| Mas_Tip[1] >0)
                                               {
if (New_Bar&&/*valsar1<Ask &&  osma0>0&&osma1<0    /*&& Volume[1]>VolumeFiltr)

OrderSend(Symbol(),OP_BUY,NormalizeDouble( lastlot*Marti,2),Ask,100,0,0,NULL,MagicNumber,0,DarkTurquoise);

if (New_Bar&& /*valsar1>Bid && osma0<0&&osma1>0    /* && Volume[1]>VolumeFiltr)

OrderSend(Symbol(),OP_SELL,NormalizeDouble( lastlot*Marti,2),Bid,100,0,0,NULL,MagicNumber,0,Yellow);       
         
}*/

CheckEvents(MagicNumber); // Вот здесь теряется выбранный ордер при переборе ордеров в вызванной функции

/*if ( eventSellClosed_SL >0|| eventBuyClosed_SL >0)
{        as();
                

 }
  /* ///   if ( eventBuyClosed_TP > 0 )
   //     Alert( Symbol(), ": Buy-позиция закрыта по ТейкПрофиту!" );

   */
    if(eventBuyStopOpened > 0)
     {
      OrderSend(Symbol(),OP_SELLSTOP,NormalizeDouble( Lotpers,5),orderprisecell,0,0,0,NULL,MagicNumber,0,clrKhaki); 
 
      if (OrderType() == OP_SELL)
       OrderClose(OrderTicket(),OrderLots(), Ask, 3,clrIvory );  // Здесь может быть чужой OrderTicket() Возможны и другие аналогичные потери
     }//завершение блока if(eventBuyStopOpened > 0)
 ///

  if(eventSellStopOpened > 0)
  {
  OrderSend(Symbol(),OP_BUYSTOP,NormalizeDouble( Lotpers,5),orderprisebuy,0,0,0,NULL,MagicNumber,0,clrPlum);
 
   if (OrderType() == OP_BUY)
    OrderClose(OrderTicket(),OrderLots(), Bid, 3,clrIvory );  
  }//завершение блока if(eventSellStopOpened > 0)
 }//завершение блока if(OrderSelect(b
}//завершение блока for(int b=0


I did not manage to get into that place where you have multi-line comments. Something seemed to me that there might be a compilation error there... Pay attention to my comments in the code.

 
Zhunko:
What's the point?
thanks for your help!
 
AlexeyVik:

Don't write unnecessary things. Why did you put in nested loops? Because everything you need can be done in one loop with one order selection.


I have not managed to understand that place where you have multi-line comments. Something seemed to me that there might be a compilation error there... Pay attention to my comments in the code.

There are no errors, but there is a suggestion to check theOrderSend.OrderClose. andOrderDelete functions

return value of 'OrderSend' should be checked .

Thanks for your comments.

 

Looking for the minimum of the "ZigZag" indicator in the array using"ArrayMinimum".

Can I set the search to ignore null values or will I have to use a loop to find them?

 
I can't figure out how to code. I need the EA to wait for a certain amount of time if the last pose was unprofitable. Do you have any idea?
 
Forexman77:

Looking for the minimum of the "ZigZag" indicator in the array using"ArrayMinimum".

Can I set the search to ignore null values or will I have to use a loop to find them?

Most likely you will have to use a loop
 
Vinin:
Probably have to use a loop
Thank you!
 

How do we find the deepest correction between the maximum and the minimum? The maximum and minimum are known to us, it is not a problem to find them using iHighest and

If we use iHighest and iLowest, we will sometimes find near extrema as it is not always the case, as shown in the picture. Generally speaking, we need ABC formation identification.

I tried to apply ZigZag for that but it does not bring exact hits.

е.

 

Forexman77:

How do we find the deepest correction between the maximum and the minimum? The maximum and minimum are known to us, it is not a problem to find them using iHighest and

If we use iHighest and iLowest, we will sometimes find near extrema as it is not always the case, as shown in the picture. Generally speaking, we need ABC formation identification.

I tried to apply ZigZag for that but it does not bring exact hits.

All will be easy if to determine on what depth should seek. Instead of iLowest you can use CopyLow and ArrayMinimum()

 
001:
I can't figure out how to code. I need the EA to wait for a certain amount of time if the last pose was unprofitable. Do you have any idea?
Have a time of closing an unprofitable position OrderCloseTime(). From it, you can read the time via TimeCurrent() - OrderCloseTime(). Or in bars using iBarShift (NULL, 0, OrderCloseTime()).
Reason: