[ARCHIVE] Toute question de débutant, afin de ne pas encombrer le forum. Professionnels, ne passez pas à côté. Nulle part sans toi - 3. - page 94

 

Salutations à tous !

Veuillez m'aider à résoudre ce problème : je n'arrive pas à faire en sorte que l'indicateur se redessine à l'apparition d'une nouvelle barre (intervalle D). П

//+------------------------------------------------------------------+
//|                                                 Demark Lines.mq4 |
//|                      Copyright © 2011, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2011, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_chart_window
#property indicator_buffers 2       // Количество буферов
#property indicator_color1 Green     // Цвет первой линии
#property indicator_color2 Red      // Цвет второй линии

double Buf_UP[],Buf_DN[];             // Объявление массивов (под буферы индикатора)

extern int History=21;        // Колич.баров в расчётной истории
extern int M= 3;           // начальный бар с которого начинаем поиск фракталов в цикле.
int    i,k;                // номера баров в циклах.
int    Vnf3,Vnf2,Vnf1;     // номера реперных фракталов (1-ый справа на графике на нисходящем тренде).
int    VnfL3,VnfL2,VnfL1;  // номера реперных фракталов (1-ый справа на графике на восходящем тренде).
int    VFN,VFNL;           // счетчик найденных фракталов.
int    Md,MdL;             // счетчики кол-ва модификаций
int counted_bars;
double VMF1,VMF2;     // промежуточные значения верхних фракталов на нисходящем тренде.
double VMFL1,VMFL2;  // промежуточные значения нижних фракталов на восходящем тренде.
double VlFl_L;             // Min значение ближайшего нижнего фрактала на тренде вниз
double VlFl_H;             // Max значение ближайшего верхнего фрактала на тренде вверх
datetime tim1_L;           // Время ближайшего нижнего фрактала после нисходящего тренда 
datetime timL1_H;          // Время ближайшего верхнего фрактала после восходящего тренда 

datetime tim1,tim2,tim3;   // время для построения линий вилки Чувашова.
datetime timL1,timL2,timL3;// время для построения линий вилки Чувашова.

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   SetIndexBuffer(0,Buf_UP);         // Назначение массива буферу
   SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1);// Стиль линии
   SetIndexBuffer(1,Buf_DN);         // Назначение массива буферу
   SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,1);// Стиль линии
   
   counted_bars=IndicatorCounted();
   return;                          // Выход из спец. ф-ии init()

  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  int limit=counted_bars;
  counted_bars=IndicatorCounted();
   if (counted_bars!=limit)
      {int Razmer=ArraySize(Buf_DN);
       for (i=Razmer;i>=0;i--)
         {Buf_DN[i]=0;
         }
         Razmer=ArraySize(Buf_UP);
         for (i=Razmer;i>=0;i--)
         {Buf_UP[i]=0;
         }
       }  
//----
   for (i=2;i<=History;i++)
    {//цикл
    if(High[i]>High[i+1] &&High[i]>High[i-1]&&High[i]>Close[i-2])
     {//фрактал
      VFN++;           // счетчик найденного фрактала.
      // ------------------------------------------------------------+
      if(VFN==1)       // если 1-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
        {// f1
           Vnf1=i;        // запоминаем номер Max бара найденного фрактала.
           VMF1=High[i];  // запоминаем Max значение 1-ого найденного фрактала.
           tim1=iTime(NULL,0,i);        // запоминаем время 1-ой опорной точки.
         }//-f1
    // --------------------------------------------------------------+
    if(VFN==2)        // если 2-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
      {// f2
          VMF2=High[i];    // запоминаем Max значение 2-ого найденного фрактала.
          if(VMF2>VMF1)    // если Max значение 2-го фрактала больше 1-го (т.е. направлена вниз),
            {
              Vnf2=i;      // запоминаем номер Max бара найденного фрактала.
              tim2=iTime(NULL,0,i);      // запомним время 2-ой опорной точки.
            }
            else VFN=VFN-1;
       }//-f2
    // --------------------------------------------------------------+
   
    

// ------------------------------------------------------------------+
   if(VFN==2) break; // найдены все 2 фрактала, выходим из цикла.
// ------------------------------------------------------------------+ 
    }//-фрактал                      
   }//-цикл 
//----
 //int k=0;
   
  
  


for (i=2;i<=History;i++)
    {//цикл
    if(Low[i]<Low[i+1] &&Low[i]<Low[i-1]&&Low[i]<Close[i-2])
     {//фрактал
      VFNL++;           // счетчик найденного фрактала.
      // ------------------------------------------------------------+
      if(VFNL==1)       // если 1-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
        {// f1
           VnfL1=i;        // запоминаем номер Max бара найденного фрактала.
           VMFL1=Low[i];  // запоминаем Max значение 1-ого найденного фрактала.
           
           timL1=iTime(NULL,0,i);        // запоминаем время 1-ой опорной точки.
         }//-f1
    // --------------------------------------------------------------+
    if(VFNL==2)        // если 2-ый фрактал найден, запоминаем значения: Max[i], № свечи[i], время[i]:
      {// f2
          VMFL2=Low[i];    // запоминаем Max значение 2-ого найденного фрактала.
          if(VMFL2<VMFL1)    // если Max значение 2-го фрактала больше 1-го (т.е. направлена вниз),
            {
              VnfL2=i;      // запоминаем номер Max бара найденного фрактала.
              timL2=iTime(NULL,0,i);      // запомним время 2-ой опорной точки.
            }
            else VFNL=VFNL-1;
       }//-f2
    // --------------------------------------------------------------+

// ------------------------------------------------------------------+
   if(VFN==2) break; // найдены все 2 фрактала, выходим из цикла.
// ------------------------------------------------------------------+ 
    }//-фрактал                      
   }//-цикл 

 //_________________________________Отрисовка индикатора_________________________________________________
  
  if (Vnf1<VnfL1&&Vnf2!=0)               // если ближайший фрактал - вверх
 
  {int k=Vnf2;
   for (i=Vnf2;i>=0;i--)
    {
     Buf_DN[i]= EquationDirect(Vnf2, VMF2, Vnf1,VMF1,k);
     k--;
    }}
   if (VnfL1<Vnf1&&VnfL2!=0)       //если ближайший фрактал - вниз
 
 {k=VnfL2;
   for (i=VnfL2;i>=0;i--)
    {
     Buf_UP[i]= EquationDirect(VnfL2, VMFL2, VnfL1,VMFL1,k);
     k--;
    }}
 //_____________________________________________________________________________________________________
    

   return(0);
  }
//+------------------------------------------------------------------+


  
   double EquationDirect(double x1, double y1, double x2, double y2, double x) //прямая линия
   {
if (x2==x1) return(y1);
return((y2-y1)/(x2-x1)*(x-x1)+y1);}

Je dois le redémarrer manuellement.

 
phh200400:
est-il possible de télécharger l'indicateur d'onde zolliot ?

Bien sûr que vous pouvez. Vous devez trouver et télécharger
 
Une chaîne de recherche google :
indicateur de vague zlliot site:mql4.com
 

Merci, splxgf ! !!!!!!!!!!!!!!

Plus précisément, ici si ( OrderType( )==OP_BUY && OrderType( )==OP_SELL )

Bien sûr, l'ordre peut être à la fois d'achat et de vente, mais je mettrais ||.

LOL ! !! Oui, je l'ai fait... Pour de vrai...

if (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)<0.5*Point)


Je recommande de clarifier qui est le point et pourquoi il est multiplié par 0.5 ? C'est juste que la variante sans doublet de normalisation n'est pas si fiable si on la compare à zéro. Ici, ça marche.

Ticket est un type entier, OrderClose est booléen... Il vaut mieux ne pas le faire de cette façon.

La boucle while est infinie et seuls les ordres de marché sont supprimés, s'il y en a un en attente, cette musique sera éternelle. Merci ! !! ! !!!


 

Les gars, dites-moi la différence ? ????

si(OrderSymbol()!=Symbol())continuer ;

и

si(OrderSymbol()==Symbol())

? ??????????

 

Ouais, je ne sais pas... Eh bien, continue;devrait envoyer à la boucle précédente, et elle peut probablement continuer jusqu'à ce qu'elle corresponde, selon la façon dont elle est écrite.

Aide ! !!!!!! (mon post sur la page précédente) !

 
//+------------------------------------------------------------------+
//|             AsctrendBuySellExpert_v1.mq4  code by Newdigital     |
//|                                     https://www.forex-tsd.com     |
//|                using Gordago software http://www.gordago.com     |
//| - Asctrend code for this EA was taken from                       |
//|   AscTrend_NonLag EA coded by of Igorad.                         |
//| - "Non-Trading Hours" on the screen fixing code by Locutus       |
//|   from Updated DayTradingMM EA                                   |
//+------------------------------------------------------------------+
#property copyright "newdigital"
#property link      "https://www.forex-tsd.com"

#include <stderror.mqh> // библиотека ошибок
#include <stdlib.mqh>
extern int MAGIC  = 100111;

extern string PARAMETERS_EXPERT = "PARAMETERS EXPERT";
extern color clOpenBuy = Blue;
extern color clCloseBuy = Aqua;
extern color clOpenSell = Red;
extern color clCloseSell = Violet;
extern color clModiBuy = Blue;
extern color clModiSell = Red;
extern string Name_Expert = "AsctrendBuySellExpert";
extern bool UseSound = False;
extern string NameFileSound = "alert.wav";

extern string PARAMETERS_FILTER = "PARAMETERS FILTER";
extern bool UseHourTrade = False;
extern int FromHourTrade = 8;
extern int ToHourTrade = 18;


extern string PARAMETERS_TRADE = "PARAMETERS TRADE";
extern double Lots = 0.10;
extern int Slippage = 4;
extern double lStopLoss = 1000;
extern double sStopLoss = 1000;
extern double lTakeProfit = 1000;
extern double sTakeProfit = 1000;
extern double lTrailingStop = 1000;
extern double sTrailingStop = 1000;

extern string PARAMETERS_INDICATOR_ONE  = "ASCTrend";
extern bool    UseASCtrend    = True;
extern int     RISK           = 3;
int asctrend,asctrend1;
int ASCtrend,ASCtrend1;



void deinit() {
   Comment("");
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int start(){
   if (UseHourTrade){
   if((Hour()>=FromHourTrade)&&(Hour()<=ToHourTrade))
      Comment("Trading Hours");
   else
     {
      Comment("Non-trading Hours");
      return(0);
     }
   }
   if(Bars<100){
      Print("bars less than 100");
      return(0);
   }
   if(lStopLoss<10){
      Print("StopLoss less than 10");
      return(0);
   }
   if(lTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
   if(sStopLoss<10){
      Print("StopLoss less than 10");
      return(0);
   }
   if(sTakeProfit<10){
      Print("TakeProfit less than 10");
      return(0);
   }
   
   if (UseASCtrend)
{
ASCtrend = ASCTrend(RISK);
bool ASCtrendBuy  = ASCtrend>0 && ASCtrend1<0;  
bool ASCtrendSell = ASCtrend<0 && ASCtrend1>0;
} 
else {ASCtrendBuy = true; ASCtrendSell = true;}

   if(AccountFreeMargin()<(1000*Lots)){
      Print("We have no money. Free Margin = ", AccountFreeMargin());
      return(0);
   }
   if (!ExistPositions()){

      if ((ASCtrendBuy)){
         OpenBuy();
         return(0);
      }

      if ((ASCtrendSell)){
         OpenSell();
         return(0);
      }
   }
   if (ExistPositions()){
      if(OrderType()==OP_BUY){

         if ((ASCtrendSell)){
            CloseBuy();
            return(0);
         }
      }
      if(OrderType()==OP_SELL){

         if ((ASCtrendBuy)){
            CloseSell();
            return(0);
         }
      }
   }
   TrailingPositionsBuy(lTrailingStop);
   TrailingPositionsSell(sTrailingStop);
   ASCtrend1=ASCtrend;
   return (0);
}

bool ExistPositions() {
        for (int i=0; i<OrdersTotal(); i++) {
                if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
                        if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
                                return(True);
                        }
                } 
        } 
        return(false);
}
void TrailingPositionsBuy(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { 
            if (OrderType()==OP_BUY) { 
               if (Bid-OrderOpenPrice()>trailingStop*Point) { 
                  if (OrderStopLoss()<Bid-trailingStop*Point) 
                     ModifyStopLoss(Bid-trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void TrailingPositionsSell(int trailingStop) { 
   for (int i=0; i<OrdersTotal(); i++) { 
      if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { 
         if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) { 
            if (OrderType()==OP_SELL) { 
               if (OrderOpenPrice()-Ask>trailingStop*Point) { 
                  if (OrderStopLoss()>Ask+trailingStop*Point || OrderStopLoss()==0)  
                     ModifyStopLoss(Ask+trailingStop*Point); 
               } 
            } 
         } 
      } 
   } 
} 
void ModifyStopLoss(double ldStopLoss) { 
   bool fm;
   fm = OrderModify(OrderTicket(),OrderOpenPrice(),ldStopLoss,OrderTakeProfit(),0,CLR_NONE); 
   if (fm && UseSound) PlaySound(NameFileSound); 
} 

void CloseBuy() { 
   bool fc; 
   fc=OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy); 
   if (fc && UseSound) PlaySound(NameFileSound); 
} 
void CloseSell() { 
   bool fc; 
   fc=OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell); 
   if (fc && UseSound) PlaySound(NameFileSound); 
} 
void OpenBuy() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 
   ldLot = GetSizeLot(); 
   ldStop = GetStopLossBuy(); 
   ldTake = GetTakeProfitBuy(); 
   lsComm = GetCommentForOrder(); 
   BroCoOrderSend(Symbol(),OP_BUY,ldLot,Ask,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenBuy); 
   if (UseSound) PlaySound(NameFileSound); 
} 
void OpenSell() { 
   double ldLot, ldStop, ldTake; 
   string lsComm; 

   ldLot = GetSizeLot(); 
   ldStop = GetStopLossSell(); 
   ldTake = GetTakeProfitSell(); 
   lsComm = GetCommentForOrder(); 
   BroCoOrderSend(Symbol(),OP_SELL,ldLot,Bid,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpenSell); 
   if (UseSound) PlaySound(NameFileSound); 
} 
string GetCommentForOrder() {   return(Name_Expert); } 
double GetSizeLot() {   return(Lots); } 
double GetStopLossBuy() {       return (Bid-lStopLoss*Point);} 
double GetStopLossSell() {      return(Ask+sStopLoss*Point); } 
double GetTakeProfitBuy() {     return(Ask+lTakeProfit*Point); } 
double GetTakeProfitSell() {    return(Bid-sTakeProfit*Point); }

int ASCTrend( int risk )
{

   double smin, smax, bsmin, bsmax;
   int len = 3 + 2*risk;
   
   smin=Low[Lowest(NULL,0,MODE_LOW,len,1)]; 
   smax=High[Highest(NULL,0,MODE_HIGH,len,1)];

   bsmax = smax-(smax - smin)*(33.0-risk)/100.0;
   bsmin = smin+(smax - smin)*(33.0-risk)/100.0;

   asctrend = asctrend1;
   
   if(Close[1]>bsmax)  asctrend= 1; 
   if(Close[1]<bsmin)  asctrend=-1;
   
   asctrend1 = asctrend;
  return(asctrend);
}    
//+------------------------------------------------------------------+
//| Функция для работы с дилинговым центром BroCo                    |
//+------------------------------------------------------------------+
int BroCoOrderSend(string symbol, 
                 int cmd, 
                 double volume, 
                 double price, 
                 int slippage, 
                 double stoploss, 
                 double takeprofit, 
                 string comment, 
                 int magic, 
                 datetime expiration, 
                 color arrow_color)
{
   int ticket = OrderSend(symbol,cmd, volume, price, slippage, 0, 0, comment, magic, expiration, arrow_color);   
   int check = -1;
   if (ticket > 0 && (stoploss != 0 || takeprofit != 0)) {
      if (!OrderModify(ticket, price, stoploss, takeprofit,expiration, arrow_color)) {
         check = GetLastError();
         if (check != ERR_NO_ERROR) {
            Print("OrderModify error: ", ErrorDescription(check));
         }
      }
   } else {
      check = GetLastError();
      if (check != ERR_NO_ERROR){
         Print("OrderSend error: ",ErrorDescription(check));
      }
   }
   return (ticket);
}  
  
//----------------------------------------------------------------
Bonjour à tous ! Je suis tombé sur un vieil expert travaillant avec l'indicateur asctrend. J'aimerais vérifier comment cet indicateur se comporte en temps réel, mais je ne peux pas toujours suivre les points et mon trading n'est pas complet. J'ai vérifié le testeur, il y a un signal à chaque point, mais je l'ai mis sur une démo et j'ai remarqué la chose que la démo saute des signaux, alors que le journal n'a pas écrit quoi que ce soit à l'expert, creuser dans le code et n'a pas compris ce que le problème :( peut-être quelqu'un poke un nez dans ce qui peut être le problème ?
 
if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
      if (NormalizeDouble(OrderClosePrice()-OrderTakeProfit(), Digits)<0.5*Point) {
         Alert("Позиция с тикетом #",OrderTicket()," закрыта по TakeProfit, закрываем остальные прозиции и удаляем отложенные ордера");
         // Здесь код для закрытия всех открытых позиций (тоже в цикле)
         for (  int y=OrdersTotal()-1; y>=0; y--) {Alert ("Здесь код для закрытия всех открытых позиций (тоже в цикле)",y);
           OrderSelect(y, SELECT_BY_POS );
              if (  OrderType( )==OP_BUY || OrderType( )==OP_SELL ){
                          OrderClose( OrderTicket( ), OrderLots( ), OrderClosePrice( ) , 0, CLR_NONE);
   Alert ("OrderClose-vse-2",  GetLastError( ) ); C=0;A=1; }} 
         // Здесь код для удаления всех отложенных ордеров (также в цикле)
         for ( int f=OrdersTotal()-1; f>=0; f--) {Alert("Здесь код для удаления всех отложенных ордеров (также в цикле)",f);
         OrderSelect(f, SELECT_BY_POS );
           if (  OrderType( )==OP_BUYSTOP || OrderType( )==OP_SELLSTOP ){ 
            OrderDelete(OrderTicket( )) ; Alert ("OrderDelete-vse-2",  GetLastError( ) ); }}   // CloseAll();
         }
      }
J'ai écrit jusqu'à présent, et seul le premier message d'alerte est enregistré.
 

MetaEditor a cessé de fonctionner après avoir réinstallé le terminal. Cela ne fonctionne que si vous ne changez rien au code de l'indicateur. Si vous modifiez quelque chose, même la couleur de la ligne, cela génère une erreur :

Le système d'exploitation est Windows 7. Qui sait, peut-être que quelqu'un a rencontré un tel problème. Pouvez-vous me dire ce qu'il faut faire ?

 
Long code les gars ! Je tiens à rappeler que le code de quelqu'un d'autre est avant tout un cryptogramme, qui reste à déchiffrer ! Et c'est beaucoup de travail ! Pensez-vous qu'un programmeur ait envie de fouiller dans des kilomètres de listes ? Permettez-moi de donner mon code à l'un d'entre vous pour trois mille lignes seulement et de lui demander d'éliminer un petit malentendu sur ce code. Tu penses que tu veux juste entrer dans mon invention ? J'en doute encore. J'ai donc une requête à vous faire : lorsque vous posez une question clé, décrivez le problème aussi brièvement que possible et, en même temps, faites en sorte que la description soit suffisante pour en comprendre l'essence. Sinon, ton cri est un cri dans le vide. Le code peut être joint à l'article. Tout cela est nécessaire et suffisant.
Raison: