Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1062

 
Artyom Trishkin:

Can you check it yourself? Difficult? And why write unnecessary things?

I have not checked. What's stopping you?

Can you do this or not I ran an error, so you can not do this is not possible?

 

Colleagues, how to programmatically check the TF where the Expert Advisor is running both for testing and for trading, e.g. for

to get indicator values from the next TF

Возвращает значение времени открытия бара (указанного параметром shift) соответствующего графика. 



datetime  iTime( 
   string           symbol,          // символ 
   int              timeframe,       // период 
   int              shift            // сдвиг 
   );
 

Параметры

symbol

[in]  Символьное имя инструмента. NULL означает текущий символ.

timeframe

[in]  Период. Может быть одним из значений перечисления ENUM_TIMEFRAMES. 0 означает период 

I want to use this example, in general, the INIT function in the tester is run on every pass?

int OnInit()
{
   MINLOT = MarketInfo(Symbol(),MODE_MINLOT);
   MAXLOT = MarketInfo(Symbol(),MODE_MAXLOT);  
   //double vbid    = MarketInfo(Symbol(),MODE_BID); 
   //double vask    = MarketInfo(Symbol(),MODE_ASK); 
   vpoint  = MarketInfo(Symbol(),MODE_POINT); 
   vdigits = (int)MarketInfo(Symbol(),MODE_DIGITS); 
   
   if(Digits==5 || Digits==3)
     {
      StopLoss = StopLoss*10;       
      slippage = slippage*10;
      TakeProfit = TakeProfit*10;   
      TralingStop = TralingStop * 10;
      DELTA = DELTA*10; 
      SPREAD_MAX = SPREAD_MAX*10;      
     }
     
//   --------------------------------------------------------------
 switch (signal_period)
  { 
   case 0:            ПЕРИОД_ДИАПАЗОНА = 0;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = 0;
                      break;
//  --------------------------------------------------------------- 
   case 1:            ПЕРИОД_ДИАПАЗОНА = PERIOD_M1;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_M5;
                      break;
//  ---------------------------------------------------------------
   case 2:            ПЕРИОД_ДИАПАЗОНА = PERIOD_M5;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_M15;
                      break;
//  ---------------------------------------------------------------
   case 3:            ПЕРИОД_ДИАПАЗОНА = PERIOD_M15;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_M30;
                      break;
//  ---------------------------------------------------------------
   case 4:            ПЕРИОД_ДИАПАЗОНА = PERIOD_M30;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_H1;
                      break;
//  ---------------------------------------------------------------
   case 5:            ПЕРИОД_ДИАПАЗОНА = PERIOD_H1;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_H4;
                      break;
//  --------------------------------------------------------------- 
   case 6:            ПЕРИОД_ДИАПАЗОНА = PERIOD_H4;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_D1;
                      break;
//  --------------------------------------------------------------- 
   case 7:            ПЕРИОД_ДИАПАЗОНА = PERIOD_D1;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_W1;
                      break;
      
   case 8:            ПЕРИОД_ДИАПАЗОНА = PERIOD_W1;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_MN1;
                      break;   
                                      
   case 9:            ПЕРИОД_ДИАПАЗОНА = PERIOD_MN1;
                      ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА = PERIOD_MN1;
                      break;             

 //  --------------------------------------------------------------- 
    default: 
    {
      Print(" не соответствует signal_period для торгов "); 
      return(0);
    }  
 }                

iTmfrm = ПЕРИОД_ДИАПАЗОНА;
 
 
     
   Print(" vpoint = ", vpoint," vdigits = ", vdigits); 
   Print(" MAXLOT = ", MAXLOT," MINLOT = ", MINLOT); 
   Print (" STOPLEVEL  = ", MarketInfo(Symbol(),MODE_STOPLEVEL));
   Print (" SPREAD     = ", MarketInfo(Symbol(),MODE_SPREAD));
   return(INIT_SUCCEEDED);
}
//--------------------------------------------------------------------
void OnTick()
{
                                 
   
   if(iTime(Symbol(),ПЕРИОД_ДИАПАЗОНА,0) == prevtime) return;            //ждем нового бара на текущем таймфрейме
      prevtime = iTime(Symbol(),ПЕРИОД_ДИАПАЗОНА,0);                     //если появился новый бар на текущем графике, то включаемся 
 


// -------------------   РАСЧЕТ ИНДИКАТОРОВ    ---------------------------------------
  
   MacdCurrent =iMACD(NULL,ПЕРИОД_ДИАПАЗОНА,12,26,9,PRICE_OPEN,MODE_MAIN,0);
   MacdPrevious=iMACD(NULL,ПЕРИОД_ДИАПАЗОНА,12,26,9,PRICE_OPEN,MODE_MAIN,1);
  // SignalCurrent=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,0);
  // SignalPrevious=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,1);
   MaCurrent =iMA(NULL,ПЕРИОД_ДИАПАЗОНА,MATrendPeriod,0,MODE_EMA,PRICE_OPEN,0);
   MaPrevious=iMA(NULL,ПЕРИОД_ДИАПАЗОНА,MATrendPeriod,0,MODE_EMA,PRICE_OPEN,1); 
   
   MaCurrent_СТАРШЕГО =  iMA(NULL,ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА,MA_СТАРШЕГО_ТФ,0,MODE_EMA,PRICE_OPEN,0);
   MaPrevious_СТАРШЕГО = iMA(NULL,ПЕРИОД_СТАРШЕГО_ДИАПАЗОНА,MA_СТАРШЕГО_ТФ,0,MODE_EMA,PRICE_OPEN,1);                        

  // ------------------------------------------------------------------------------------ 
 
Roman Shiredchenko:

Colleagues, how to programmatically check the TF where the Expert Advisor is running both for testing and for trading, e.g. for

to get indicator values from the next TF

I want to use this example. Does the INIT function in the tester run on every pass?


This is how the function is called Period(), there is also a variable that stores the timeframe.

 
Seric29:

That's how the function is called Period(), and there's also a variable that stores the timeframe.

Thanks. I'll have a look...
 
Seric29:

Is it possible to do this or not, I've run it with an error and it's not possible to do this?

Execution cannot be pardoned.

What kind of error?

 
Haven't traded for 1.5 months, I'm logged into Mt5 and there's a connection that needs to be restored ?
Files:
 
Let's say I overstayed accepting work on a freelance job and now the contractor has an overdue object. can this be fixed? has now been accepted.
 
Zlaya_budka:
Let's say I overstayed accepting work on a freelance job and now the contractor has an overdue object. can this be fixed? has now been accepted.

you cannot.

 
Artyom Trishkin:

You can't.

Well, I'll add that to the review, then.

 
Zlaya_budka:

Well, I'll add that to the review.

That won't change the statistics.
Reason: