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

 
artmedia70:

1. If there is a closed takeout position, ...

1.1 If its type is OP_BUY, ...

1.1.2 If there is an open position OP_SELL, ....

1.1.3 If the current bar time minus the open Sell position time is greater than or equal to the number of bars for a delay, ...

1.1.4 Close a Sell position

1.2 If its type is OP_SELL, ...

1.2.2 If there is an open position OP_BUY, ...

1.2.3 If the current bar time minus the Buy position open time is greater than or equal to the number of bars for a delay, ...

1.2.4. we close the Buy position

Thanks for the algorithm, it is much more complicated than I expected(

Could you please sketch the code in general, because it took me so long to write the previous one, but I couldn't find similar EAs....

I cannot find similar EAs, but I would be very grateful!

 
Before you try to go to the limit, it's better to try to assess whether you need the solution.
You can find a lot of similar functions here - Useful functions from KimIV. There's also a ready-made one for your task.
 

Hello.

Please help me to find an error. The code counts the sum of RangeX0_D1 values

The result is only the last (sixth) member of the sequence.

Thank you in advance.

  int k;
  double RangeX0_D1  = 0;  
  for (k=1;k<=6;k++) 
   {
    RangeX0_D1  = (iHigh(NULL,1440,k)-iLow(NULL,1440,k))/Point;
    if (RangeX0_D1>0)
    RangeX0_D1++;
   }
 
int k;
  double RangeX0_D1  = 0;  
  for (k=1;k<=6;k++) 
   {
    RangeX0_D1  += (iHigh(NULL,1440,k)-iLow(NULL,1440,k))/Point;
   }
 
FAQ:
Thank you for your help, accuracy and speed :)
 
nemo811:
Thanks for your help, accuracy and speed :)


To speed up calculations, it is better to do things a little differently

int k;
  double RangeX0_D1  = 0;  
  for (k=1;k<=6;k++) 
   {
    RangeX0_D1  += (iHigh(NULL,1440,k)-iLow(NULL,1440,k));
   }
   RangeX0_D1 /= Point;

Dividing takes a long time. It's better to do it once.

 
Good afternoon, could you please tell me why the quotes from June 10 to September 22 of this year cannot be uploaded? I have made two to three history uploads and all have the same gap in the data.
 
Good afternoon, some advice: The loop searches for values that satisfy certain conditions. The found values are written to an array. It is not known in advance how many values will be found. Therefore, the size of the array to be declared is unknown. From the point of view of time and resources, I'd rather not make two runs (so that I could count the number of found values in the first run, declare the array and write data into the array in the second one). Is there any way to get the required result in one run?
 
Elenn:
Good afternoon, some advice: The loop searches for values that satisfy certain conditions. The found values are written to an array. It is not known in advance how many values will be found. Therefore, the size of the array to be declared is unknown. From the point of view of time and resources, I'd rather not make two runs (so that I could count the number of found values in the first run, declare the array and write data into the array in the second one). Is there any way to get the required result in one run?

An "infinite" length array can be declared in the indicator. Declare it and then in the loop immediately write the values found in the array. The only question is how to transfer the necessary selection to the Expert Advisor/Script? There are some tools, but we need to assess the complexity. Maybe it would really be easier to do 2 runs - in the first one, we count the number of filtered values, then change the dimension of the array, and in the second one, we enter the values into the array?
 
Elenn:
Good afternoon, some advice: The loop searches for values that satisfy certain conditions. The found values are written to an array. It is not known in advance how many values will be found. Therefore, the size of the array to be declared is unknown. From the point of view of time and resources, I'd rather not make two runs (so that I could count the number of found values in the first run, declare the array and write data into the array in the second one). Is there any way to get the required result in one run?

Declare the array larger than the maximum required size.
Reason: