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

 

Aleksei Stepanenko grazie.


Valeriy Yastremskiy Forse è perché il codice è incompleto, dato che ho rimosso tutte le funzioni inutili.


//+----------------------------------------------------------------------------+
//|                                                          AverageRange.mq4  |
//|                                                    Ким Игорь В. aka KimIV  |
//|                                                       http://www.kimiv.ru  |
//|                                                                            |
//|  14.09.2005  Скрипт для расчёта:                                           |
//|              средней волатильности инструмента High-Low                    |
//|              среднего размера тела свечи       ABS(Open-Close)             |
//|              среднего размера тени свечи                                   |
//|                                                                            |
//|  17.11.2007  Возможность использования заданного количества баров          |
//+----------------------------------------------------------------------------+
#property copyright "Ким Игорь В. aka KimIV"
#property link      "http://www.kimiv.ru"
#property  show_inputs

extern datetime BeginDateCalc = D'2013.01.01';
extern datetime EndDateCalc   = D'2013.12.31';
extern int      NumberOfBars  = 100;         


//+----------------------------------------------------------------------------+
//|  script program start function                                             |
//+----------------------------------------------------------------------------+
void start() {
   int    i;           
   int    b  = 0;     
   int    bb = 0;      
   int    h  = 0;      
   int    l  = 0;     
   int    s  = 0;      
   int    t  = 0;      
   string st = "";        

  for (i = Bars; i > 0; i--) {
    
    if ((Time [i] >= BeginDateCalc && Time [i] <= EndDateCalc && NumberOfBars <= 0)
    || (NumberOfBars > 0 && NumberOfBars >= i)) {
      
      if (bb == 0) bb = i;
      s += (High [i] - Low [i]) / Point;
      t += MathAbs (Open [i] - Close [i]) / Point;
      
      if (Open [i] > Close [i]) {
        h += (High [i] - Open [i]) / Point;
        l += (Close [i] - Low [i]) / Point;
      } else {
        h += (High [i] - Close [i]) / Point;
        l += (Open [i] - Low [i]) / Point;
      }
      
      b++;
    }
  }

  st =      "Начало: " + TimeToStr (Time [bb], TIME_DATE | TIME_MINUTES) + "\n";
  st = st + "Конец: " + TimeToStr (Time [bb - b + 1], TIME_DATE | TIME_MINUTES) + "\n";
  st = st + "Использовано баров: " + b + "\n";
  st = st + "Средняя волатильность: " + s / b + " п.\n";
  st = st + "Средний размер тела: " + t / b + " п.\n";
  st = st + "Средний размер верхней тени: " + h / b + " п.\n";
  st = st + "Средний размер нижней тени: " + l / b + " п.";

  Comment (st);
}
//+----------------------------------------------------------------------------+
Aleksei Stepanenko
Aleksei Stepanenko
  • www.mql5.com
Профиль трейдера
 
Valeriy Yastremskiy #:

Ad essere onesti, non capisco la logica di Kim, perché le condizioni di tempo della barra che supera il valore impostato e il numero di barre calcolate sono negative con OR il numero di barre calcolate è maggiore del numero di barre Barz)))) E allo stesso tempo corregge solo i parametri personalizzati)

E non visualizza nemmeno un avviso che l'utente ha sbagliato)

Logicamente, se NumberOfBars è specificato (maggiore di 0), il tempo è ignorato e solo le ultime barre sono prese in considerazione

Ma un utente può fare un errore con le date o se c'è un buco nella citazione, allora non viene stampato nulla, restituisce solo DivideByZero :-)

 
Ciao

qualcuno può sapere come convertire le quotazioni da mt5 a mt4? o qualsiasi modo per approfittare della migliore storia da mt5 a mt4... tranne TDS2😊
 
Pavel Malyshko #:
Ciao

qualcuno può sapere come convertire le quotazioni da mt5 a mt4? o qualsiasi modo per approfittare della migliore storia da mt5 a mt4... tranne TDS2😊
Esportazione/importazione
 
MakarFX #:
Esportazione/importazione

quindi mt5 ha un formato di citazione diverso. mt4 non li legge. questo è il problema...😎

 
Pavel Malyshko #:

quindi mt5 ha un formato di citazione diverso. mt4 non li legge. questo è il problema...😎

MT5 esporta in csv e mt4 legge tutto

 
Oksana_Timakova Punto;

Perché ho bisogno della divisione per punti?

...

Lo consiglio vivamente:

s+=MathRound((High [i] - Low [i]) / Point);

Altrimenti si ottiene un oops)))

void OnStart(){
   double first=0.00001;
   double point=0.00001;
   for(uint i=0;i<10;++i){
      double value=NormalizeDouble(first+i*point,5);
      int res=(int)((value-first)/point);
      if (res!=i)
         PrintFormat("Alert: (%.5 f-%.5 f)/%.5 f!=%u, but ==%i",value,first,point,i,res);
   }
}
2021.09.12 11:06:26.041 Script test EURGBP,H1: removed
2021.09.12 11:06:26.038 test EURGBP,H1: uninit reason 0
2021.09.12 11:06:26.038 test EURGBP,H1: Alert: (0.00007-0.00001)/0.00001!=6, but ==5
2021.09.12 11:06:26.038 test EURGBP,H1: Alert: (0.00003-0.00001)/0.00001!=2, but ==1
2021.09.12 11:06:26.038 test EURGBP,H1: initialized
2021.09.12 11:06:25.998 Script test EURGBP,H1: loaded successfully
 

Come fare in modo che la finestra dell'indicatore nasconda completamente il grafico dei prezzi?

Non posso farlo tramite ChartSetInteger(0,CHART_HEIGHT_IN_PIXELS,0,0). Devo prima impostare la dimensione dell'indicatore e poi aggiungervi l'altezza della finestra dei prezzi:

int chart_height=(int)ChartGetInteger(0,CHART_HEIGHT_IN_PIXELS,0);
IndicatorSetInteger(INDICATOR_HEIGHT,200+chart_height);


Tuttavia, se si apre la finestra dell'ordine in basso, la dimensione della finestra dell'indicatore diventa più grande della dimensione dello schermo e il terem mostra nuovamente il prezzo.

Non so come misurare la finestra dell'ordine, inoltre, continua a cambiare.

Cosa fare?

 

Per favore, aiutatemi!

Aiuta a tradurre questo codice in mql5...

Voglio capire come lavorare con le maniglie.

//+------------------------------------------------------------------+
//|                                                Stochastic.v1.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers  2
#property indicator_plots    2
#property indicator_minimum -51
#property indicator_maximum  51
#property indicator_level1   0
#property indicator_levelstyle 0
#property indicator_levelcolor clrDimGray
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDimGray
#property indicator_style1  STYLE_SOLID
#property indicator_width1  0
//--- plot Label2
#property indicator_label2  "Label2"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  0
//--- input parameters
input int             WeekCount   = 1;     // Ограничение истории в неделях(0-вся история)
input int             StochPeriod = 14;
input ENUM_TIMEFRAMES TimeFrame   = PERIOD_CURRENT;
//--- indicator buffers
double   Label1Buffer[];
double   Label2Buffer[];
int      index=-1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   IndicatorDigits(2);
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer);
   SetIndexBuffer(1,Label2Buffer);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {

  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   ArrayInitialize(Label1Buffer,0);
   ArrayInitialize(Label2Buffer,0);
   int limit,i;
   int barPlus=iBarShift(_Symbol,_Period,iTime(_Symbol,PERIOD_W1,WeekCount));
   limit=rates_total-prev_calculated-1;
   if(WeekCount!=0)limit=barPlus-2;
   if(limit<1) return(0);
   for(i=limit;i>=0;i--)
     {
      index=iBarShift(_Symbol,TimeFrame,time[i],false);
      Label1Buffer[i]=iStochastic(_Symbol,TimeFrame,StochPeriod,3,3,MODE_SMA,1,MODE_MAIN,index)-50; 
     }
   for(i=limit;i>=0;i--)
     {
      Label2Buffer[i]=iMAOnArray(Label1Buffer,0,StochPeriod*3,0,MODE_SMA,i);
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Apprezzerei il vostro aiuto.

 
MakarFX #:

Per favore, aiutatemi!

Aiuta a tradurre questo codice in mql5...

Voglio capire come lavorare con le maniglie.

Apprezzerei il vostro aiuto.

L'unica domanda riguarda questa linea

  Label1Buffer[i]=iStochastic(_Symbol,TimeFrame,StochPeriod,3,3,MODE_SMA,1,MODE_MAIN,index)-50; 
-50 ridondante e array