Good afternoon. My question may seem incredibly stupid to many people, I apologize, I am still a beginner in this business, I can't figure out what's wrong.
I have created a text file in MQL5\Files\date.txt and cannot open it. The error 5004 is writing. Please help me if you can.
Good afternoon. My question may seem incredibly stupid to many people, I apologize, I am still a beginner in this business, I can't figure out what's wrong.
I have created a text file in MQL5\Files\date.txt and cannot open it. The error 5004 is writing. Please help if you can.
If your file is not in the shared folder of MT5 client terminals (and in your case it is),
Thanks for the help, but unfortunately it didn't help. Tried a lot of variants with the flags. Also, writes error 5004. Is there anything else I should try?
olegin038: Thanks for the help, but unfortunately it didn't help. Tried a lot of options with the flags. Also, writes error 5004. Is there anything else I can try?
Try opening it simply as a text file:
voidOnTick()
{
ResetLastError();
int Handle=FileOpen("date.txt",FILE_TXT|FILE_READ|FILE_WRITE);
if(Handle==-1)
{
Print("Файл не открыт, ошибка: ", GetLastError());
}
return;
}
Hi all, I need help with the famous CrossArbitr indicator. The code is of course not mine. Needed some information, which it does not output. So, in order.
I added variablesdouble n, m;
"\nDifference BID Synthetic and Real =", n=(CalcBid-Bid),
"\, Difference ASK Synthetic and Real =", m=(CalcAsk-Ask),
"\nTotal =" (m - n) <----
It ends up swearing at the minus in this bracket (some operatot expected). Who can tell me what I'm doing wrong?
//+------------------------------------------------------------------+//| CrossArbitr.mq4 |//| Scriptong |//| |//+------------------------------------------------------------------+#property copyright"Scriptong"#property link""#property indicator_chart_window//---- input parametersexternbool ShowBid=false;
externbool ShowAsk=false;
externcolor BidColor = Lime;
externcolor AskColor = Yellow;
externint AlarmIfPointDifference = 10;
externstring AlarmFile = "wait.wav";
bool Activate = False;
string FP, SP;
double Tick;
int WayForCross;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+int init()
{
//---- indicatorsstring S = Symbol();
if(StringFind(S, "USD", 0) != -1)
{
Comment("Индикатор работает только с кроссовыми парами (GBPJPY, EURJPY, EURGBP и т. д)!");
return(0);
}
if(StringLen(S) != 6)
{
Comment("Индикатор работает только с валютными парами, у которых название состоит из шести символов!");
return(0);
}
// Поиск первой валютной пары кросса
FP = StringSubstr(S, 0, 3)+"USD";
MarketInfo(FP, MODE_BID);
if(GetLastError() > 0)
{
FP = "USD"+StringSubstr(S, 0, 3);
MarketInfo(FP, MODE_BID);
if(GetLastError() > 0)
{
Comment("Невозможно найти инструмент ", FP, " или ", StringSubstr(S, 0, 3)+"USD. Необходимо добавить его в Обзоре рынка и перезапустить индикатор.");
return(0);
}
}
// -------------------------------------- // "Создание" второй валютной пары кросса
SP = "USD"+StringSubstr(S, 3, 3);
MarketInfo(SP, MODE_BID);
if(GetLastError() > 0)
{
SP = StringSubstr(S, 3, 3)+"USD";
MarketInfo(SP, MODE_BID);
if(GetLastError() > 0)
{
Comment("Невозможно найти инструмент ", SP, " или ", StringSubstr(S, 3, 3)+"USD. Необходимо добавить его в Обзоре рынка и перезапустить индикатор.");
return(0);
}
}
// -------------------------------------- // Определение пути синтеза кроссаif (StringFind(FP, "USD") == 3 && StringFind(SP, "USD") == 0)
WayForCross = 1;
if (StringFind(FP, "USD") == 0 && StringFind(SP, "USD") == 0)
WayForCross = 2;
if (StringFind(FP, "USD") == 3 && StringFind(SP, "USD") == 3)
WayForCross = 3;
if (StringFind(FP, "USD") == 0 && StringFind(SP, "USD") == 3)
WayForCross = 4;
// -------------------------------
Tick = MarketInfo(Symbol(), MODE_TICKSIZE);
Activate = True;
//----return(0);
}
//+------------------------------------------------------------------+//| Custom indicator deinitialization function |//+------------------------------------------------------------------+int deinit()
{
//----Comment("");
if(ObjectFind("CrossBid") == 0)
ObjectDelete("CrossBid");
if(ObjectFind("CrossAsk") == 0)
ObjectDelete("CrossAsk");
//----return(0);
}
//+------------------------------------------------------------------+//| Приведение значений к точности одного тика |//+------------------------------------------------------------------+double ND(double A)
{
return(NormalizeDouble(A, Digits));
}
//+------------------------------------------------------------------+//| Расчет значения синтетического бида |//+------------------------------------------------------------------+double CalcBidWayForCross()
{
switch (WayForCross)
{
case1: return(ND(MarketInfo(FP, MODE_BID)*MarketInfo(SP, MODE_BID)));
case2: return(ND(MarketInfo(SP, MODE_BID)/MarketInfo(FP, MODE_ASK)));
case3: return(ND(MarketInfo(FP, MODE_BID)/MarketInfo(SP, MODE_ASK)));
case4: return(1/(ND(MarketInfo(FP, MODE_ASK)*MarketInfo(SP, MODE_BID))));
}
}
//+------------------------------------------------------------------+//| Расчет значения синтетического аска |//+------------------------------------------------------------------+double CalcAskWayForCross()
{
switch (WayForCross)
{
case1: return(ND(MarketInfo(FP, MODE_ASK)*MarketInfo(SP, MODE_ASK)));
case2: return(ND(MarketInfo(SP, MODE_ASK)/MarketInfo(FP, MODE_BID)));
case3: return(ND(MarketInfo(FP, MODE_ASK)/MarketInfo(SP, MODE_BID)));
case4: return(1/(ND(MarketInfo(FP, MODE_BID)*MarketInfo(SP, MODE_ASK))));
}
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+int start()
{
int counted_bars=IndicatorCounted();
//----if(!Activate)
return(0);
// Расчет синтетических Bid и Askdouble CalcBid = CalcBidWayForCross();
RefreshRates();
double CalcAsk = CalcAskWayForCross();
double n, m;
// -------------------------------// Рисуем уровень синтетического Bidif (ShowBid)
{
if(ObjectFind("CrossBid") == -1)
{
ObjectCreate("CrossBid", OBJ_HLINE, 0, 0, CalcBid);
ObjectSet("CrossBid", OBJPROP_COLOR, BidColor);
ObjectSet("CrossBid", OBJPROP_STYLE, STYLE_DOT);
}
elseif(!ObjectMove("CrossBid", 0, 1, CalcBid))
Print("Ошибка перемещения №", GetLastError());
}
// ---------------------------------- // Рисуем уровень синтетического Askif(ShowAsk)
{
if(ObjectFind("CrossAsk") == -1)
{
ObjectCreate("CrossAsk", OBJ_HLINE, 0, 0, CalcAsk);
ObjectSet("CrossAsk", OBJPROP_COLOR, AskColor);
ObjectSet("CrossAsk", OBJPROP_STYLE, STYLE_DOT);
}
elseObjectMove("CrossAsk", 0, 1, CalcAsk);
}
// ---------------------------------- Comment("Реальный BID = ", DoubleToStr(Bid, Digits), ", реальный ASK = ", DoubleToStr(Ask, Digits),
"\nСинтетик BID = ", DoubleToStr(CalcBid, Digits), ", синтетик ASK = ", DoubleToStr(CalcAsk, Digits),
"\nРазница BID Синтетика и Реального =", n=(CalcBid-Bid),
"\, Разница ASK Синтетика и Реального =", m=(CalcAsk-Ask),
"\nИтог =" (m - n)
);
// Выдаем звуковой сигнал о превышении минимальной разностиif(ND(MathAbs(CalcBid-Bid)) >= ND(AlarmIfPointDifference*Point))
PlaySound(AlarmFile);
// -------------------------------------------------------- //----return(0);
}
//+------------------------------------------------------------------+
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good afternoon. My question may seem incredibly stupid to many people, I apologize, I am still a beginner in this business, I can't figure out what's wrong.
I have created a text file in MQL5\Files\date.txt and cannot open it. The error 5004 is writing. Please help me if you can.
Good afternoon. My question may seem incredibly stupid to many people, I apologize, I am still a beginner in this business, I can't figure out what's wrong.
I have created a text file in MQL5\Files\date.txt and cannot open it. The error 5004 is writing. Please help if you can.
If your file is not in the shared folder of MT5 client terminals (and in your case it is),
You have to remove the FILE_COMMON flag:
If your file is not in the shared folder of MT5 client terminals (and in your case it is),
The FILE_COMMON flag must be removed:
Thanks for the help, but unfortunately it didn't help. Tried a lot of options with the flags. Also, writes error 5004. Is there anything else I can try?
Try opening it simply as a text file:
Try opening it simply as a text file:
It didn't work either. I have never worked with files before. Don't you need to do anything extra here?
Yes, you have to be sure to close the file:
Yes, you must always close the file:
Sharing courses by prominent authors from my personal library.
Hi all, I need help with the famous CrossArbitr indicator. The code is of course not mine. Needed some information, which it does not output. So, in order.
I added variablesdouble n, m;
"\nDifference BID Synthetic and Real =", n=(CalcBid-Bid),
"\, Difference ASK Synthetic and Real =", m=(CalcAsk-Ask),
"\nTotal =" (m - n) <----
It ends up swearing at the minus in this bracket (some operatot expected). Who can tell me what I'm doing wrong?