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

 
sergeev:

Deal at a certain time


1
Mega4alik 03.08.2011 17:34

How do I write an EA which opens a deal at a certain second?

I can't think of anything but start, but it only opens when price changes, and I need it in a second

And what if in this second there is a momentary lapse of connection? And this phenomenon is very common in all brokers.

if(TimeHour(prevtime)==1 && TimeMinute(prevtime)==1 && TimeSeconds(prevtime)==1)
{
order open function
}

prevtime=TimeCurrent();

You have to loop the whole start:


int start()
{
while(!IsStopped())
{

RefreshRates();

all operations

}

}

 
demlin:
...Ctrl+Alt+M used to paste code, but it's not working. SRC can't find it, sorry, please.
How to make a post, insert code of program, image, video
 
 

demlin i.e. will the second condition be met in any case?



 
if (x2==x1) return(y1);
else
return((y2-y1)/(x2-x1)*(x-x1)+y1);}
 
nuan:

is the point of it - to calculate the value of
 
demlin you are trying to return one value first
return(y1);
потом сразу другое
return((y2-y1)/(x2-x1)*(x-x1)+y1);
а смысл у1 возвращать
 
nuan:
You are tryingto return one value first

y1 is returned if x1=x2, i.e. there is only one point. If there are two points and x1 is not equal to x2, then the calculation is done.

The function is fine, I separately tested it outside the loop - it works correctly.

 
nuan:

What don't you understand? Don't confuse the man:

double EquationDirect(double x1, double y1, double x2, double y2, double x) 
{
  if (x2==x1) return(y1);              // Если х2 равно х1, то вычислять ничего не нужно, а просто вернуть значение y1
  return((y2-y1)/(x2-x1)*(x-x1)+y1);   // а тут вычисления нужны (х2 не равно х1), вычисляем значение по формуле уравнения прямой и возвращаем его
}

Is that clearer?

 
demlin:

y1 is returned if x1=x2, i.e. there is only one point. If there are two points and x1 is not equal to x2, then the calculation is done.

The function is fine, I separately tested it outside the loop - it works correctly

Give me again the indicator code fragment where you want to put it all. But... You don't need to increase the buffer - you need to shift the pointer to the buffer cell where you want to put the value.