[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 123

 
KabrGvin:

Please tell me how to avoid the influence of weekends when there are no bars. Suppose the bar numbers are calculated using the formulas:

nt i1=(Time[0]-t1)/60/Period();

int i2=(Time[0]-t2)/60/Period();

And the number of bars between i1 and i2 equals the difference between them. That is: Number of bars = i1-i2. But if i1 and i2 fall between weekends then the number of bars will be calculated taking into account the bars that do not exist on Saturday and Sunday. How do I get out of this situation?

Regards, Dimitri.


Thank you all. I have worked it out myself.



 

People! How do you round 2.643789 to a whole number?

I can't find it in the textbook or documentation, I can't find anything in the search, or I'm looking in the wrong place.

 
eddy:

alsu, fill in the whole how?:)

and why print i?) i equals Bars-counted+2. how can it be negative?

              for(i=Bars; i>=0; i--) Rel[i]=pr(Close[i])-pr(Close[i+1]);
     if(teni) for(i=Bars; i>=0; i--) {Rhi[i]=pr(High[i])-pr(Close[i+1]);
                                      Rlo[i]=pr(Low[i])-pr(Close[i+1]);
                                                Rlo[i]=MathMin(Rlo[i],0);
                                                Rhi[i]=MathMax(Rhi[i],0);}

This code is executed on every tick, i.e. at the arrival of every tick All elements of arrays Rel,. from Bars to zero are assigned some value. (By the way, there is no element with the number Bars, the last index in the array is Bars-1 - this should be remembered)

Now for the non-drawing.

We need to find out where the error is. First, I suggest that we look at what values the i index takes and what the rsi() function outputs. Since there is no debugger in ME, we have to use echo, i.e. Print().

 
gheka:

People! How do you round 2.643789 to a whole number?

I can't find it in the textbook or documentation, I can't find anything in the search, or I'm looking in the wrong place.

https://docs.mql4.com/ru/math/MathRound

double MathRound( double value)

The function returns the value rounded to the nearest whole number of the specified numeric value.

Example:
double y=MathRound(2.8);
Print("Rounding 2.8 to ",y);
y=MathRound(2.4);
Print("Rounding -2.4 to ",y);
//Output: Rounding 2.8 to 3
//rounding -2.4 to -2

 
alsu:

..on each tick All elements of Rel,... from Bars to zero are assigned some value.

Now about the non-drawing.

We need to find out where the error is. First, I suggest that we look at what values the i index takes and what rsi() function outputs at that. Since there is no debugger in ME, we can use echo, i.e. Print().

"Bars to zero" I've already fixed) I'm always reading and fixing things.

now about the non-drawing)

Can Bars-counted+2 be negative?

 

How can I modify all open orders?

I only modify one order for some reason

Here is my code

 tot=OrdersTotal();
if(tot>0)
{ if(OO_11(0)==false) <---- ОО_11() он проверяет есть ли стоп
{ int k=OrdersTotal();
for(int a=0;a<=k;a++)
{ if(OrderSelect(a,SELECT_BY_POS,MODE_TRADES))
{ if(OrderType()==OP_SELL)
{ if(OrderMagicNumber()==0)
{
int tik=OrderTicket();
OrderModify(tik,Ask,Ask+0.01000,0,0,0);
}
}
}
}
}
}
I have 10-50 orders open without a magician but it only sets a stop loss on one order, tell me what's wrong?
 
eddy:

"Bars to zero" I've already corrected) I'm always reading and correcting things.

now about the non-drawing)

can Bars-counted+2 be negative?

On the fly, no, it can't. But it's still quicker to check than to think. Ideally, you should put prints everywhere and see how the software works.
 
gheka:

How can I modify all open orders?

I only modify one order for some reason

here is my code

i have 10-50 open orders without magic open but i get stop loss only on one order, tell me what's wrong?

1) variable k repeats variable tot

2) a<=k is wrong, correct a<k

3) What's in the log about modifying orders?

 
alsu:

1) the variable k repeats the variable tot

2) a<=k is incorrect, correct a<k

3) What's in the log regarding order modification?

There is no information in the logbook, only the opening of orders and nothing else, it still doesn't work either
 
alsu:

1) the variable k repeats the variable tot

2) a<=k is incorrect, correct a<k

3) What's in the log regarding order modification?

It's working now) thank you.
Reason: