Toute question des nouveaux arrivants sur MQL4 et MQL5, aide et discussion sur les algorithmes et les codes. - page 324

 

Est-ce correct ?

for(int i=1 ; i<=OrdersTotal() ; i++) // Boucle de commande

{

if(OrderSelect(i-1,SELECT_BY_POS)==true) // si ce qui suit se produit

{

int OT=OrdersTotal ; //le nombre d'ordres ouverts dans le terminal

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas [Price][OT] ; //tableau pour mettre en ordre tous les ordres

ou

for(int i=1 ; i<=OrdersTotal() ; i++) //boucle d'ordre

{

if(OrderSelect(i-1,SELECT_BY_POS)==true) // s'il existe un

{

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas [Price] ; //tableau pour classer toutes les commandes par prix ?

 
vikzip:

Est-ce correct ?

for(int i=1 ; i<=OrdersTotal() ; i++) // Boucle de commande

{

if(OrderSelect(i-1,SELECT_BY_POS)==true) // si ce qui suit se produit

{

int OT=OrdersTotal ; //le nombre d'ordres ouverts dans le terminal

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas [Price][OT] ; //tableau pour mettre en ordre tous les ordres

ou

for(int i=1 ; i<=OrdersTotal() ; i++) //boucle d'ordre

{

si (OrderSelect(i-1,SELECT_BY_POS)==true) // s'il existe un

{

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas [Price] ; //tableau pour classer toutes les commandes par prix ?

1) OrdersTotal renvoie le nombre total de commandes, mais elles sont numérotées à partir de zéro. C'est pourquoi la boucle doit être i < OrdersTotal()

2. Le tableau doit être déclaré double Mas[] ;. Si la commande est sélectionnée avec succès, la taille du tableau doit être augmentée, car nous ne savons pas combien de commandes il y a au total.

3. L'indice de la chaîne du tableau doit être entre crochets. Mas[i] = Prix ;

Par conséquent, les deux ont tort.

 
Alexey Viktorov:

1) OrdersTotal renvoie le nombre total de commandes mais elles sont numérotées à partir de zéro. C'est pourquoi la boucle devrait être i < OrdersTotal()

2. Le tableau doit être déclaré double Mas[] ;. Si un ordre est choisi avec succès, la taille du tableau doit être augmentée, car nous ne savons pas combien il y en a...

3. L'indice de la chaîne du tableau doit être entre crochets. Mas[i] = Prix ;

Par conséquent, les deux ont tort.


Merci beaucoup !

 
Alexey Viktorov:

1) OrdersTotal renvoie le nombre total de commandes, mais elles sont numérotées à partir de zéro. Par conséquent, la boucle doit être i < OrdersTotal()

2. Le tableau doit être déclaré double Mas[] ;. Si un ordre est choisi avec succès, la taille du tableau doit être augmentée, car nous ne savons pas combien il y en a...

3. L'indice de la chaîne du tableau doit être entre crochets. Mas[i] = Prix ;

Par conséquent, les deux ont tort.


Obtiendrons-nous un tableau unidimensionnel des prix des commandes dans ce cas ?

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas[i] = Price ; //tableau pour mettre en ordre tous les ordres

for(int i=1 ; i<OrdersTotal() ;) // Boucle d'ordre

{

if(OrderSelect(i-1,SELECT_BY_POS)==true) // s'il y a un suivant

i++ ;

}

 
vikzip:

Et dans ce cas, ce sera un tableau unidimensionnel de prix de commande ?

double Price=OrderOpenPrice() ; // Prix de l'ordre sélectionné

double Mas[i] = Price ; //tableau pour mettre en ordre tous les ordres

for(int i=1 ; i<OrdersTotal() ;) // Boucle d'ordre

{

if(OrderSelect(i-1,SELECT_BY_POS)==true) // s'il y a un suivant

i++ ;

}

Non. C'est plus ou moins comme ça.
  double Price;               // Цена выбранного ордера
  double Mas[];                      //массив для упорядочивания всех ордеров
  for(int i=0; i<OrdersTotal(); i++;)          // Цикл перебора ордер
   {
    if(OrderSelect(i,SELECT_BY_POS)==true) // Если есть следующий
     {
      ArrayResize(Mas, ArraySyze()+1);
      Mas[i] = OrderOpenPrice();
// или 
//    Price=OrderOpenPrice();
//    Mas[i] = Price;
     }
   }

La sélection ==vrai ne peut pas être écrite.

 
Alexey Viktorov:
Non. C'est plus ou moins comme ça.

La mise en évidence ==true ne peut pas être écrite.


Merci beaucoup !

 
L'après-midi, il y a une ligne pour sélectionner le bénéfice en devise. Je veux 1) avoir le choix dans les paramètres de l'EA entre un profit fixe (comme c'est déjà le cas) ou une partie du dépôt sous forme de pourcentage. Veuillez me conseiller sur la manière de procéder.
La chaîne originale est la suivante :

Double profit externe =10 ;

2) faire en sorte que l'autocompte du bénéfice soit activé, désactivé par le chiffre sélectionné du solde du compte.

En résumé :
Profit : fix/autocount.
Fixe - montant.
Autorate - pourcentage du solde.
Activer l'exécution automatique - % de bénéfice.
Désactiver la comptabilisation automatique - bénéfice/perte en %.
Sélectionnez la valeur à partir de laquelle les profits/pertes de l'auto-compte seront comptabilisés.
 

Salut. Pouvez-vous me dire comment supprimer la fermeture et l'ouverture d'un ordre en attente sur chaque barre ? J'ai besoin qu'il s'ouvre et attende que l'ordre correspondant s'ouvre.

//+------------------------------------------------------------------+
//|                                                e-News-Lucky$.mq4 |
//|                                                   Lucky$ & KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|   24.10.2005                                                     |
//| Выставление ордеров в определённое время на пробой диапазона.    |
//| Если ни один ордер не сработал, то модификация на каждом баре.   |
//+------------------------------------------------------------------+
#property copyright "Lucky$ & KimIV"
#property link      "http://www.kimiv.ru"
#define    MAGIC     123

//------- Внешние параметры советника --------------------------------
extern string _Parameters_Trade = "----- Параметры торговли";
extern double Lots           = 0.01;     // Размер торгуемого лота
extern int    StopLoss       = 0;      // Размер фиксированного стопа
extern int    TakeProfit     = 0;       // Размер фиксированного тэйка
extern string TimeSetOrders  = "10:30"; // Время установки ордеров
extern string TimeDelOrders  = "22:30"; // Время удаления ордеров
extern string TimeClosePos   = "22:30"; // Время закрытия позиций
extern int    DistanceSet    = 200;      // Расстояние от рынка
extern bool   UseTrailing    = True;    // Использовать трал
extern bool   ProfitTrailing = True;    // Тралить только профит
extern int    TrailingStop   = 25;      // Фиксированный размер трала
extern int    TrailingStep   = 5;       // Шаг трала
extern int    Slippage       = 3;       // Проскальзывание цены

extern string _Parameters_Expert = "----- Параметры советника";
extern string Name_Expert   = "e-News-Lucky$";
extern bool   UseSound      = True;         // Использовать звуковой сигнал
extern string NameFileSound = "expert.wav"; // Наименование звукового файла
extern color  clOpenBuy     = LightBlue;    // Цвет открытия покупки
extern color  clOpenSell    = LightCoral;   // Цвет открытия продажи
extern color  clModifyBuy   = Aqua;         // Цвет модификации покупки
extern color  clModifySell  = Tomato;       // Цвет модификации продажи
extern color  clCloseBuy    = Blue;         // Цвет закрытия покупки
extern color  clCloseSell   = Red;          // Цвет закрытия продажи

//---- Глобальные переменные советника -------------------------------
int prevBar;

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  if (TimeToStr(CurTime(), TIME_MINUTES)==TimeSetOrders) SetOrders();
  if (prevBar!=Bars && ExistOrder(1) && ExistOrder(2)) ModifyOrders();
  DeleteOppositeOrders();
  TrailingPositions();
  if (TimeToStr(CurTime(), TIME_DATE)==TimeDelOrders) DeleteAllOrders();
  if (TimeToStr(CurTime(), TIME_MINUTES)==TimeClosePos) CloseAllPositions();
  prevBar=Bars;
}

//+------------------------------------------------------------------+
//| Установка ордеров                                                |
//+------------------------------------------------------------------+
void SetOrders() {
  double ldStop=0, ldTake=0;
  int    spr=MarketInfo(Symbol(), MODE_SPREAD);
  double pAsk=Ask+(DistanceSet+spr)*Point;
  double pBid=Bid-DistanceSet*Point;

  if (!ExistOrder(1)) {
    if (StopLoss!=0) ldStop=pAsk-StopLoss*Point;
    if (TakeProfit!=0) ldTake=pAsk+TakeProfit*Point;
    SetOrder(OP_BUYSTOP, pAsk, ldStop, ldTake, 1);
  }
  if (!ExistOrder(2)) {
    if (StopLoss!=0) ldStop=pBid+StopLoss*Point;
    if (TakeProfit!=0) ldTake=pBid-TakeProfit*Point;
    SetOrder(OP_SELLSTOP, pBid, ldStop, ldTake, 2);
  }
}

//+------------------------------------------------------------------+
//| Модификация ордеров                                              |
//+------------------------------------------------------------------+
void ModifyOrders() {
bool ret;
  double ldStop=0, ldTake=0;
  int    spr=MarketInfo(Symbol(), MODE_SPREAD);
  double pAsk=Ask+(DistanceSet+spr)*Point;
  double pBid=Bid-DistanceSet*Point;

  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC+1) {
        if (StopLoss!=0) ldStop=pAsk-StopLoss*Point;
        if (TakeProfit!=0) ldTake=pAsk+TakeProfit*Point;
        ret=OrderModify(OrderTicket(), pAsk, ldStop, ldTake, 0, clModifyBuy);
      }
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC+2) {
        if (StopLoss!=0) ldStop=pBid+StopLoss*Point;
        if (TakeProfit!=0) ldTake=pBid-TakeProfit*Point;
        ret=OrderModify(OrderTicket(), pBid, ldStop, ldTake, 0, clModifySell);
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Возвращает флаг существования ордера или позиции по номеру       |
//+------------------------------------------------------------------+
bool ExistOrder(int mn) {
  bool Exist=False;
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC+mn) {
        Exist=True; break;
      }
    }
  }
  return(Exist);
}

//+------------------------------------------------------------------+
//| Возвращает флаг существования позиции по номеру                  |
//+------------------------------------------------------------------+
bool ExistPosition(int mn) {
  bool Exist=False;
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC+mn) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          Exist=True; break;
        }
      }
    }
  }
  return(Exist);
}

//+------------------------------------------------------------------+
//| Установка ордера                                                 |
//| Параметры:                                                       |
//|   op     - операция                                              |
//|   pp     - цена                                                  |
//|   ldStop - уровень стоп                                          |
//|   ldTake - уровень тейк                                          |
//|   mn     - добавить к MAGIC                                      |
//+------------------------------------------------------------------+
void SetOrder(int op, double pp, double ldStop, double ldTake, int mn) {
  bool ret;
  color  clOpen;
  string lsComm=GetCommentForOrder();

  if (op==OP_BUYSTOP) clOpen=clOpenBuy;
  else clOpen=clOpenSell;
  ret=OrderSend(Symbol(),op,Lots,pp,Slippage,ldStop,ldTake,lsComm,MAGIC+mn,0,clOpen);
  if (UseSound) PlaySound(NameFileSound);
}

//+------------------------------------------------------------------+
//| Генерирует и возвращает строку коментария для ордера или позиции |
//+------------------------------------------------------------------+
string GetCommentForOrder() {
  return(Name_Expert);
}

//+------------------------------------------------------------------+
//| Удаление всех ордеров                                            |
//+------------------------------------------------------------------+
void DeleteAllOrders() {
  bool fd;
  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderMagicNumber()>MAGIC && OrderMagicNumber()<=MAGIC+2) {
        if (OrderSymbol()==Symbol()) {
          if (OrderType()==OP_BUYSTOP || OrderType()==OP_SELLSTOP) {
            fd=OrderDelete(OrderTicket());
            if (fd && UseSound) PlaySound(NameFileSound);
          }
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Закрытие всех позиций по рыночной цене                           |
//+------------------------------------------------------------------+
void CloseAllPositions() {
  bool fc;
  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderMagicNumber()>MAGIC && OrderMagicNumber()<=MAGIC+2) {
        if (OrderSymbol()==Symbol()) {
          fc=False;
          if (OrderType()==OP_BUY) {
            fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy);
          }
          if (OrderType()==OP_SELL) {
            fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);
          }
          if (fc && UseSound) PlaySound(NameFileSound);
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Удаление противоположных ордеров                                 |
//+------------------------------------------------------------------+
void DeleteOppositeOrders() {
  bool fd, fep1, fep2;

  fep1=ExistPosition(1);
  fep2=ExistPosition(2);

  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol()) {
        fd=False;
        if (OrderType()==OP_BUYSTOP && OrderMagicNumber()==MAGIC+1) {
          if (fep2) fd=OrderDelete(OrderTicket());
        }
        if (OrderType()==OP_SELLSTOP && OrderMagicNumber()==MAGIC+2) {
          if (fep1) fd=OrderDelete(OrderTicket());
        }
        if (fd && UseSound) PlaySound(NameFileSound);
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Сопровождение позиции простым тралом                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderMagicNumber()>MAGIC && OrderMagicNumber()<=MAGIC+2) {
        if (OrderSymbol()==Symbol()) {
          if (OrderType()==OP_BUY) {
            if (!ProfitTrailing || (Bid-OrderOpenPrice())>TrailingStop*Point) {
              if (OrderStopLoss()<Bid-(TrailingStop+TrailingStep-1)*Point) {
                ModifyStopLoss(Bid-TrailingStop*Point, clModifyBuy);
              }
            }
          }
          if (OrderType()==OP_SELL) {
            if (!ProfitTrailing || OrderOpenPrice()-Ask>TrailingStop*Point) {
              if (OrderStopLoss()>Ask+(TrailingStop+TrailingStep-1)*Point || OrderStopLoss()==0) {
                ModifyStopLoss(Ask+TrailingStop*Point, clModifySell);
              }
            }
          }
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Перенос уровня StopLoss                                          |
//| Параметры:                                                       |
//|   ldStopLoss - уровень StopLoss                                  |
//|   clModify   - цвет модификации                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStop, color clModify) {
  bool   fm;
  double ldOpen=OrderOpenPrice();
  double ldTake=OrderTakeProfit();

  fm=OrderModify(OrderTicket(), ldOpen, ldStop, ldTake, 0, clModify);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+

 

Bonjour. Est-ce que quelqu'un ici utilise des indicateurs de ClasterDelta dans son travail ? J'ai une question sur l'utilisation automatique des données de l'indicateur VolumeProfile. Le fait est que cet indicateur ne renvoie rien, mais dessine seulement un histogramme de lignes de tendance. Mais en plaçant le curseur sur cette ligne, la valeur du volume négocié sur ce tick apparaîtra. Comment faire sortir ces informations de l'indicateur !

Des idées ?

 

Comme je l'ai déjà rencontré en étudiant les cours, il y a encore des nuances qui ne sont pas décrites dans les articles ou qui sont tellement cachées qu'il n'est pas possible de les trouver avec un moteur de recherche. Une journée entière passée à chercher en vain des explications. Par exemple, ce que ce symbole signifie et comment il affecte si non. Comme on le voit ci-dessous dans l'exemple du stati, d'abord il est là et ensuite il ne l'est plus : &.

   // Для int. Проверка существования в массиве элемента с заданным значением
   int Find(int & aArray[],int aValue)
     {
      for(int i=0; i<ArraySize(aArray); i++) 
        {
         if(aArray[i]==aValue) 
           {
            return(i); // Элемент существует, возвращаем индекс элемента
           }
        }
      return(-1); // Нет такого элемента, возвращаем -1
     }

Ce symbole n'est pas clair non plus quant à sa signification : ~

   // Конструктор
                     CName() { Alert("Конструктор"); }
   // Деструктор
                    ~ CName() { Alert("Деструктор"); }

*

CInfo * returnInfo()
  {
   CInfo * i = new CInfo();
   i.symbol=_Symbol;

   return i;
  }
Raison: