[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 182

 
hoz:

I have written a simple indicator. Here is the code:

There is only one buffer in it. The indicator values are of type double.

In Expert Advisor, I decided to get the value of the indicator and apply it to the trade as a filter.

Here I wrote a simple function call of this indicator buffer on the last formed bar:

In the tester the slope value is returned wrong:

Why? The type is correct. The call is also correct. The indicator works properly at all. Here is the log log on the tester, and from the real current market:

Why is some number2147483647 returnedall the time instead of the required number ?

An Empty value(EMPTY_VALUE) is returned to you, which is 2147483647. Maybe you should press Ctrl+D and look up the data of the indicator itself?
 
hoz:

I have written a simple indicator. Here is the code:

It has only one buffer. The indicator values are of type double.

In Expert Advisor, I decided to get the value of the indicator and apply it to the trade as a filter.

Here I wrote a simple function call of this indicator buffer on the last formed bar:

The slope value is not correct in the tester:

Why? The type is correct. The call is also correct. The indicator works properly at all. Here is the log log on the tester, and from the real current market:

Why is some number2147483647 returnedall the time instead of the required number ?


Reworked the indicator

2013.02.26 21:22:39     2011.12.30 23:59  D_Aleks_first_pattern EURUSD,H1: slope = -0.0003
2013.02.26 21:22:39     2011.12.30 23:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0003
2013.02.26 21:22:39     2011.12.30 22:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0006
2013.02.26 21:22:39     2011.12.30 21:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0009
2013.02.26 21:22:39     2011.12.30 20:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0011
2013.02.26 21:22:39     2011.12.30 19:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 18:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 17:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0014
2013.02.26 21:22:39     2011.12.30 16:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 15:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 14:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 13:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 12:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 11:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 10:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.30 09:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 08:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 07:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 06:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 05:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0011
2013.02.26 21:22:39     2011.12.30 04:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 03:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 02:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 01:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.30 00:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 23:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 22:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0014
2013.02.26 21:22:39     2011.12.29 21:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0015
2013.02.26 21:22:39     2011.12.29 20:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0017
2013.02.26 21:22:39     2011.12.29 19:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0018
2013.02.26 21:22:39     2011.12.29 18:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0018
2013.02.26 21:22:39     2011.12.29 17:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0017
2013.02.26 21:22:39     2011.12.29 16:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0016
2013.02.26 21:22:39     2011.12.29 15:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0015
2013.02.26 21:22:39     2011.12.29 14:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0015
2013.02.26 21:22:39     2011.12.29 13:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0014
2013.02.26 21:22:39     2011.12.29 12:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0014
2013.02.26 21:22:39     2011.12.29 11:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0014
2013.02.26 21:22:39     2011.12.29 10:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 09:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 08:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 07:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 06:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 05:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 04:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 03:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 02:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 01:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.29 00:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0013
2013.02.26 21:22:39     2011.12.28 23:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0012
2013.02.26 21:22:39     2011.12.28 22:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.001
2013.02.26 21:22:39     2011.12.28 21:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0007
2013.02.26 21:22:39     2011.12.28 20:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0004
2013.02.26 21:22:39     2011.12.28 19:00  D_Aleks_first_pattern EURUSD,H1: slope = -0.0002
2013.02.26 21:22:39     2011.12.28 18:00  D_Aleks_first_pattern EURUSD,H1: slope = 0
2013.02.26 21:22:39     2011.12.28 17:00  D_Aleks_first_pattern EURUSD,H1: slope = 0
2013.02.26 21:22:39     2011.12.28 16:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0001
2013.02.26 21:22:39     2011.12.28 15:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0001
2013.02.26 21:22:39     2011.12.28 14:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0001
2013.02.26 21:22:39     2011.12.28 13:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0001
2013.02.26 21:22:39     2011.12.28 12:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0001
2013.02.26 21:22:39     2011.12.28 11:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0002
2013.02.26 21:22:39     2011.12.28 10:00  D_Aleks_first_pattern EURUSD,H1: slope = 0.0002
Files:
 
Vinin:


The problem seems to be with the indicator.


You're right... But it's just the number of bars that need to be recalculated... Strange why there is no way to get the correct value in this case.

If you comment out this line, everything works fine and correct the calculation from the 0th bar:

int start()
  {
    int i, countedBars = IndicatorCounted();
    int limit = Bars - countedBars - 1;
    //if (limit > 400) limit = 400;
        
    for(i = limit;i > 0;i--)
    {

But In the previous variant, at priming it was outputting an adequate value. But owl takes not adequate. Why?

 
hoz:


You're right... But it's just the number of bars to be recalculated... Strange why in this case there is no way to get the correct value.

If this line is commented out, everything works fine and the calculation from bar 0 is corrected:

But In the previous variant, it was outputting an adequate value. But owl takes not adequate. Why?


Looks like you are using visualisation mode to check
 
Vinin:

You seem to be using visualisation mode to check

Yeah, so what?
 

Help me find an error, no action and no error. Maybe I am missing some libraries?

//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
#import "kernel32.dll"
   int _lopen  (string path, int of);
   int _lcreat (string path, int attrib);
   int _llseek (int handle, int offset, int origin);
   int _lread  (int handle, string buffer, int bytes);
   int _lwrite (int handle, string buffer, int bytes);
   int _lclose (int handle);
#import


int start()
 {
 string text ="222222";//текст который собираемся записать или перезаписать в файл
 string pach ="D:\FILE.txt";//путь куда записываем файл или перезаписываем
 WriteFile("D:\FILE.txt", text);//выполнение 
 }
//+------------------------------------------------------------------+
//|  записать содержимое буфера по указанному пути                   |
//+------------------------------------------------------------------+
void WriteFile (string path, string buffer) 
 {
  int count=StringLen(buffer); //Возвращает число символов в строке. 
  int result;
  int handle=_lopen (path,1);
  if(handle<0) //если файл еще не создан то создаем
  {
  handle=_lcreat (path,0);
  result=_lclose (handle);
  }
  handle=_lopen (path,1);     //открываем          
  result=_llseek (handle,0,0);    //ставим указатель      
  result=_lwrite (handle,buffer,count); //записываем
  result=_lclose (handle);       //закрываем файл       
 }
//+------------------------------------------------------------------+  

My system: MT4, Build 451.

Windows 7 Home Base.

 
merkulov.artem:

Help me find an error, no action and no error. Maybe I am missing some libraries?

My system: MT4, Build 451.

Windows 7 Home Base.

Unprint handle and result after each operation, you will know what is not working
 
What's wrong with the standard FileXXXXX functions?
 
how to choose the smallest lot among all open trades?
 
pasha5282:
how to choose the smallest lot among all open trades?


int i, ot = OrdersTotal();
double min=0;
int min_ticket=0;
for(i=0;i<ot;i++)
{
   if(!OrderSelect(i,SELECT_BY_POS)) continue;
   if(OrderType()!=OP_BUY && OrderType()!=OP_SELL) continue;
   if(i==0||min> OrderLots()) {min = OrderLots(); min_ticket=OrderTicket();}
}