Questions from Beginners MQL5 MT5 MetaTrader 5 - page 17

 
At the beginning ofOnCalculate there is a check of some condition. If the result is false, then I call return(0); how to make this indicator stop working at all and unload itself?
 

I need to make a kind of slip so that the next buy or sell is not opened earlier than specified in the settings.

Can you tell me how to do this on MT5?

 
T-G:

We have to make some sort of a slip so that the next Buy or Sell order would not open earlier than specified in the settings.

Please advise how to do this on MT5.

The slip is called simply by Sleep(xxx); but most likely you need to ignore it until the time runs out,

For this purpose, just remember the server time when the last order was opened, and until the timing comes out, which is remembered time + what is compared to the current server time in the settings, a new order is not opened.

input ulong inptime=30;// время таймаута в секундах
ulong time=0; // это глобально объявляем
 
//---
 if(TimeCurrent()>time+inptime)
   {
    // тут выставляем ордер
    time=TimeCurrent();
   }
Документация по MQL5: Дата и время / TimeCurrent
Документация по MQL5: Дата и время / TimeCurrent
  • www.mql5.com
Дата и время / TimeCurrent - Документация по MQL5
 
Urain:

The slip is called simply by Sleep(xxx); but most likely you need to ignore it until the time runs out,

To do this, just remember the server time when the last order was opened, and until the timing comes out, which is the remembered time + what is compared to the current server time in the settings, no new order is opened.


Yes, most likely not a slip.

How do you know when the last order was closed?

 
T-G:

Probably not a slip.

How do you know when the last order was closed?

You need to view the trade history (you can find the necessary functions in the MQL5 Reference / Trading Functions)

and find the last trade with direction out. The time of this trade will be the required time.

 
Desead:
At the beginning of OnCalculate there is a check of some condition. If the result is false, then I call return(0); how can I make this indicator stop working and unload itself?
ChartIndicatorDelete()
 
Thank you! So many questions disappeared at once. I've never looked into this section before
 

Hello.

Could you please tell me how to close a position without using the standard CTrade trade class? Is there such a function? Need to make a reverse buy/sell position on the market?

Thank you in advance.

 
RedFish:

Hello.

Could you please tell me how to close a position? Is there such a function? Need to do a reverse buy/sell position on the market?

Thank you in advance.

OrderSend
 
sergeev:
OrderSend
Can you elaborate on that. I'm sorry I didn't understand the answer.