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

 
TheXpert:

Compactness impairs readability. To be fair, Roman's version isn't exactly good either, even if you ignore the logic.

What's the point of saving lines?

To each his own... For me it's much more convenient to read the code when it's all in front of my eyes. I don't try to save lines: as it came out - so it came out...

It's all a matter of taste of every single individual and deciding what is more convenient and what is not is empty...

My main thing is to have every line in its usual place and no more... I think the rest of us should do the same, but at our own discretion.

There are no colour and taste, as you know.

 

but to design like this... A coder's nightmare.

         
             if (ticket>0)                                               // 
                    {
                             while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                                 {
                                   Sleep(100);
                                 }
                                  
      
                             OrderDelete(ticket,CLR_NONE); // и удаляете их                       
                     
                            
                    }

       
      return (0);
 
artmedia70:
Yeah... Alexey, I can imagine what the 807 line EA I just gave to a customer would look like if it was written in Roman's style ... :))))
Congratulations! If you look at my posted code in the context of my answer to the question, namely from my last post on this page, perhaps your idea of what an 807 line EA would have looked like would have changed. I have corrected my code from my EA, where a lot of things are located, in particular, in the missing lines in the loop, if statement and further in curly brackets when exiting the loop, the fact that the error handling for not deleting delayed is not done - this is also in the context of my question and my answer to it, IMHO - is normal.
 
sergeev:

but to design like this... A coder's nightmare.

For me - such a design is normal. This is not a custom EA, but the answer to the question, and instead of OrderDelete() - you could have written it in words - you put here to delete an order and call the function for handling possible errors. The person is waiting, I opened my code, removed all "unnecessary", without paying attention to the presence or absence of spaces after the changes and gave him a working version for his further connection to his EA according to his trading conditions. I think everything is within the norm, IMHO.
Here is the same plot - the original - to the question of a bad dream.

          ....
          orderProfit = OrderProfit() + OrderSwap();       // Profit
          Price = OrderOpenTime();                        // Цена открытия рыночного ордера
          SL =  OrderStopLoss();                           // Значение StopLoss ордера
          TP = OrderTakeProfit();                          // Значение TakeProfit ордера
          
             if (ticket>0)                                               // Если позиция открылась
                    {
                             while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                                 {
                                   Sleep(100);
                                 }
                                  double OpenPrice=OrderOpenPrice();                                   
                                  
                     //---------------------Запоминаем значения сл и тп ордера
                     // При количестве итераций выше 3-х увеличиваем уровень ТР для выхода в профит. 
                        if (orderType == OP_BUY) 
                           {
                            //if (Iteration == 4 ) TakeProfitPips = 400; if (Iteration >= 5 ) TakeProfitPips = 500;                
                            V_StopLossPips = NormalizeDouble(OpenPrice  - (StopLossPips * Point), Digits);
                            V_TakeProfitPips = NormalizeDouble(OpenPrice + (TakeProfitPips * Point), Digits);
                           }
            
                        if (orderType == OP_SELL) 
                           {
                            //if (Iteration == 4 ) TakeProfitPips = 400; if (Iteration >= 5 ) TakeProfitPips = 500;        
                            V_StopLossPips = NormalizeDouble(OpenPrice  + (StopLossPips * Point), Digits);
                            V_TakeProfitPips = NormalizeDouble(OpenPrice - (TakeProfitPips * Point), Digits);
                           }                               
                   }     
    
     // Проверка на предельную просадку
      
      double loss = - ((orderProfit * 100.0) / AccountBalance());
      if (loss > MaxLoss)
      {
         Print ("MaxLoss");
         CloseAllOrders(MagicNumber);
         IsExpertFailed = true;
         return (0);
      }
    
       // Проверка на необходимость закрытия открытой позиции (ордера) по стоп-лоссу      
     
      if ( V_StopLossPips != 0 )
        {
          if (orderType == OP_BUY && Bid <=  V_StopLossPips) 
             {
               CloseAllOrders(MagicNumber); Print ("V_StopLossPips закрываем по сл = ", V_StopLossPips);
             }
             
          if (OrderType()== OP_SELL && Ask >=  V_StopLossPips) 
             {
               CloseAllOrders(MagicNumber); Print ("V_StopLossPips закрываем по сл = ", V_StopLossPips);
             }  
        }          
        // Проверка на необходимость закрытия открытой позиции (ордера) по тейку
        
        if ( V_TakeProfitPips != 0 )
        {
          if (orderType == OP_BUY && Bid >=  V_TakeProfitPips) 
             {
               CloseAllOrders(MagicNumber); Print ("V_TakeProfitPips закрываем по ТР = ", V_TakeProfitPips);
             }
             
          if (OrderType()== OP_SELL && Ask <=  V_TakeProfitPips) 
             {
               CloseAllOrders(MagicNumber); Print ("V_TakeProfitPips закрываем по ТР = ", V_TakeProfitPips);
             }  
        }      
     
       
   //-----------------------------------ВЫВОДИМ ТЕКУЩУЮ ИНФОРМАЦИЮ О ТОРГАХ НА ЭКРАН------------------------------------------------------------ 
     
      string messageLoss = "";
      if (orderProfit < 0.0)
      {
         messageLoss = "Просадка = " + DoubleToStr(loss, 1) + "% (макс. " + MaxLoss + "%)";
      }
   
      // Вывод текущего состояния
      Comment("Прибыль = ", DoubleToStr(orderProfit, 1), " (лот ", orderLots, ")  ", messageLoss, " Iteration= ", Iteration, "  Sum_Loss + Delta= ", MathAbs (Sum_Loss) +  Delta_Sum_Loss * 10 * orderLots, " Ширина канала = ", StopLossPips, " Профит по рыночному ордеру =   ", orderProfit, "  k = ", k);
      return (0);
   }
   
   Comment ("");   
 
artmedia70:

There is no such thing as taste or colour.


We are all so different, but we are still together. ))) We're all in the same cosmic pot. )))
 
tol64:

We're all so different, but we're still together. ))) We're in the same cosmic pot. )))
Mine's already leaking broth... I'm gonna take a nap... Till morning.)
 

Since we're in the mood (I write code the way I want/can), I'm going to cut the last cucumber:

I write all "executive" and "legislative" bodies as separate (tried many times) functions.

Since the functions and their abilities are well known to me, I put them far away somewhere at the end of the code.

In the start() function I only prescribe what should trigger what.

I read only the start(), and everything becomes clear at once.

It's convenient.

 
DhP:

Since we're in the mood (I write code the way I want/can), I'm going to cut the last cucumber:

I write all "executive" and "legislative" bodies as separate (tried many times) functions.

Since the functions and their abilities are well known to me, I put them far away somewhere at the end of the code.

In the start() function I only prescribe what should trigger what.

I read only the start(), and everything becomes clear at once.

It's convenient.


Don't you get errors when compiling code, because you first write a function for execution, and then somewhere at the end you write its content, of course I don't use functions, I mostly use comments, but with variables this problem is present
 
LazarevDenis:

Isn't there an error when compiling code? You write the function to be executed first and then somewhere at the end write the content.


There cannot be any errors in this case.

When compiling, there may only be an indication/reminder that some function is not used.

In that case, I either turn a blind eye to it, or delete the unused function.

 
LazarevDenis:

Don't you get errors when compiling code, because you first write a function for execution, and then somewhere at the end you write its content, of course I don't use functions, I mostly use comments, but with variables this problem is present

What is it? ))) Is it a joke or what? If so, it's a good one)).
Reason: