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

 


It is of course better to switch to read/write array

1. Don't change the size of the array by 1 at every iteration, it's better to do it less frequently, for example increase it in increments of 50 or 100 if necessary

2. You'd better use DoubleToStr() for check printing.

3. I don't understand why a string variable is used for reading

 
Vinin:


It is better of course to switch to read/write array

1. Don't change the array size by 1 at each iteration, it's better to do it less frequently, e.g. increase it in increments of 50 or 100 if necessary

2. For check printing, it is better to use DoubleToStr()

3. I don't understand why a string variable is used for reading

1. it doesn't work otherwise. it writes null rows, like for 4 columns it must be updated every time

2. ok.

3. one special advised, now it reads everything correctly. but it turns out, one null row is redundant, and one extra run.but the value is not there, so it fills the null row accordingly.

 
orb:

1. it doesn't work otherwise. it writes null rows, like for 4 columns you have to update each time

2. ok.

3. a special advised one, now it reads everything correctly. but it turns out, one null row is extra, while one extra run.and the value is not there, respectively the null row is filled.


With such approach there will be big brakes.
 
Vinin:

With this approach there will be big brakes.

I see, so far it's easier for me to write this way.

Can you tell me how to get rid of "while" being executed one more time?

 
orb:

I see, so far it's easier for me to write this way.

how do I get rid of while being executed one more time?



I couldn't get rid of it. But I didn't use string variables
 
Got it. Can, then, ArrayResize(); be applied less than the loop counter, will it remove this string from the array?
 
orb:
Got it. Can, then, ArrayResize(); be applied less than the cycle count, will it remove this string from the array?

Yes, it will.

The less often you use this function, the faster it works. Reserve 100 elements and read by controlling the array overrun. If necessary, increase the array again by 100 elements. At the same time you keep the actual number of elements downloaded. After a complete download of the array, you make a new ArrayResize(), but by the actual number of downloaded elements.

But the functions for working with arrays work more correctly. You should first save the number of elements of the array into a file, and then the array itself

Read the number of elements first, set the size of the array. Download the array. And no loops

 
Vinin:

Yes, it will.

The less often you use this function, the faster it works. Reserve 100 elements and read by controlling the array overrun. If necessary, increase the array again by 100 elements. At the same time you keep the actual number of elements downloaded. After a complete download of the array, you make a new ArrayResize(), but by the actual number of downloaded elements.

But the functions for working with arrays work more correctly. You should first save the number of elements of the array into a file, and then the array itself

Read the number of elements first, set the size of the array. Download the array. And no loops

Thank you! I'll keep that in mind for the future.
 

Please advise how to solve the problem correctly:

There is a projection of Support/Resistance levels of the older TF to the current TF. It is necessary to determine which of the levels was the last to be tested by the price. I tried to do it through the flags:

int start()
{ 
      int limit;
      int counted_bars=IndicatorCounted();
      if(counted_bars>0) counted_bars--;

      limit=Bars-counted_bars;
      if(limit>barsToProcess)
         limit=barsToProcess;

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

{
 
  bool flag_R[], flag_S[], S[];

   double Level_Re = iCustom(NULL,0,"........",0,i); // для каждого бара получаем значения со старшего ТФ
   double Level_Su = iCustom(NULL,0,"........",1,i); // для каждого бара получаем значения со старшего ТФ

{
   if (iHigh(Symbol(),0,i)>=Level_Re)              // проверяем тестирование ценой уровня Re
   {flag_R[i]=true; flag_S[i]=false; S[i]=true;}   // выставляем флаги
   
   if (iLow(Symbol(),0,i)<=Level_Su)               // проверяем тестирование ценой уровня Su
   {flag_R[i]=false; flag_S[i]=true; S[i]=true;}   // выставляем флаги


   if (S[i]==false) {flag_R[i]=flag_R[i+1]; flag_S[i]=flag_S[i+1];} // если тестирования не было - берем предыдущее значение

   if (flag_R[0]==true) Print("Re zone tested"); if (flag_S[0]==true) Print("Su zone tested");
   
}
}

return(0);
}

but the log doesn't show anything.... [If I set, for example, Print(Level_Re), then running through the whole array, the log will stop at the value of the level for the last bar, i.e. levels themselves are calculated correctly, but with flags something does not work for me.... ]

What is the error? Or what is the best way to do it?

 
alkador:

to T-G

try it like this:

datetime expiration=TimeCurrent()+MaxSecLiveTime;

OrderSend(Symbol(), OP_BUYSTOP, Lots(), PriceBuy, 0, 0, 0, EA_Comment, Magic, expiration, CLR_NONE);


and what's the difference with:

extern int MaxSecLiveTime = 120;
OrderSend(Symbol(), OP_BUYSTOP, Lots(), PriceBuy, 0, 0, 0, EA_Comment, Magic, TimeCurrent()+MaxSecLiveTime, CLR_NONE);