Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 813

 
WinProject:
Good evening, could you advise me please. I am reading FileOpen of their text .csv file. There are three values in each line of the file, they are instrument, date (in descending order) and price. I want to get the price comment on the last date (it's the first line), but the file is always read to the end and I get the comment of the oldest price (from the last line). How can I get the price value from the first line into the comment without any workarounds?

FileSeek()

Документация по MQL5: Файловые операции
Документация по MQL5: Файловые операции
  • www.mql5.com
Из соображений безопасности в языке MQL5 строго контролируется работа с файлами. Файлы, с которыми проводятся файловые операции средствами языка MQL5, не могут находиться за пределами файловой "песочницы". общая папка всех установленных на компьютере терминалов  – обычно расположена в каталоге C:\Documents and Settings\All Users\Application...
 
Igor Makanu:

Each broker has its own quotes providers, often there are several of them, plus the algorithms for smoothing the quotes

If you need real ticks, transfer your TS to MQL5 - there is testing by real ticks, you will save time when testing

Tell us briefly about the algorithms of smoothing quotes, what is it? mql5 allows testing on the history of the TS by ticks, ie, the result will be one-to-one with requotes and gaps, and there is an opportunity to conduct a test on ticks taking into account the Bid Asc, requotes and gaps?

 
Seric29:

Tell us briefly about the algorithms for smoothing quotes, what are they? On mql5 there is an opportunity to test the TS on tick history, i.e. the result will be one to one taking into account requotes and gaps, and there is an opportunity to test on ticks taking into account Bid Asc as well as requotes and gaps?

all information is publicly available on this forum, about ticks search admin messages 6-8 years ago

about the quality of testing - articles

 
Alexey Viktorov:

Maybe try to open an opposite closing volume and apply OrderCloseBy?

Greetings. Could you please tell me what I'm doing wrong?

OrderCloseBy() gives error 3

3

ERR_INVALID_TRADE_PARAMETERS

Incorrect parameters

code sample

#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict


datetime time; int ticket_buy; int ticket_sell; 
bool open=false; bool close=false;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
ticket_sell=OrderSend(NULL, OP_SELL, 0.1, Bid, 0, 0, 0, "", 0, 0, Red);  

time=TimeCurrent();
//if (Digits() ==3 || Digits()==5) {trailingStep*=10; }
   return(INIT_SUCCEEDED);
  }
void OnDeinit(const int reason)
  {
//---
   
  }
void OnTick(){
if(!open && TimeCurrent()>=time+2600){
   ticket_buy=OrderSend(NULL, OP_BUY, 0.1, Ask, 1, 0, 0, "buy order", 0, 0, Blue);
   open=true;
}
if(!close && TimeCurrent()>=time+3000){
   if(OrderCloseBy(ticket_buy, ticket_sell , Black)){ }
   close=true;
}

}//+------------------------------------------------------------------+
 
Andrey Sokolov:

Greetings. Could you please tell me what I'm doing wrong?

OrderCloseBy() gives error 3

3

ERR_INVALID_TRADE_PARAMETERS

Incorrect parameters

code sample

code works in the tester, tidy upOrderSend(), no normalized price and lot

and the second condition - not all brokers allow using OrderCloseBy() - I think this is the main reason for the error

 
Igor Makanu:

the code works in the tester,

You're closing, right? What broker do you have? I have Alpari.
 
Igor Makanu:

tidy up OrderSend(), no normalised price and lot


I don't quite understand what to normalise here and why, when there are no mathematical operations?
 
Andrey Sokolov:
Not quite sure what to normalise here and why when there are no mathematical operations?

Because you have to accustom yourself to send normalised prices to the server, now the order is sent - tomorrow it is not, you will be constantly looking for your mistakes

What's complicated about it? Here, copy it yourself if it's complicated:

ticket_sell=OrderSend(_Symbol, OP_SELL, 0.1, Bid,10,
                     NormalizeDouble(0.0,_Digits),NormalizeDouble(0.0,_Digits), "", 0, 0, clrRed);  

mathematical operations have nothing to do with it, there used to be strange terminal behaviour in new builds, to all questions the developers wrote - write your codes correctly - they're right )))

on server Metakvot check your code - everything works

SZS: 0 is not 0.0 , so there may not be quite the expected result - also a good habit not to look for bugs ;)

 
Igor Makanu:

and the second condition - not all brokers allow the use of OrderCloseBy() - I think this is the main reason for the error

In general, I understand correctly that if Alpari and probably others do not support it, it is better not to use it at all mark it as not working?

 
Andrey Sokolov:

In general, am I correct in assuming that if Alpari and possibly others do not support it, it is best not to use it at all, mark it as not working?

the function is working

alas, each server's settings need to be checked - there are very few universal solutions (alpars also has stoplevel = 0, you may be surprised with trailing)

if i'm not mistaken, in MarketInfo() there was a request to determine whether a server will close a position using opposite order