Tutte le domande dei nuovi arrivati su MQL4 e MQL5, aiuto e discussione su algoritmi e codici - pagina 697

 


#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
//extern double    TakeProfit=250.0;
//extern double    Lots=1;
extern int       barn=1000;
extern int       Length=10;
extern int       PatternLength=10;
extern int        PatternWidth=4;
extern color       PatternColor = Red;
extern bool       DrawZigZag = true;
extern bool    ShowValues = true;
extern color   ValueColor = Blue;
//---- buffers
double ExtMapBuffer1[];
//double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexEmptyValue(0,0.0);
  //SetIndexDrawBegin(0, barn);
  if (DrawZigZag == true)  {SetIndexStyle(0,DRAW_SECTION);}
  else {SetIndexStyle(0,DRAW_NONE);}
   SetIndexBuffer(0,ExtMapBuffer1);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
ObjectsDeleteAll();
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
 
   int shift,Swing,Swing_n,alf,uzl,i,zu,zd,mv;
   double LL,HH,BH,BL,NH,NL; 
   double Uzel[10000][3]; 
   string text;
    
    ObjectDelete(OBJ_TREND);
    

// loop from first bar to current bar (with shift=0) 
      Swing_n=0;Swing=0;uzl=0; 
      BH =High[barn];BL=Low[barn];zu=barn;zd=barn; 



for (shift=barn;shift>=0;shift--) { 
      LL=10000000;HH=-100000000; 
   for (i=shift+Length;i>=shift+1;i--) { 
         if (Low[i]< LL) {LL=Low[i];
           
         } 
         if (High[i]>HH) {HH=High[i];} 

  }
 
   if (Low[shift]<LL && High[shift]>HH){ 
      Swing=2; 
      if (Swing_n==1) {zu=shift+1;} 
      if (Swing_n==-1) {zd=shift+1;
 
      } 
      
   } else { 
      if (Low[shift]<LL) {Swing=-1;} 
      if (High[shift]>HH) {Swing=1;} 
   } 

   if (Swing!=Swing_n && Swing_n!=0) { 
   if (Swing==2) {
      Swing=-Swing_n;BH = High[shift];BL = Low[shift]; 
   } 
   uzl=uzl+1; 
   if (Swing==1) {
      Uzel[uzl][1]=zd;
      Uzel[uzl][2]=BL;
      NewSid(i,zd,BL);
     
   } 
   if (Swing==-1) {
      Uzel[uzl][1]=zu;
      Uzel[uzl][2]=BH; 
       NewSid(i,zu,BH);
   } 
      BH = High[shift];
      BL = Low[shift]; 
      

   } 
 
   
/*

 */
   
   

   if (Swing==1) { 
      if (High[shift]>=BH) {BH=High[shift];zu=shift;}} 
      if (Swing==-1) {
          if (Low[shift]<=BL) {BL=Low[shift]; zd=shift;}} 
      Swing_n=Swing; 
   } 

   

   
   for (i=1;i<=uzl;i++) { 
         mv=StrToInteger(DoubleToStr(Uzel[i][1],0));
      ExtMapBuffer1[mv]=Uzel[i][2];
      

   
   } 


   return(0);
  }
  
  void NewSid(int i, int re,  double Uzels)
{

int zed=re-PatternLength;

if (zed < 0)
   {
   ObjectCreate("priceLine1_"+i,OBJ_TREND,0,0,0,0,0);
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE1,Uzels);
  
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME2,Time[re+PatternLength]); 
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE2,Uzels);   
    
   ObjectSet("priceLine1_"+i ,OBJPROP_COLOR,PatternColor);
   ObjectSet("priceLine1_"+i,OBJPROP_RAY, false);
   ObjectSet("priceLine1_"+i,OBJPROP_WIDTH,PatternWidth);
   

   }
   
   
   
   
  else {

   ObjectCreate("priceLine1_"+i,OBJ_TREND,0,0,0,0,0);
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE1,Uzels);
  
   ObjectSet("priceLine1_"+i ,OBJPROP_TIME2,Time[re-PatternLength]); 
   ObjectSet("priceLine1_"+i ,OBJPROP_PRICE2,Uzels);   
    
   ObjectSet("priceLine1_"+i ,OBJPROP_COLOR,PatternColor);
   ObjectSet("priceLine1_"+i,OBJPROP_RAY, false);
   ObjectSet("priceLine1_"+i,OBJPROP_WIDTH,PatternWidth);
}

      string high  = DoubleToStr(High[re],4);
      string low   = DoubleToStr(Low[re],4);
      string open  = DoubleToStr(Open[re],4);
      string close = DoubleToStr(Close[re],4);

 Comment(low,"   ",high);

if (ShowValues == true)

{
   ObjectCreate("price_text"+i,OBJ_TEXT,0,0,0);
   //ObjectSetText("price_text"+i,"Date: "+TimeToStr(Time[re],TIME_DATE | TIME_MINUTES)+" | Time: ",10,"Calibri", Green);
   
   ObjectSetText("price_text"+i,"Open: "+open+" | High: "+high+" | Low: "+low+" | Close: "+close,10,"Calibri", ValueColor);
   ObjectSet("price_text"+i ,OBJPROP_TIME1,Time[re]);
   ObjectSet("price_text"+i ,OBJPROP_PRICE1,Uzels);
   
};
}


Perché Comment(low," ",high) produce
solo il valore alto?
 
Qualcuno può consigliarmi come impostare delle restrizioni nel testo dell'indicatore per l'uso in diversi timeframe. Quando si carica l'indicatore è nelle proprietà, ma come limitarlo programmaticamente????
 
Vladimir Pavlov:
Potete consigliarmi come porre delle restrizioni all'uso di diversi timeframe nel testo dell'indicatore? Quando si carica l'indicatore è nelle proprietà, ma come limitare questo programmaticamente????
if(InpTimeframeWork!=Period())
  {
   // Здесь действия, которые нужно выполнить если период графике не совпадает с заданным в настройках
  }

Se è controllato in OnInit(), si può emettere un messaggio sulla mancata corrispondenza del grafico e restituire INIT_FAILED; o sintonizzare il grafico terminale su quello desiderato: ChartSetSymbolPeriod(0,NULL,InpTimeframeWork);

 

Buon pomeriggio!
Per favore, aiutatemi con il problema dell'attivazione della fotocopiatrice. Ho comprato una fotocopiatrice sul mercato molto tempo fa per 25$. Vorrei usarlo su VPS ma non posso scaricarlo dal mercato in MT4 per qualche motivo. Offerte solo per comprare. Ho ancora 7 attivazioni gratuite. Non riesco acapire cosa c'è che non va, potete consigliarmi cosa devo fare per attivare la copiatrice https://www.mql5.com/ru/market/product/4319 ?

Grazie in anticipo.

 
Artyom Trishkin:

Se è controllato in OnInit(), è possibile emettere un messaggio sulla mancata corrispondenza del grafico e restituire INIT_FAILED; o adattare il grafico terminale a quello richiesto: ChartSetSymbolPeriod(0,NULL,InpTimeframeWork);

Conosco questa variante, ma non so come usare le proprietà. Come configurare nella scheda del programma "Display" per non far entrare livelli inutili.

 
//+------------------------------------------------------------------+
//| eeeeee.mq4 |
//| Copyright 2018, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#proprietà link "https://www.mql5.com"
#proprietà versione "1.00"
#proprietà rigorosa
#proprietà indicator_chart_window
extern int ExtDepth = 12;
extern int ExtDeviation = 5;
extern int ExtBackstep = 3;
extern inttern ShiftBars = 2;
//+------------------------------------------------------------------+
//| funzione di inizializzazione dell'indicatore personalizzato
//+------------------------------------------------------------------+
int OnInit()
{// nel modulo

//nella funzione
doppio y3=0, y2=0, y1=0, zz; // estremi
int x3, x2, x1, sh=ShiftBars;// numero di barre
// Prendete tre estremi della Zig-Zag
mentre (y3==0) {
zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
se (zz!=0 && zz!=EMPTY_VALUE) {
if (y1==0) { x1=sh; y1=zz; }
else if (y2==0) { x2=sh; y2=zz; }
else if (y3==0) { x3=sh; y3=zz; }
}
sh++;

}

Come si ottiene il valore dell'estremo corrente?

Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
Открой новые возможности в MetaTrader 5 с сообществом и сервисами MQL5
  • www.mql5.com
Задавайте вопросы по техническому анализу, обсуждайте торговые системы и улучшайте свои навыки программирования торговых стратегий на языке MQL5. Общайтесь и обменивайтесь опытом на форуме с трейдерами всего мира и помогайте ответами новичкам — наше сообщество развивается вместе с вами. Как эффективно продвигать свой продукт в Маркете...
 
02031986dima:

Come ottenere il valore dell'estremo corrente?

Inserire il codice correttamente:


 
02031986dima:
//+------------------------------------------------------------------+
//| eeeeee.mq4 |
//| Copyright 2018, MetaQuotes Software Corp.
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#proprietà link "https://www.mql5.com"
#proprietà versione "1.00"
#proprietà rigorosa
#proprietà indicator_chart_window
extern int ExtDepth = 12;
extern int ExtDeviation = 5;
extern int ExtBackstep = 3;
extern inttern ShiftBars = 2;
//+------------------------------------------------------------------+
//| funzione di inizializzazione dell'indicatore personalizzato
//+------------------------------------------------------------------+
int OnInit()
{// nel modulo

//nella funzione
doppio y3=0, y2=0, y1=0, zz; // estremi
int x3, x2, x1, sh=ShiftBars;// numero di barre
// Prendete tre estremi della Zig-Zag
mentre (y3==0) {
zz=iCustom(NULL, 0, "ZigZag", ExtDepth, ExtDeviation, ExtBackstep, 0, sh);
se (zz!=0 && zz!=EMPTY_VALUE) {
if (y1==0) { x1=sh; y1=zz; }
else if (y2==0) { x2=sh; y2=zz; }
else if (y3==0) { x3=sh; y3=zz; }
}
sh++;

}

Come si ottiene il valore dell'estremo corrente?

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 07.10.2006                                                     |
//|  Описание : Возвращает экстремум ЗигЗага по его номеру.                    |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (NULL или "" - текущий символ)          |
//|    tf - таймфрейм                  (      0     - текущий ТФ)              |
//|    ne - номер экстремума           (      0     - последний)               |
//|    dp - ExtDepth                                                           |
//|    dv - ExtDeviation                                                       |
//|    bs - ExtBackstep                                                        |
//+----------------------------------------------------------------------------+
double GetExtremumZZPrice(string sy="", int tf=0, int ne=0, int dp=12, int dv=5, int bs=3) {
  if (sy=="" || sy=="0") sy=Symbol();
  double zz;
  int    i, k=iBars(sy, tf), ke=0;

  for (i=0; i<k; i++) {
    zz=iCustom(sy, tf, "ZigZag", dp, dv, bs, 0, i);
    if (zz!=0) {
      ke++;
      if (ke>ne) return(zz);
    }
  }
  Print("GetExtremumZZPrice(): Экстремум ЗигЗага номер ",ne," не найден");
  return(0);
}
 

quanti allegati sono ammessi?

if
{
   if
     {

     }
}
 
multiplicator:

quanti allegati sono ammessi?

Finché non ti stanchi di scriverli

Motivazione: