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

 
hoz:
Nah. Tanks are not an option. If you really want to do something like that. It will calm down just the result.)

:-)
 

No way. All in all, it turns out to be a strange moment. I didn't have the lot normalised. Here we have the function of lot normalization:

//+-------------------------------------------------------------------------------------+
//| Проверка объема на корректность и округление                                        |
//+-------------------------------------------------------------------------------------+
double LotFloor(double value)
{
   return(MathFloor(MathMin(MathMax(value, g_minLot), g_maxLot)/g_lotStep)*g_lotStep);

I checked where there was a mistake, in the trading function itself where functions of order opening are called from. I have added this function in the lot parameter of the calling function that sends orders. The error did not disappear.

And the soon as I added the normalization function directly to the first cursing function, and this is the function that sets pending orders, the cursing stopped. What do you mean by that?

//+-------------------------------------------------------------------------------------+
//| Открытие отложенной короткой позиции                                                |
//+-------------------------------------------------------------------------------------+
bool OpenPendingSell(double lot, double price)
{
   int g_ticket = -1;
   double OOP = price - i_distanceFromLastPos * pt;
      
   if (OOP < Bid)
   {
       fCheck_ValidPendingOOP(Symbol(), OP_SELLSTOP, OOP);
       
       g_ticket = OrderSend(Symbol(), OP_SELLSTOP, LotFloor(lot), ND(OOP), 30, 0, 0, NULL, i_magic, 0, CLR_NONE);
   }
   if (g_ticket > 0)
   {
       return (true);
   }
   else
       pr ("OpenPendingSell(): Ордер послать не удалось " + GetLastError());
   
   return (false);
}

In the first case, I immediately send a checked lot, and in the second case, I check the lot size in the OrderSend() function itself. But what is the difference?

 
chief2000:
Here's the problem - there is a one-dimensional array, which size may vary.
How to loop through all possible combinations of array elements with each other?
The order of elements doesn't matter, i.e. 123==213==321.

Here is an example for an array with 4 elements:

Well, with each other, it doesn't seem difficult.

int k = ArraySize(array);
for(int i=0;i<k-1;i++)
for(int ii=i+1;ii<k;ii++)
   {
   ...
   }
But, here, when there are more than two, it's not clear how to compare. Show a method to compare three numbers 1, 2 and 3 at the same time,
 
Can anyone tell me how to make it so that I don't have to reopen the optimisation window..... Cas sted that this window was with different settings for background, candle, etc.
 
Maybe there are scripts like that!!!
 
Hi all! Please advise me on this subject... If I want to shift the level to 798, it is too complicated to calculate for many pairs, how should I write an indicator that either draws the price of shifted moving average or displays it in the data window without counting manually?levels to MA
 
Roger:

Well, with each other, it doesn't seem difficult

But when there are more than two, it's not clear how to compare. Show me a method to compare three numbers 1, 2 and 3 at the same time,

.

If I'm not mistaken, the number of cycles must match the number of elements in the array. The problem is that the number of elements is not fixed and can be much more than 4, need to think how to design it. I also wonder if there are other implementation options that affect speed, memory consumption, etc.?
 
paladin80:



Thank you! Doesn't it matter which side you start counting from, i.e. the 3rd bar?
 
I want to rephrase and add to my previous question.
Below is the code for an array of 4 elements. In reality the number of items in the array is variable.
How can I change the code so that the number of nested 'for' loops becomes variable, one 'for' per array item?
Thank you!

int start() { 

   int Array[4]                                       = {1, 2, 3, 4};
   int x1, x2, x3, x4;
   int Array_Size                                  = ArrayRange(Array,0);


   for(x1=0; x1<Array_Size; x1++) {
      Print("Combination                       = ", Array[x1]);

      for(x2=x1+1; x2<Array_Size; x2++) {
         Print("Combination                    = ", Array[x1] + "   " + Array[x2]);

         for(x3=x2+1; x3<Array_Size; x3++) {
            Print("Combination                 = ", Array[x1] + "   " + Array[x2] + "   " + Array[x3]);

            for(x4=x3+1; x4<Array_Size; x4++) {
               Print("Combination              = ", Array[x1] + "   " + Array[x2] + "   " + Array[x3] + "   " + Array[x4]);
            }
         }
      }
   }


   return(0);
}
 
skyjet:

Thank you! Doesn't it matter which side to start counting from, i.e. 3rd bar?

For your example it doesn't actually make a difference, but you have to specify the beginning and end of the array anyway.

for (int x=3; x>1; x--)
{
 if(Open[x]==Open[x-1]) continue;
 if(Open[x]<Open[x-1])
   {
   //--- action
   }
}
The beginning does matter if the array is large. For example, if the condition is triggered at the end of the array as a rule, you'd better start at the end. This example is typical of order/position searching. Of course, if you do the search first in this case, the program will get to this point anyway, but it will take more resources.
Reason: