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

 
tatianati:
Now checking, the hai of the three bars before and after should be less than the hai of the bar found.

It could be like this:

bool Status_Successful = true;

for(int x=(High_i-3); x<=(High_i+3); x++) {
   if(x==High_i) {
      continue;
   }
   if(High[x]>=High[High_i]) {
      Status_Successful = false;
      break;
   }
}


if(Status_Successful==true) {
   ....
}
 
atztek:
Probably like this:



Thank you, it works.

But after increasing the number of bars, like this:

for(int x=(High_i-7); x<=(High_i+7); x++)

arises.

arrayout of range in 'ta_v1_05.mq4' (174,11)

line 174, this one:

   if(High[x]>=High[High_i])

please tell me how to fix it.

 
are you sure that x is a natural number or 0? if high_i = e.g. 6, then x = -1, and high[-1] is already a problem. maybe add a check in line 173 if (x < 0) continue;
 
tatianati

danik: are you sure that x is a natural number or 0? if high_i = e.g. 6, then x = -1 and high[-1] is already a problem. maybe add a check if (x < 0) continue to line 173;
For three bars such a "check" has been done:
      for(j=i+3;j<=i+m;j++)

For the other values you need to change them all over the place.
You could start with this, and then see if this solves the problem or if there is something else that needs to be fixed.
 
Hello, could you please advise me, there is a function to close orders, but the orders are not closed for some reason, I can't understand what's wrong
void CloseOrders(int otype)
    {
      int ClosePrice;
      
      if (otype == OP_BUY) ClosePrice=Bid;
      if (otype == OP_SELL) ClosePrice=Ask;
    
       
      int total = OrdersTotal();
      for(int i = total-1; i >= 0; i--)
      {    
         if (OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
         { 
           if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderType() == otype)
           OrderClose(OrderTicket(),OrderLots(),ClosePrice,Slippage,Yellow);
         }
      }
 
lufer:
Hello, could you please advise me, there is a function to close orders, but the orders are not closed for some reason, I can't figure out what's wrong

The price cannot be int!

int ClosePrice;
 
TarasBY:

The price cannot be int!

oh right!!! Thank you!!!
 
Help me to find a bug in the code, it seems to be drawing two lines based on ZeroLag MACD indicator data for EUR\USD and GBP\USD, but nothing happens. Here is the code
#property indicator_separate_window
#property indicator_buffers 2
#property  indicator_color1 Red
#property  indicator_color2 DarkBlue
#property  indicator_width1 1
#property  indicator_width2 1
//+------------------------------------------------------------------+

extern string ExtParam1="EURUSD";
extern string ExtParam2="GBPUSD";
extern int FastEMA=12;
extern int SlowEMA=24;
extern int SignalEMA=9;

//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexLabel(0,ExtParam1); 

SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexLabel(1,ExtParam2); 
//----
return(0);
}
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars --; 
int limit=Bars-IndicatorCounted();
int bar;
for(bar=0; bar<limit; bar++)
ExtMapBuffer1[bar]=iCustom(ExtParam1,Period(),"ZeroLag MACD",FastEMA,SlowEMA,SignalEMA,iBarShift(ExtParam1,0,Time[bar],false));
ExtMapBuffer2[bar]=iCustom(ExtParam2,Period(),"ZeroLag MACD",FastEMA,SlowEMA,SignalEMA,iBarShift(ExtParam2,0,Time[bar],false));
return(0);
}  
 
ASZmyrov:
Please, help me to find a bug in the code, it seems that ZeroLag MACD should draw two lines for EUR\USD and GBPUSD, but nothing happens. Here is the code

Rumor has it that IndicatorCounted() does not work, also indicator recalculation is more correct to count from past to present, and there are some more errors in the code.

P.S. ZeroLag MACD itself should also be "adjusted" for the new virtual machine.

Files:
 
tatianati:

Thank you, it works.

But after increasing the number of bars, like this:

arises.

array out of range in 'ta_v1_05.mq4' (174,11)

line 174, this one:

please tell me how to fix it.

Isn't that what you're looking for?

Files:
isf.mq4  6 kb
Reason: