[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 105

 
abolk:
look here: https: //docs.mql4.com/ru/basis/operations/math
I've looked at it all. How do I solve my problem?
 
Zhunko:
You can do that too.

wouldn't b be equal to one?

I checked. One.

 
artmedia70:
Create flags, e.g.

For TP1 - bool TP1, for TP2 - bool TP2, etc...

Initially their values are false.

Before the next closing, you do a check:

if (!TP1) {code for partial closing of the first part, after successful closing write TP1=true}

if (!TP2) {code for partially closing the second part, after a successful closing write TP2=true}

... and so on for all parts...

So the flags will signal that each part has been closed once already...


Thanks! Reworked the code... TP0==false I put it at the beginning of the program .

The problem remains: 1st part closes and immediately starts to close 2nd :-( ..., with error 131 for 2nd, understandable - lot size different ) But another nuance is that for 1st part ""Alert ("Closed ",Lot," Lot Buy ",Ticket);"" does not write in log, i.e. does not reach verification Ans==true. Why???? Below is a piece of code...

Thanks in advance!

while(true) // Close horde loop.
{
if (TP0==false && (Cls_B0==true ||Cls_S0==true))

{
LotC=MathRound(Lot/4/Step)*Step;
Alert("Lot-",Lot, "Attempting to close-",LotC," Lot Buy ",Ticket,. Waiting for reply...");

RefreshRates(); // Refresh data
Ans=OrderClose(Ticket,LotC,Bid,5); // TicketClose Buy 1/3 lots?
if (Ans==true) // It worked :)
{
TP0=true;
Alert ("Closed ",Lot," Lot Buy ",Ticket);
break; // Exit from closed loop
}
if (Fun_Error(GetLastError())==1) // Error handling
continue; // Retry
return; // Exit from start()
}

 
Sinichka:

Dear programmers!

Help, please. The indicator draws values on a bullish latent divergence, and does not draw a bearish latent.... It writes, that error 4002 - array index - out of range.

I seem to have fixed everything... It took me a whole evening... And it's a shame - the code is the simplest... But it's drawing bulls with arrows, but not bears... PLEASE! What is the error in?????????????????????


Alena,

You need to allocate memory for arrays vpadcci[], v[], hh[], ss[]. They are declared as dynamic, but their size is not specified anywhere. The size of a dynamic array is specified using the ArrayResize() function.

P.S. And please use the SRC button to insert code

 
Snaf:
Question for MT5. How can I know that the Strategy Tester has completed its work? Other than visually :)

The deinit() function is executed when the job is completed. Consequently, if we get there, it means that the expert's work is finished. To determine whether the work in the tester is in progress, use function IsTesting().


Sorry, I noticed that this question is related to MT5.

It is the same there, only OnDeinit() and MQL5InfoInteger(MQL5_TESTING).

 
alsu:

Alena,

You need to allocate memory for the arrays vpadcci[], v[], hh[], ss[]. They are declared as dynamic, but their size is not specified anywhere. The size of a dynamic array is defined using the ArrayResize() function.

P.S. And please use SRC button to insert code


Thanks so much for the reply, I'll look into it!
 
eddy:

вопрос програмистам: как сделать число после запятой целым?:)

например в числе 1,128 нужно 128, в 1,12 - 12, в 1,2 - 2)

exnern double n=1,12
n-=MathFloor(n);          // 0.12 = 0.1200000..01 или 0.11999999..99
int n2=MathRound(n*1000); // 0.12 > 120 или 119
while(true)               // пока в конце 0 или 9
 if(n2%10<1)              // n2==хз*10+0
    n2/=10; else          // убираем 0
 if(n2%10==9)             // n2==хз*10+9
   {n2=MathRound(n2/10);} // округляем 9 (119 > 11.9 > 12)
 else if(n2%10>0) break;
That's how I solved it. One minus - you can't get a number if it ends in 0 or 9. But I don't need to, I just enter the calculation period (4,8,12,16,24,36,48 etc.)
 

Please advise how to correctly record that VininI LRMA indicator colour.mq4 https://www.mql5.com/ru/code/8200 has changed.

If you use double iCustom(string symbol, int timeframe, string name, ..., int mode, int shift). I cannot figure it out. I wrote iCustom(NULL,0, "VininI_LRMA_color",55,0,1) and don't know what to do with it))

 

The values of the lines are in the indicator buffers 1 (green) and 2 (red). When a green line is drawn on the chart, the variable up on bar 1 has the value of this line, and the variable dn=EMPTY_VALUE and vice versa. EMPTY_VALUE is an empty buffer value, its numeric value is 2147483647.
You can then use these values as you wish.

double up=iCustom(NULL,0,"VininI LRMA color",period,price,Shift,1,1); 
double dn=iCustom(NULL,0,"VininI LRMA color",period,price,Shift,2,1); 
 
Poseidon:
Can we create an EA which closes all orders when the take-profit of the last opened order triggers?
I am just a beginner and do not know how to do it. Can you do it for me, if you don't mind?
Reason: