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

 
rustein:
Yes, I see, thank you.

Put it that way, I don't know any other way.......)

And so...

double BullSumm()
{
  double MySummBull=0;
  for(int Cnt=0;Cnt<OrdersTotal();Cnt++)
  { 
    if(!OrderSelect(Cnt,SELECT_BY_POS,MODE_TRADES))continue; // если нет продолжим цикл
    if(OrderType()==OP_BUY)
    {
      MySummBull+=OrderOpenPrice()*OrderLots();
    }
  }
  if(MySummBull==0)return(380/*v*/);
  return(MySummBull);
}
 
griha:
want to log EA actions to a file
I took an example from the MQL editor's manual, slightly remade it for my own needs


The result is that the file OrdersReport.csv is empty, although the orders are opened.


I ran into the same problem, when opening a file for reading and trying to write into it, the file is either not created, or nothing is written into it.

Servicedeck application :

When trying to add to a text file deregistered with FILE_READ|FILE_WRITE key, without first explicitly setting the file pointer with FileSeek(), writing does not happen at all.

In previous versions of the terminal, when pre-reading a text file using FileReadString() function, file pointer is set automatically.

Here is an answer from developers:

The last change of file functionality dates back to mid-2008.

Never before has it been possible to append to a file without first setting a file pointer at the end.

Again a question about extra information. Does this have anything to do with appending to the end of a file?

Any file read-write operations automatically move the file pointer around. This has always been the case and has not changed. However, if the file is opened as a csv, intermediate data buffering is possible. Then the file pointer may not be where you expect it to be. Again, this has always been the case, both in the previous version and in the pre-release, since the beginning of the official release.

We have reiterated many times that the default principle is extremely detrimental. Including for file pointers. Handle the file pointer explicitly unless you use continuous reading or continuous writing (especially the exotic mixed read-write cases).

Conclusion: use FileSeek

 
khorosh:
Check.
Thank you.
 
Roll:

Your Expert Advisor trades on 30 min ADX signals. If your Expert Advisor trades on 1min ADX signals, such signals will be more frequent than in the first variant. Screenshot in your variant is taken only at BUY position opening.
You are interested in the absence of indicators from the chart in the screenshot (in test mode). You were asked to verify the presence of indicators on the screenshot in demo mode. The script with the appropriate function was added, so you could check and understand your question quickly, instead of waiting for hours. More than a day has passed. I want to know -- what are your results?

I'll keep you posted. I'm busy but I'll try to check tomorrow.
 

Can you tell me what the difference is when defining a name in a function or when assigning a variable name and then passing the variable to a function?

//-------------- первый вариант (рабочий)

string up_line = "upline_", down_line = "downline_";
 
     flatlineup(up_line+TimeToStr(Time[i]), y2,x2,y22,x2,Red,1);     Имя присваиваю в теле функции
     flatlinedown(down_line+TimeToStr(Time[i]), y1,x1,y11,x1,Blue,1);
     dellline(up_line, down_line);

TimeToStr(Time[i]) указывал в имени тренд лайн в теле функции
//--------------- второй вариант (нерабочий)

string up_line = "upline_"+TimeToStr(Time[i]); //--или пробовал StringConcatenate()        ИМЯ ПРИСВАИВАЮ В ПЕРЕМЕННОЙ
string down_line = "downline_"+TimeToStr(Time[i]); //--или пробовал StringConcatenate()
 
     flatlineup(up_line, y2,x2,y22,x2,Red,1);                 ПЕРЕДАЮ ПЕРЕМЕННУЮ В ФУНКЦИЮ
     flatlinedown(down_line, y1,x1,y11,x1,Blue,1);
     dellline(up_line, down_line);
 
rustein:
Help me get rid of the zero divide error in the EA.

Thank you in advance.

You can do it this way, it works for me

double BullPrice()

{

double BullAveragePrice=0;

doubleSummBullLots=0;

for (int i = OrdersTotal() - 1; i >= 0; i--)

{

OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

if (OrderSymbol() != Symbol()) continue;

if (OrderSymbol() == Symbol() && OrderType() == OP_BUY)

{

BullAveragePrice+=OrderOpenPrice()*OrderLots();

MySummBullLots+=OrderLots();

}

}

if (MySummBullLots>0) BullAveragePrice = NormalizeDouble(BullAveragePrice / MySummBullLots, Digits);

return(BullAveragePrice);

}

 
Zhunko:

In the MT4 folder there is a sample C++ code for all cases in MQL4. Compile that code and paste your own code in it. You will immediately find the difference between yours and the example.

My MT does not have one. There is only 1 library written in MQL (stdlib.mq4). Can you throw an example here?
 
Fox_RM:

Can you tell me what the difference is when defining a name in a function or when assigning a variable name and then passing the variable to a function?

In your example, the only difference is in passing the parameters to the function
dellline(...)
 
costy_:

Otherwise...

Thank you!
 

Please advise the situation is this, I read a csv file like this

void ReadDate(){
   while(!IsStopped()){
      string dTime = FileReadString(ExtCsvHandle); // читаем строчку 1
      string sValue = FileReadString(ExtCsvHandle); // читаем строчку 2
      Print("Date=",StrToTime(dTime), "Value=",sValue);   
      
   }
}

but csv file has a header, the first extra line

Time,Value
15.02.2012 00:00:00;Значение1
15.02.2012 00:01:07;Значение2
15.02.2012 00:02:26;Значение3
15.02.2012 00:00:00;Значение1
15.02.2012 00:01:07;Значение2
15.02.2012 00:02:26;Значение3

How to skip the first line programmatically, or delete it programmatically in general when saving the value it spoils everything.

Thanks in advance.

Reason: