Questions from Beginners MQL4 MT4 MetaTrader 4 - page 147

 

EA should read from a file an array of data in the form: date integer1 integer2 integer3 integer4, can be from any file type, except bin.

файл скопировал в папку C:\Users\Михаил\AppData\Roaming\MetaQuotes\Tester\1B9501BF48F2354A4685940A72752910\Agent-127.0.0.1-3000\MQL5\Files\qqq.scv

it's deleted from this folder.

here's the code.


int File()
{
int P=0;

int filehandle=FileOpen("qqq.csv",FILE_READ|FILE_CSV,","); 
if(filehandle!=INVALID_HANDLE) 
     { 
     datetime d = FileReadDatetime(filehandle);
   int I=FileReadNumber(filehandle);
     FileClose(filehandle);
     Comment(d+" "+I);
     }
     else {Comment("qqq.csv");}
return P;

}

can you specify the path to the folder from which the file will not be deleted by the tester? I understood that all files are deleted from this folder during testing, but when the file is created programmatically, it is placed in this folder

 
Mikhail Simakov:

EA should read from a file an array of data in the form: date integer1 integer2 integer3 integer4, can be from any file type, except bin.

файл скопировал в папку C:\Users\Михаил\AppData\Roaming\MetaQuotes\Tester\1B9501BF48F2354A4685940A72752910\Agent-127.0.0.1-3000\MQL5\Files\qqq.scv

it's deleted from this folder.

Here's the code.

maybe specify the path to the folder from which the file will not be deleted by the tester? I understood that all files are deleted from this folder when testing, but when creating a file programmatically, it is placed in this folder

Maybe we should use FileCopy with the FILE_COMMON flag. The new test works from scratch, this might be a glitch.

 
Konstantin Nikitin:

Maybe you should use FileCopy with FILE_COMMON flag. The new test works from scratch, this may be a glitch.

it works if you copy the file to a folder while testing )) now to figure out the separator

 

I started writing a trading panel in MQL4 and here's the paradox. Everything looks fine, but every time I change TF, lines and text from other indicators are drawn on top of my panel.

Here is what I checked: when changing the TF, parameter OBJPROP_BACK = false. It means that everything is fine on this side.

Any ideas on this subject?

P.S. As a matter of fact, I have checked it now and the source code (which I took as a prototype) behaves in the same way. After I have changed TF, it draws normal lines on top of the panel and the lines created by indicators that don't use OOP.
https://www.mql5.com/ru/code/19220
Infopanel
Infopanel
  • www.mql5.com
Пример создания простого и быстрого меню с поддержкой нескольких языков. В примере выводится информация о цене, времени до следующего бара, балансе счета, количестве ордеров. Данный пример можно использовать в качестве шаблона для создания своих разработок. Минус данного метода при добавлении, удалении или редактировании объектов необходимо...
 
Goya7:

I started writing a trading panel in MQL4 and here's the paradox. Everything looks ok, but every time I change TF, lines and text of other indicators are drawn on top of my panel.

Here is what I have checked: when changing the TF, parameter OBJPROP_BACK = false. So everything is fine on this side.

Any ideas on this subject?

P.S. As a matter of fact, I have checked it now, the source code (which I took as a prototype) behaves the same way. After I have changed TF, it draws normal lines on top of the panel and the lines created by indicators that don't use OOP.
https://www.mql5.com/ru/code/19220

When switching timeframe, objects created by other programs are deleted and new ones are created right away. In the panel, objects are not deleted, so they are "old". On the chart, the principle "whoever is last is on top" applies.

You need to delete objects in the panel with DeInit(), and create new ones again

 
Goya7:

I started writing a trading panel in MQL4 and here's the paradox. Everything looks ok, but every time I change TF, lines and text of other indicators are drawn on top of my panel.

Here is what I have checked: when the TF is changed, parameter OBJPROP_BACK = false. So, everything is fine on this side.

Any ideas on this subject?

P.S. As a matter of fact, I have checked it now, the source code (which I took as a prototype) behaves the same way. After I have changed TF, it draws normal lines on top of the panel and the lines created by indicators that don't use OOP.
https://www.mql5.com/ru/code/19220
Vitaly Muzichenko:

When switching timeframe, objects created by other programs are deleted and new ones are created right away. In the panel, objects are not deleted, so they are "old". On the chart, the principle "whoever is last is on top" applies.

You need to delete objects in the panel using DeInit(), and create new ones again

it is better to catch creation of a new object in Events and redraw the panel

 
Vitaly Muzichenko:

When you switch times, objects created by other programmes are deleted and new ones are created immediately. In the panel, objects are not deleted, so they are "old". The principle of "The last one on top is the last one on top" applies in the graph.

You need to delete objects in the panel using DeInit(), and create new ones again

Thanks for the thoughts. In DeInit() they are deleted, of course. When changing TF the Init() procedure goes through, but something tells me that the panel is not redrawn. Namely, I experimented and installed another panel, which is territorially where mine is and then deleted it. Mine is also gone (before the TF change) - so it's not redrawing. ((
Can you tell me a bit more about how to redraw it?


Taras Slobodyanik:

it is better to catch creation of a new object in Events and redraw the panel

Tell me how to do it, I'm only half an hour as a programmer. :)
 
int OnInit()
{
ChartSetInteger(0,CHART_EVENT_OBJECT_CREATE,true);
}


void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
//событие создания нового объекта на чарте
if(id==CHARTEVENT_OBJECT_CREATE && StringFind(sparam, prefix, 0)<0)
   {
   //удаляем панель и рисуем заново

   ChartRedraw();
   }
}

ps. that reminds me - you also need to check the name of the created object to make sure it is not "your" object (prefix the name of your objects).
or instead of the name, compare the type of object.

 
Citizens, tell me if I'm doing it right!!! I need the Expert Advisor to trade when it hasn't entered the 30 or 70 zone, and when it has, it won't trade!!! Is this the right way to do it?

RSI3 = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE, 1);
RSI4 = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE, 2);

bool RSItf = RSI3 > 30 && 30 > RSI4;
if(RSItf == true)
{
}
else
{
ordersend(_Symbol, OP_SELL, lot, Bid, Slippage, 0, 0, NULL, Magic, 0, clrRed);
}
bool RSItf = RSI3 > 70 && 70> RSI4;
if(RSItf == true)
{
}
else
{
ordersend(_Symbol, OP_BUY, lot, Ask, Slippage, 0, 0, NULL, Magic, 0, clrBlue);
}
 
ponochka:
Citizens, tell me if I'm doing it right!!! I need the Expert Advisor to trade when it hasn't entered the 30 or 70 zone, and when it has, it won't trade!!! Is this the right way to do it?

It's something like this, as far as I understand you need

int RSIPeriod = 0, Slippage = 5, Magic = 1234;
double lot = 0.1;

void OnStart()
{
     double RSI3 = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE, 1),
            RSI4 = iRSI(_Symbol, _Period, RSIPeriod, PRICE_CLOSE, 2);
     int ticket = 0;
     
     if(RSI3 <= 30 && RSI4 <= 30)
          ticket = OrderSend(_Symbol, OP_SELL, lot, Bid, Slippage, 0, 0, NULL, Magic, 0, clrRed);
     
     if(RSI3 >= 70 && RSI4 >= 70)
          ticket = OrderSend(_Symbol, OP_BUY, lot, Ask, Slippage, 0, 0, NULL, Magic, 0, clrBlue);
}
Reason: