Une question pour les experts MQL - page 2

 
printemps
 
Les gars, merci beaucoup à tous, je vais voir ce qui convient. Printemps ....
 

Je m'excuse pour cette question qui pourrait être incorrecte !

Je suis actuellement en train de traiter le code EA décompilé. Je ne peux pas "entrer" dans un morceau de code.

//-----------------------------------------------------------      
int TotalSell() {  int count=0;
   for (int i=0; i<OrdersTotal(); i++) {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_SELL) count++;}return (count);}
//------------------------------------------------------------      
int TotalSellStop() { int count=0;
   for (int i=0; i<OrdersTotal(); i++){
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_SELLSTOP) count++;} return (count);}
//-------------------------------------------------------------------

Veuillez décoder (en russe) ligne par ligne cette construction obscure (haut ou bas) pour moi ?

En général, le "concept" de ce conseiller expert, je l'ai compris. Initialement, deux ordres en attente sont définis - Buy Stop et Sell Stop. Lorsque l'un des ordres en attente se déclenche, le second est supprimé. Mais, en même temps, un stop suiveur est fixé sur la position ouverte et le stop-loss suiveur opposé est fixé à la place du prix du stop-loss !

 
//-----------------------------------------------------------      
int TotalSell() {  int count=0;                                    //Функция возвращающая количество устаноавленныых SELL ордеров 
   for (int i=0; i<OrdersTotal(); i++) {                           //задается цикл от ноля до общего количества всех ордеров 
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;        //Выбирается ордер по позиции из списка, если не выбран - выход
      if (OrderSymbol()!=Symbol()) continue;                       //Сравнивается по символу, если соответствует - продолжить 
      if (OrderType()==OP_SELL) count++;}return (count);}          //Сравнивается по типу SELL, если соответствует то увеличивает счетчик ордеров на 1
//------------------------------------------------------------      
int TotalSellStop() { int count=0;                                 //Тоже что и предидущая функция но для SELLSTOP ордеров
   for (int i=0; i<OrdersTotal(); i++){
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderType()==OP_SELLSTOP) count++;} return (count);}
//-------------------------------------------------------------------

C'est tout ce qu'il y a à faire

 
Merci, xeon!
 

Bonsoir à tous ! Un besoin s'est fait sentir.

Pour utiliser un script qui inverse les positions ouvertes.

À ma grande surprise, j'ai découvert que le script ne fonctionne pas pour une raison quelconque ! J'ai essayé de comprendre, mais ..... Cela ne fonctionne pas.

Et là, apparemment, - l'auteur trop spirituel a obtenu la conception ..., inséré des commentaires d'accompagnement stupides.

/ Развернуть все ордера.mq4
// Скрипт
#property copyright "mandorr@gmail.com"
#include <WinUser32.mqh>
void start()
{
   int i=0, count=0;
   //закладываем массивы значений
   int cmd[];
   int ticket[];
   double lots[];
   string symbol[];
   string type[];
//------------------------------------------------------------   
   for (i=0; i<OrdersTotal(); i++)           {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderType()==OP_BUY || OrderType()==OP_SELL)      {
         ArrayResize(cmd,count+1); 
         ArrayResize(ticket,count+1); 
         ArrayResize(lots,count+1); 
         ArrayResize(symbol,count+1); 
         ArrayResize(type,count+1); 
         cmd[count]=OrderType();
         ticket[count]=OrderTicket();
         lots[count]=OrderLots();
         symbol[count]=OrderSymbol();
         if (OrderType()==OP_BUY) type[count]="Buy";//если открыта длинная позиция
         // заносим её в массив "Buy"
         else type[count]="Sell";// иначе в массив "Sell"
         count++;                                            }
   }
//---------------------------------------------------------------   
   string space="    ";
   string title="Кароче_В_натуре";
   string msg="Развернуть:"+"\n";
   for (i=0; i<count; i++) msg=msg+"\n"+"Order "+ticket[i]+" "+type[i]+" "+DoubleToStr(lots[i],1)+" Lots "+symbol[i]+space;
   if (MessageBox(msg,title,MB_YESNO|MB_ICONQUESTION)!=IDYES)
   {
      title="Аха";
      string ends=""; if (count>1) ends="и";
      msg="Ну и хрен с ним"+ends+" ...    "; 
      MessageBox(msg,title,MB_OK|MB_ICONEXCLAMATION);
      return;
   }
   for (i=0; i<count; i++)
   {
      if(!OrderSelect(ticket[i],SELECT_BY_TICKET)) continue;
      double ask=MarketInfo(symbol[i],MODE_ASK);
      double bid=MarketInfo(symbol[i],MODE_BID);
      int slippage=3;
      if (cmd[i]==OP_BUY )
      {
         OrderClose(ticket[i],lots[i],bid,slippage);
         OrderSend(symbol[i],OP_SELL,lots[i],bid,slippage,0,0,NULL,0,0);
      }
      if (cmd[i]==OP_SELL)
      {
         OrderClose(ticket[i],lots[i],ask,slippage);
         OrderSend(symbol[i],OP_BUY ,lots[i],ask,slippage,0,0,NULL,0,0);
      }
   }
}
// End
Pouvez-vous me dire pourquoi ça ne fonctionne pas ?
 
// Развернуть все ордера.mq4
C'est bizarre, tout fonctionne, mais ce ne serait pas une mauvaise chose de le rendre ainsi :
 

Ce n'est pas la question. J'ai mis le script sur le graphique (Alpari demo). J'appuie sur le bouton "OUI" dans la fenêtre qui apparaît, mais rien ne se passe. Les positions ne sont pas inversées. Dans le carnet de bord au moment de la pression

2008.04.29 01:15:41 Script Revers__all_orders EURJPY,M15 : supprimé

 

Bon après-midi. Veuillez écrire une expression iCustom pour cet indicateur :



Voici son code -

#property indicator_chart_window
#property indicator_buffers 2

//---- input parameters
extern int R=3;
//---- buffers
double HighBuffer[];
double LowBuffer[];
double VALUE1,VALUE2,VALUE11,VALUE22;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_ARROW,EMPTY,1,Blue);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,1,Yellow);
   SetIndexArrow(0, 0x9F);
   SetIndexArrow(1, 0x9F);

   SetIndexBuffer(0,HighBuffer);
   SetIndexBuffer(1,LowBuffer);

   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
//---- name for DataWindow and indicator subwindow label
   short_name="HiLo";
   IndicatorShortName(short_name);
   SetIndexLabel(0,short_name);
//----
   SetIndexDrawBegin(0,10);
   SetIndexDrawBegin(1,10);
//----
   return(0);
  }
//+-----------------------------------------------------+
int deinit()
  {
//---- TODO: add your code here
ObjectsDeleteAll(0);   
//----
   return(0);
  }
//+-------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted(),i,shift,Swing;   

//---- TODO: add your code here
i=(Bars-counted_bars)-1;

for (shift=i; shift>=0;shift--)  {

VALUE1=iMA(NULL,0,R,0,MODE_SMA,PRICE_HIGH,shift+1);
VALUE2=iMA(NULL,0,R,0,MODE_SMA,PRICE_LOW,shift+1);

if (Close[shift+1]<VALUE2 ) Swing=-1;
if (Close[shift+1]>VALUE1 ) Swing=1;

if (Swing==1) { HighBuffer[shift]=VALUE2; LowBuffer[shift]=0;  }
if (Swing==-1) { LowBuffer[shift]=VALUE1; HighBuffer[shift]=0; }
//----
}
   return(0);
  }
Pour pouvoir définir le paramètre R dans les "propriétés" et le numéro de la barre, bien sûr.
 

Oui, un peu comme ça, si on considère que le nom de l'indicateur est hilo.mq4 :

extern int iR=3;
extern int SignalBar=1;
//.......
//---получение значения HighBuffer
double buy = iCustom( NULL,0, "hilo",
iR,
0, // № буффера
SignalBar ); // № бара

//---получение значения LowBuffer
double sell = iCustom( NULL,0, "hilo",
iR,
1, // № буффера
SignalBar ); // № бара
Raison: