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

 
OTPOK:

One more thing - How do I change the stoploss of an already open order programmatically?


https://docs.mql4.com/ru/trading/OrderModify
 
FOReignEXchange:


Good afternoon. I take it you've never assigned values to variables. It's very easy to do.

PriceBuy=Ask


Actually: PriceBuy=Bid;
 
Roger:

Actually: PriceBuy=Bid;

Well, that's a matter of opinion. And if realistically, Asc.
 

Hello.

Please tell me if the expression for calculating the total sum of a sequence of numbers delta*(2*Lot+Lot*(i-2))*(i-1)/2is correct :

for (int i=1; i<=MaxOrders; i++) {

double Sum=Lot;

Sum+=delta*(2*Lot+Lot*(i-2))*(i-1)/2; }

If there are no errors, how to substitute "Sum+" value into expression like X=("Sum+" + Y)/Z ???

Source code:

for (int i=1; i<=MaxOrders; i++)
   {
      if (BUY)
      {
         Price = NormalizeDouble(Ask-delta*i*Point,Digits);
         double Sum=Lot;
         Sum+=delta*(2*Lot+Lot*(i-2))*(i-1)/2;
         DeltaProfitL = (Sum+i*delta*Lot+Lot*R_Lot*R_point+Lot*R_Lot*delta*i)/((2*Lot+Lot*(MaxOrders-1))*MaxOrders/2+Lot+Lot*R_Lot);
         if (takeprofit!=0) TP  = NormalizeDouble(Price + (takeprofit + DeltaProfitL*zero_tp)*Point,Digits); else TP=0;
         if (stoploss!=0)   SL  = NormalizeDouble(Price - stoploss*Point,Digits); else SL=0;     
         OPENORDER ("Buy Limit",Price,SL,TP,i);
      }
   }

Thanks in advance.

 
nemo811:

Hello.

Please tell me if the expression for calculating the total sum of a sequence of numbers delta*(2*Lot+Lot*(i-2))*(i-1)/2is correct :

for (int i=1; i<=MaxOrders; i++)

double Sum=Lot;

Sum+=delta*(2*Lot+Lot*(i-2))*(i-1)/2;

If there are no errors, how to substitute "Sum+" value in expression like X=("Sum+" + Y)/Z ???

Thanks in advance.


Wouldn't that work?

for (int i=1; i<=MaxOrders; i++)

Sum=Sum+delta*(2*Lot+Lot*(i-2))*(i-1)/2;

Only it's not clear why Sum=Lot; And what's it for in general.

 
FOReignEXchange:


Only it is not clear why Sum=Lot; And what for in general.

I asked a similar question on page 81. I have done everything according to the answer given to me. But so far no result.

Sum=Sum+delta*(2*Lot+Lot*(i-2))*(i-1)/2; - is not suitable for my calculation.

 
delta*(2*Lot+Lot*(i-2))*(i-1)/2 is the number formula for the sequence in question. I need to sum ALL the numbers of the given sequence.
 
nemo811:
delta*(2*Lot+Lot*(i-2))*(i-1)/2 is the number formula of the sequence in question. I need to sum up ALL the numbers of the given sequence.


So I wrote a formula for that.

I understand you need to calculate something like this

Sum =delta*(2*Lot+Lot*(1-2))*(1-1 )/2 +delta*(2*Lot+Lot*(2-2))*(2-1 )/2 +delta*(2*Lot+Lot*(3-2))*(3-1)/2 + ... etc.

This is the formula Sum=Sum+delta*(2*Lot+Lot*(i-2))*(i-1)/2, where you set the limitations for i in the operator body. When the operator finishes, Sum will take the desired value. It is important that Sum equals to zero before the operator starts making calculations. At the operator exit Sum will take the desired value.

 

I'm not sure how much it would cost to order an EA, but I'm sure I can get it to work in both charts.

Ah, and in general it is possible to make it work once for 2 different currencies (simultaneously on two charts) and opened on each of the different trades.

For example, I bought on the first one and sold on the second one?

And on closure of one of the transactions opened the opposite of the already open transaction....

And may be someone knows, maybe there is such an Expert Advisor, just a good idea came to my mind.....

 
for (int i=1; i<=MaxOrders; i++)
   {
      if (BUY)
      {
         Price = NormalizeDouble(Ask-delta*i*Point,Digits);
         double Sum=0;
         Sum=Sum+delta*(2*Lot+Lot*(i-2))*(i-1)/2;   ........
      }
}
Thank you. Is this the right thing to do?
Reason: