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

 
valeryk:
If I understand the problem correctly.It's not clear where n should be taken from...
Thank you for your feedback! The number of open orders is equal to n. When the signal to open is repeated, the requirement of having profit in the already opened positions increases. Thus, I avoid unreasonable drawdowns. It is solved simply in the loop, but it is not convenient to insert it into opening conditions, like with theswitch.We need a "factorial", but summing one, not multiplying! Formula! So far I'm using the above formula with MathMax.
 
borilunad:
Thank you for your feedback! The number of open orders is equal to n. When the signal to open is repeated, the requirement to have a profit in already open positions increases. Thus, I avoid unreasonable drawdowns. It is solved simply in the loop but it is not convenient to insert it into the opening conditions. I need sort of a "factorial" but it should be summing, not multiplying!
I see. Well, this is how I would do it if the number of orders is limited to 5. Sweep in this case is the fastest way.
 
valeryk:
I see. Well, I would do it that way if the number of orders is limited to 5. The scroll in this case is the fastest way.

Ouch ;) ?

const int iN[] = {1,3,6,10,15};

Nn = iN[n];
 
valeryk:
I see. Well, I would do that if the number of orders is limited to 5. A sweep is the fastest way in this case.
I do not want to limit it, and therefore I am looking for a formula. Maybe, it will come to my mind eventually, but without a sweep and a loop!
 
VladislavVG:

Ouch ;) ?

Agreed. But if it asks for a value of index 7, for example? It needs to be checked. But in any case there are no errors.
 
borilunad:
Just don't want to be restrictive, so I'm looking for some kind of formula. Maybe it will come to me in time, but without a sweep and a loop!
Then the example above, in the loop in the inite to fill the array. And resize from max orders.
 
VladislavVG:

Ouch ;) ?

О! Thank you very much! That's closer and easier! I'll experiment with this, as I understand the array. But it won't be possible to do indefinitely with the number. Or you could if n==2, then take the 2nd member, and if n==6 or more, then put more members in the array. I hope I got it right!

 
borilunad:

Yes, the array can be made deliberately bigger, for example, measuring 100 or more - the number of orders you are unlikely to get, but it will still be limited.

If you want to get it without limits, you will only need a loop. Make it a separate function, it will be normal to call it in any place. There will be a speed loss: unfortunately, there are no inline Functions in MKL.

 
borilunad:
It's got me))
input int MaxOrders = 5;  // внешняя

int Nn[];  // глобальная

int OnInit()
  {
   string txt="";
   int i=0,temp=0;
   ArrayResize(Nn,MaxOrders+1);
   for(i=1;i<=MaxOrders;i++) 
     {
      temp+=int(MathMax(i-1,0));
      Nn[i]=temp;
      txt=StringConcatenate(txt,"\n",temp);
     }
   Comment(txt);
   return(INIT_SUCCEEDED);
  }
 
valeryk:
It's got me))
That got me "hooked" too. Could you do it again, but in good old MKL4 instead of MKL4++!
Reason: