Questions from a "dummy" - page 85

 
AUser:

I'm trying to figure out how to save data to a file. I have written the following code:

Only the last price value is saved to a file. I want the value of prices in a column. Where did I go wrong?

Look at "Peculiarities of operation when specifying read and write flags" in MQL5 Reference / Standard constants, enumerations and structures / Input/Output constants / File open flags
 

I'm really dumb)) I listened to advice earlier and rewrote the code, although I don't understand why it was like this... nothing has changed anyway. In idea it's the most elementary program for writing something to a file, and I'm so dumb...))

void OnInit()
{
double BID = SymbolInfoDouble(_Symbol,SYMBOL_BID);
int FILE = FileOpen("FILE",FILE_WRITE|FILE_CSV,'\t',CP_ACP);
FileIsEnding(FILE);
FileWrite(FILE,BID);
}
void OnDeinit(const int reason)
{
int FILE = FileOpen("FILE",FILE_WRITE|FILE_CSV,'\t',CP_ACP);
FileClose(FILE);
}

Just a reminder, I'm trying to write a program for saving ticks to a file. Saves only the last tick for some reason.

 
AUser:

I'm really dumb)) I listened to advice earlier and rewrote the code, although I don't understand why it was like this... anyway, nothing has changed. In idea it's the most elementary program for writing something to a file, and I'm so dumb...))

Just a reminder, I'm trying to write a program for saving ticks to a file. For some reason, it only saves the last tick.

Function
FileIsEnding(FILE);

Doesn't set the file cursor to the end of the file at all, as you probably intended.

Work it out and you'll be happy. :)

 
AUser:

I'm really dumb)) I listened to advice earlier and rewrote the code, although I don't understand why it was like this... nothing has changed anyway. In idea it's the most elementary program for writing something to a file, and I'm so dumb...))

Just a reminder, I'm trying to write a program for saving ticks to a file. Saves only the last tick for some reason.

This is about the right way to do it.

int FILE;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   FILE = FileOpen("FILE",FILE_WRITE|FILE_CSV,'\t',CP_ACP);
//---
   return(0);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   FileClose(FILE);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double BID = SymbolInfoDouble(_Symbol,SYMBOL_BID);
   FileWrite(FILE,BID);
  }
//+------------------------------------------------------------------+
 
sergey1294:

about this is how it should be

Exactly, thank you))
 
ZahvatkiN:

I've noticed that in MT4 before opening a deal you can set stop-loss and take-profit level, but not in MT5, or is it possible, but in a different way?

 
sergeev:

ZahvatkiN:

I have noticed that in MT4 before opening a deal, you could set the stoploss and takeprofit level, but MT5 doesn't have it or is it possible, but in a different way?


It was discussed here https://www.mql5.com/ru/forum/1111/page561
 

Hello.Code.Working TF M15.Transition to Open-Close block occurs on a new bar.

If due to a requote (for example), the position will not open, then it will reopen on the next bar.

And if the entry criterion (looking at the OHLC of the previous bar) is gone, the position will not open.

Do I understand it correctly?

ZS.Probably it makes sense to enter at least on a new minute.

void OnTick()
  {CopyTime (_Symbol,PERIOD_M15,0,1,time);
   if (lastbar==time[0]) return;
   lastbar=time[0];
   
  SearchForExit();
  SearchForEnter();
 
   return;
  }
 

Colleagues, can you tell at a glance, without benchmarking, what is faster: to execute CopyTime() of the whole history once or to call it every time only for some bars (which may be less than Bars() of the whole history) and to copy the time of just one - current bar - into Arr?

If you don't look back to the benchmark, but reason logically, based on knowledge, how can you justify your answer? ...Although I understand that this is already in the direction of C/C++...

 
The correct approach is to request a reasonably appropriate depth for each challenge. And there is no need to make full depth queries. The important point is that history can be downloaded asynchronously at any time.