Comment savoir si le marché est fermé ? (mql4) - page 9

 
Vasyl Nosal:

C'est un désir persistant de tromper et de se tromper soi-même :) .

Ajouté : Avez-vous essayé d'afficher tous les symboles et d'afficher la colonne "Temps" dans la fenêtre "Aperçu du marché" et de découvrir le symbole bitcoin qui s'échange sans interruption ? De plus, un tel contrôle de base est également utile :

1

2

3

 

Ce n'est pas une solution universelle, mais elle fonctionne pour moi.


bool CanTrade()
{

bool res1=IsTradeAllowed(Symbol(), TimeCurrent());
bool res2=IsTradeAllowed(Symbol(), TimeCurrent()+4000); //с запасом,

if (!res1) return false; //сейчас торговать запрещено
if (res1 && res2) return true; //и сейчас и через час торговать можно
return false; //если зависло разрешение от TimeCurrent, то через час (или с запасом в несколько минут) покажет фалсе.
// Но наверняка есть ситуации когда реально сейчас можно торговать а через час нельзя - тогда неправильный ответ :(
}

 
Igor-san:

Mais il y a sûrement des situations où vous pouvez vraiment négocier maintenant et pas dans une heure...

Bien sûr qu'il y en a - chaque fois une heure avant la fermeture du marché ))))
 
Ihor Herasko:
Bien sûr que si - chaque fois une heure avant la fermeture du marché ))))

Je ne suis pas d'accord. La dernière date figée sur l'écran est le vendredi 21:59. Si je règle le décalage à 3600 sec - le deuxième paramètre IsTradeAllowed(Symbol(), TimeCurrent()+3600 renvoie trude. J'ai ajouté quelques secondes supplémentaires pour que ça marche. Si on est vendredi à 21 h 50, tout devrait fonctionner.

Pour être honnête, je ne l'ai pas vérifié, j'ai juste vérifié la connexion à broker Reconnector (trouvé sur le forum quelque part), qui se reconnectait constamment le week-end. Ce n'est donc pas important pour moi.

 
/// Ждём разрешения торговать
void TradeAllowed()
{
symb=Symbol();/// Текущий символ или символ на котором нужно произвести проверку

if(!AccountInfoInteger(ACCOUNT_TRADE_EXPERT))
   {Print("Automated trading is forbidden at the trade server side");return;}
if(!AccountInfoInteger(ACCOUNT_TRADE_ALLOWED)) 
   {Print("Trading is forbidden!");return;}
if (!TerminalInfoInteger(TERMINAL_TRADE_ALLOWED))  
   {Print("Check if automated trading is allowed in the terminal settings!");return;}
if(!IsTradeAllowed(symb,TimeLocal())
   {Print("Trading on the symbol "+symb+" is forbidden!");return;}

while(IsTradeContextBusy())
   {
   if(IsStopped()) {Print("Forced shutdown ");break;}
   Print("Trading is occupied. Wait.");
   Sleep(1000);
   RefreshRates(); 
   }  
}
 

bool MarketOpen(string Symbl)
{
   if(IsTradeAllowed(Symbl,TimeCurrent()+1)==false)return(false); //рынок закрыт

   return(true);

}

 
Renat Akhtyamov:

bool MarketOpen(string Symbl)
{
   if(IsTradeAllowed(Symbl,TimeCurrent()+1)==false)return(false); //рынок закрыт

   return(true);

}

Cela varie, donc ce contrôle ne garantit rien.

Le commerce par les experts est donc interdit, mais le marché est ouvert.


En ce moment, lundi, le marché est ouvert et les experts sont interdits par le bureau :


 
Au contraire, il arrive que dans certains autres bureaux, le week-end, lorsque le marché est fermé, ces contrôles indiquent que le marché est ouvert et que les experts ont reçu l'autorisation de négocier.
 
Олег avtomat:
Au contraire, il arrive que dans certains autres bureaux, le week-end, lorsque le marché est fermé, ces contrôles indiquent que le marché est ouvert et que les experts ont reçu l'autorisation de négocier.

hier.

Pour l'instant, ça marche,

Celui-ci ne le fait pas :

Forum sur le trading, les systèmes de trading automatisé et les tests de stratégies de trading

Comment puis-je savoir qu'il n'y a pas de commerce le week-end ?

Renat Akhtyamov, 2018.02.11 05:27

MERCI !

Pour MT4.

//------------------------------------------------------------------    IsSessionOpen
bool IsSessionOpen(string smb)
{
     //MqlDateTime dt; datetime tc=TimeTradeServer(dt);
      datetime tc= TimeCurrent();
     // проверяем время торгов по инструменту
     datetime t=(datetime)SymbolInfoInteger(smb, SYMBOL_EXPIRATION_TIME);
     if (tc>t && t>0) return(false);
     t=(datetime)SymbolInfoInteger(smb, SYMBOL_START_TIME);
     if (tc<t && t>0) return(false);
     
     // проверяем сессии инструмента
     datetime ds=tc/(60*60*24); ds*=(60*60*24); // начало сегодня
     datetime sec=tc-ds; // число секунд от начала дня
     bool b=false;
     for (int l=0; l<10; l++) // подразумеваем, что админ сделал не более 10 сессий в сутки
     {
             datetime fs, ts;
             if (!SymbolInfoSessionTrade(smb, TimeDayOfWeek(TimeCurrent()), l, fs, ts)) break; // данные сессии
             if (sec>=fs && sec<=ts) return(true);
     }
     return(false);
}



 

il y a quelque chose à propos de la fonction 5p qui ne fonctionne pas :

(Je me demande pourquoi ? ??)

https://www.mql5.com/ru/docs/standardlibrary/tradeclasses/cterminalinfo/cterminalinfoistradeallowed

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