Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1066

 
yiduwi:

Thank you.

Igor Makanu:...should only put the arrow where the condition is met...

However, it puts it on the second bar.


Check the indexing direction of the indicator buffer.

 
Artyom Trishkin:

Check the indexing direction of the indicator buffer.

What to check, this code should put the arrow on which bar?

 {
//---
   int limit=rates_total-prev_calculated;
   if(limit>1 || prev_calculated==0)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferUP,EMPTY_VALUE);
      ArrayInitialize(BufferDN,EMPTY_VALUE);
     }
   for(int i=limit; i>=0; i--)
     {
      if(fabs(high[i+1]-high[i])<=_Point*(double)Pips) BufferDN[i]=high[i]; else BufferDN[i]=EMPTY_VALUE;
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
yiduwi:

What should I check, this code should put the arrow on which bar?

BufferUP and BufferDN what is the indexing?

Документация по MQL5: Операции с массивами / ArraySetAsSeries
Документация по MQL5: Операции с массивами / ArraySetAsSeries
  • www.mql5.com
//| Custom indicator initialization function                         | //| Custom indicator iteration function                              |
 
Artyom Trishkin:

BufferUP and BufferDN what is the indexing?

Did it the other way around.

 for(int i=0;i<limit;i++) 

still puts it on the second bar.

 
yiduwi:

Did it the other way around.

Still puts it on the second bar.

All arrays must be in the same direction

 
Artyom Trishkin:

All arrays must be in the same direction

Well then the first option is correct, what's the problem?

 
yiduwi:

Well then the first option is correct, what's the problem?

The problem is that you can't see the full listing of the indicator

 
yiduwi:

This puts it like this on the first bar, but the arrow does not appear in real time, only after switching thef. What is wrong?

In OnInit() ArraySetAsSeries() for BufferUP and BufferDN, in OnCalculate() - ArraySetAsSeries() for high and low

if(limit>1)

{

}

No need for prev_calculated==0

 
Artyom Trishkin:

In OnInit() ArraySetAsSeries() for BufferUP and BufferDN, in OnCalculate() ArraySetAsSeries() for high and low

Thanks.

 

What's wrong with the code? Trying to catch the end of the test

void MyHistory()
  {
//--- select history for access
//HistorySelect(0,TimeCurrent());
   HistorySelect(0,TimeTradeServer());
//---
   int    orders=HistoryDealsTotal();  // total history deals
   int    losses=0;                    // number of losses orders without a break

   for(int i=orders-1;i>=0;i--)
     {
      ulong ticket=HistoryDealGetTicket(i);
      if(ticket==0)
        {
         Print("HistoryDealGetTicket failed, no trade history");
         break;
        }
      //--- check symbol
      if(HistoryDealGetString(ticket,DEAL_SYMBOL)==_Symbol)
         continue;
      //--- check profit
      string   deal_comment=HistoryDealGetString(ticket,DEAL_COMMENT);

      if(deal_comment=="end of test")
        {
         Print("!!!!!!!!!!!!!!!  END TEST !!!!!!!!!!!!!!!!");
         break;
        }
/*
         if(deal_comment!="end of test")
            {
            return;
            }
            */
     }
//---

   return;

  }
Reason: