[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 462

 
tol64:


Thank you. It's very clear. Anyone can understand if you explain it like that.))

One more question. I found a lot of similar versions of the question in the search, but my question will be a little different.))

Discrepancy in the graphs. In order to see a "reliable ???" result I have to constantly recalculate timeframes. That is, if I see that there are errors in the log, I go to quote archive and recalculate all timeframes. In the tester, for example, I run a test on control points. Everything is OK. Then I, for example, form bars. Everything is OK. But if we again perform a test using control points, I will again see discrepancy between charts in the journal. What is it? ))) Is there anything against this scourge?


IMHO, use only two models of testing - either "All ticks..." or "By opening prices..." (for this in the board you must organize control for formation of a new bar) - these are "reliable" cuts - and do not bother... :-))) "Control points" - not worth it.

Just download the minute history for the instrument you want and go ahead... :-)))

 
Roman.:


IMHO, use only two testing models - either "All ticks..." or "By opening prices..." (for this in the owl you need to organise control of new bar formation) - these are "reliable" cuts - and don't sweat it... :-))) "Control points" - not worth it.

Just download the minute history for the instrument you want and go ahead... :-)))


My link is broken...

In my approach, if you use "All ticks" you will have to wait forever.) I'm testing on a 10 year history. In the EA the conditions and trailing are built on the formed bars. But there are some conditions that should be checked on every tick. For example, if a stop loss has triggered and the money management system has changed the lot size, you should reset all pending orders in order to change the lot size. Or just delete the pending orders, if this is required by the conditions. Everything must be clear to be valid.)) That is why control points are quite enough for me in principle, as I was comparing some pieces of history with all ticks. One and the same.

So what is there to help sort out and eliminate these errors? Because the link is broken.))

 
tol64:


The link is broken...

In my approach, if you use "All ticks", you'll have to wait forever.) I'm testing on 10 year history. In the EA conditions and trailing are based on formed bars. But there are some conditions that should be checked on every tick. For example, if a stop loss has triggered and the money management system has changed the lot size, you should reset all pending orders in order to change the lot size. Or just delete the pending orders, if this is required by the conditions. Everything must be clear to be valid.)) That is why control points are quite enough for me in principle, as I was comparing some pieces of history with all ticks. One and the same.

So what is there to help sort out and eliminate these errors? Because the link is broken))


Re-downloaded

and here.

 

Good afternoon gentlemen.

Help me understand the code. I understand the logic, but I don't know how to describe it properly. I don't know how to describe it properly.

Here is a piece of the Expert Advisor.

total=OrdersTotal();
if(total<1)

{

while (d_mn_1>d_pl_1 && (d_mn_0-d_pl_0)>=2) //Пока это условие выполняется открывать только селл при таком условии (iRSI(NULL,0,rsi_period,PRICE_CLOSE,2)>0.7)&&(iRSI(NULL,0,rsi_period,PRICE_CLOSE,0)<0.7))
{

OrderSend(Symbol(), OP_SELL, lots, NormalizeDouble(Bid, Digits), 3, /*Ask+10*Point*/0, /*Bid-10*Point*/0, "ADX sell", magic, 0, CLR_NONE);
}

while (d_pl_1>d_mn_1 && (d_pl_0-d_mn_0)>=2) // Пока это условие выполняется открывать только Бай при таком условии (iRSI(NULL,0,rsi_period,PRICE_CLOSE,2)<0.3)&&(iRSI(NULL,0,rsi_period,PRICE_CLOSE,0)>0.3))
OrderSend(Symbol(), OP_BUY, lots, NormalizeDouble(Ask, Digits), 3, /*Bid-10*Point*/0, /*Ask+10*Point*/0, "ADX buy", magic, 0, CLR_NONE);

}
}
}
}

Please, advise me how to deal with it correctly. Regards Denis.

 
Roman.:


Re-posted

and here.


Thank you. These links, and more, don't say the most important thing I needed to know.

When quotes come into the terminal online, the timeframes need to be recalculated from time to time so that there is no misalignment.

In offline mode there are no such problems.) This is the first one.

Now the second.

for(pos = 0; pos < OrdersHistoryTotal(); pos++)
    {  OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY);
        ... работа с ордером ...  }

If I do so, the writing into the file goes without errors. That is, in the file everything looks as intended. If I do it the way you've confidently asserted:

for(pos = 0; pos < OrdersHistoryTotal()-1; pos++)
    {  OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY);
        ... работа с ордером ...  }

then the file is not written correctly. I can see that there are individual cases.))

 
Postponed.
smartemiy:

Good afternoon, dear ones.

I need your expert help !!!

How to specify in the Expert Advisor that it should stop trading if the drawdown of the balance is already 20%, and that this figure can be changed ?

I'm sorry, it may have been already explained on the forum, I may not have noticed it ...

I AM GRATEFUL IN ADVANCE!

Good luck trading !!!!!

 
granit77:
Postponed.


For example, like this...

extern int MaxLoss = 90;          // Максимально допустимая просадка в процентах от баланса

...     

static datetime prevtime = 0;       // по ценам открытия
bool IsExpertFailed = false;
bool IsExpertStopped = false;

      

//+------------------------------------------------------------------+
//| Старт робота                                                     |
//+------------------------------------------------------------------+

int init()
{
   if(Time[0] == prevtime)   return(0);  //ждем нового бара
   prevtime = Time[0];                   //если появился новый бар , включаемся 

   IsExpertStopped = false;
   if (!IsTradeAllowed())
   {
      Comment("Необходимо разрешить советнику торговать");
      IsExpertStopped = true;
      return (0);
   }
      
   if (!IsTesting())
   {
      if (IsExpertEnabled())
      {
         Comment("Советник запустится следующим тиком");
      }
      else 
      {
         Comment("Отжата кнопка \"Разрешить запуск советников\"");
      }
   }
 return (0);
}
  
//+------------------------------------------------------------------+
//| Завершение работы робота                                         |
//+------------------------------------------------------------------+

int deinit()
{
   return (0);
}
  
//+------------------------------------------------------------------+
//| Обработка сигнала                                                |
//+------------------------------------------------------------------+
  
int start()    // -----------------------СТАРТ ЭКСПЕРТА--------------- 
{
  
 
   if(Time[0] == prevtime)   return(0);  //ждем нового бара
   prevtime = Time[0];                   //если появился новый бар , включаемся 

   if (IsExpertStopped)
   {
      Comment("Не удалось инициализировать советник!");
      return (0);
   }
   
   if (IsExpertFailed)
   {
      Comment("Критическая ошибка! Советник остановлен.");
      return (0);
   }
   
         
   // ------------------------------------------------Ищем наш ордер---------------------------------

   int orderType;
   for (int orderIndex = (OrdersTotal() - 1); orderIndex >= 0; orderIndex--)
   {
      if (!OrderSelect(orderIndex, SELECT_BY_POS))
      {
         continue;
      }

      if ((OrderSymbol() != Symbol()) || (OrderMagicNumber() != MagicNumber))
      {
         continue;
      }

      orderType = OrderType();
      if ((orderType != OP_BUY) && (orderType != OP_SELL))
      {
         continue;
      }
          ticket = OrderTicket( );                         // Номер ордера
          orderLots = OrderLots();                         // Lots   
          orderProfit = OrderProfit() + OrderSwap();       // Profit
          Price = OrderOpenPrice();                        // Цена открытия рыночного ордера
          SL =  OrderStopLoss();                           // Значение StopLoss ордера
          TP = OrderTakeProfit();                          // Значение TakeProfit ордера
          
             if (ticket>0)                                               // Если позиция открылась
                    {
                             while(OrderSelect(ticket,SELECT_BY_TICKET)==false)       // Если ордер выбран
                                 {
                                   Sleep(100);
                                 }
                                  double OpenPrice=OrderOpenPrice();
      
                              
                                  
                           if (orderType == OP_BUY) 
                              {
      
                               }
            
                            if (orderType == OP_SELL) 
                                 {
       
                                 }   
                            
                    }

      // Проверка на предельную просадку
      
      double loss = - ((orderProfit * 100.0) / AccountBalance());
      if (loss > MaxLoss)
      {
         Print ("MaxLoss");
         CloseAllOrders(MagicNumber);
         IsExpertFailed = true;
         return (0);
      }
    
              
       
}
   
 
Please remind me how to set the delay. I think you can do it in milliseconds. I keep forgetting how to spell it.
 
And can anyone suggest a script that closes all positions quickly. I can't find it. I'd like to see the code.
 
FOReignEXchange:
And can anyone suggest a script that closes all positions quickly. I can't find it. I'd like to see the code.
A search will tell me fifty grand.
Reason: