Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1325

 

Dear programmers please advise how to correct the error, the compiler complains about theselines; possible loss of data due to type conversion

The goal is to find the first and last modified position.

The time is written as datetime, basically everything works, but this alert bothers me, I must not be saving the time correctly... any advice please

datetime FirstBuyTime=TimeCurrent();
datetime FirstSellTime=TimeCurrent();
datetime LastBuyTime=0;
datetime LastSellTime=0;
...
if(PositionGetInteger(POSITION_TIME_UPDATE)<FirstBuyTime) FirstBuyTime=PositionGetInteger(POSITION_TIME_UPDATE);//possible loss of data due to type conversion
if(PositionGetInteger(POSITION_TIME_UPDATE)>LastBuyTime)  LastBuyTime=PositionGetInteger(POSITION_TIME_UPDATE);}//possible loss of data due to type conversion
...
if(PositionGetInteger(POSITION_TIME_UPDATE)<FirstSellTime) FirstSellTime=PositionGetInteger(POSITION_TIME_UPDATE);//possible loss of data due to type conversion
if(PositionGetInteger(POSITION_TIME_UPDATE)>LastSellTime)  LastSellTime=PositionGetInteger(POSITION_TIME_UPDATE);}//possible loss of data due to type conversion
 
VVT:

Dear programmers please advise how to correct the error, the compiler complains about theselines; possible loss of data due to type conversion

The goal is to find the first and last modified position.

The time is written as datetime, basically everything works, but this alert bothers me, I must not be saving the time correctly... more info.

Please read this page in your documentation. Take a good look at the examples...

Документация по MQL5: Основы языка / Типы данных / Приведение типов
Документация по MQL5: Основы языка / Типы данных / Приведение типов
  • www.mql5.com
Приведение типов - Типы данных - Основы языка - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

Read this page of the documentation. Look carefully at the examples...

(There are no complaints) Thank you.

 
VVT:

long and no complaints) Thank you.

Yes, but if you have a FirstBuyTime variable of datetime type, it's better to bring it to that type...

FirstBuyTime = (datetime)PositionGetInteger(POSITION_TIME_UPDATE);
 
Alexey Viktorov:

Yes, but if you have variable FirstBuyTime has datetime type, then it's better to bring to this type...

It makes no difference here, then the position is selected on the same principle and in the same type when closing, saving the time in datetime was not correct.

Thank you very much for the clarification.

 
SanAlex:

I've done something wrong here - I don't know what went from 100,000 roubles to two million.

I put it in, the tester starts but nothing happens.
For the futures I changed the lots to 1.0
I put in an indicator.

But the robot is silent.
 
Eugen8519:
I did it myself, the tester runs but nothing happens.
Changed the lots to 1.0 for futures
I put in an indicator.

But the robot is silent.

Did you try to run it with what indicator?

- With this indicator? "StepMA_NRTR"

//--- create MACD indicator
   m_handle_macd=iCustom(NULL,0,"StepMA_NRTR");
 
SanAlex:

Have you tried to run it with which indicator?

- with this indicator? "StepMA_NRTR"

Got it here, StepMA_NRTR.mq5
 
Eugen8519:
I downloaded it here, StepMA_NRTR.mq5

I don't know why it's not working for you.

I copied everything from here and downloaded the same indicator from your link.

It's working for me.

SnapshotSnapshot.PNG

 
How to calculate a commission for open orders in mt5 for each pair separately?
Reason: