[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 227

 
oyshen >> :

How can I select the last 2 trades already closed (from the account history list)?

It should be something like this

how to write correct parameter to select?

The last two orders will have the numbers OrdersHistoryTotal()-1 and OrdersHistoryTotal()-2.


Here is a script to test

int start()
{
   int i, accTotal=OrdersHistoryTotal();
   for( i=0; i< accTotal; i++)
   {
     if(OrderSelect( i, SELECT_BY_POS, MODE_HISTORY)==false)
       {
        Alert("Ошибка при доступе к исторической базе (",GetLastError(),")");
        break;
       }
     Alert( i,":",TimeToStr(OrderCloseTime()));  
   }
}

>> Good luck!

 
alsu >> :

the code is quite crude.

See: i=Bars-Period1+1 at the first iteration of the loop, we get k=i+Period1-1=Bars-Period1+1+Period1-1=Bars and then Close[k], which means we are already out of the array.

Correct: i=Bars-Period1-1

..................

Is there any way to find the maximum(min) of the close[i]/close[i+1] ratio, but without using arrays??? Thank you!

 
Mr-Franklyn >> :

Is there any way to find the maximum(min.) of the close[i]/close[i+1] relationship, but without using arrays??? Thanks!

the question is where to write what the maximum will be searched for. this is usually called an array:) ArrayMax(in)imum is optimal

 
alsu >> :

the question is where to write what the maximum will be searched for. this is usually called an array:) ArrayMax(in)imum -optimal

And if you write it into a buffer?

 
Mr-Franklyn >> :

Is there any way to find the maximum(min.) of the close[i]/close[i+1] ratio, but without using arrays??? Thank you!

If I understood the question correctly. You can experiment not with close[i], but like this:

макс= iHigh(NULL,0,iHighest(NULL,0,MODE_HIGH, Cbar,0));
мин= iLow (NULL,0,iLowest (NULL,0,MODE_LOW, Cbar,0));  

where Cbar, -number of last bars, among which an extremum is searched for

 
rid >> :

If I understood the question correctly. It is possible to experiment not with close, but like this:


where Cbar is the number of last bars among which the extremum is searched for

It is the absolute value of the ratio Prace[i]/Price[i+1] that interests me.

 
Mr-Franklyn >> :

What if you put it in a buffer?

Isn't a buffer an array?

 
alsu >> :

Isn't a buffer an array?

Yes, but if I write Buffer[i]=close[i]/close[i+1] and then use iHighest function, nothing works!!!!

 
Mr-Franklyn >> :

Yes, but if I write Buffer[i]=close[i]/close[i+1] and then use iHighest function, then nothing happens!!!!

because iHighest only works with timeseries. For other arrays analog of ArrayMaximum

 
double Buffer[];

int init()
{
   SetIndexBuffer(0, Buffer);
}

int start()
{
for( i= start; i>=0; i--)
{
   Buffer[ i]=Close[ i]/Close[ i+1];
   double max= Buffer[ArrayMaximum( Buffer, period, i)];
   double min= Buffer[ArrayMinimum( Buffer, period, i)];
   double stddev=iStdDevOnArray( Buffer, period,8,0,MODE_EMA, i);
//TODO
}
///TODO
}