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

 
Ihor Herasko:

If you want to take an M30 candle that closed together with the last closed H1 candle, it can be a candle with index not only 1, but also 2. Another thing is that then it is not clear why the closing price of M30 is taken, if it is the same closing price for the previous H1 candle. That is, in this case there is no sense to ask the closing price of another TF, because it is the same as the closing price of the current TF.

Exactly what we need to know is the closing price of M30 inside H1

Found the reason, bar opening control. Thank you.

 

How in the indicator to compare, in the loop, price High[i+1] +/-10*Point with lower fractals?

if found equal, put arrow Buf_o[i+1]= High[i+1] ;.

 

Hello!

I want to write a simple binary strategy code for testing it with MetaTrader 4 tester. I know that the built-in tester does not fully test binary strategies, but I just need to know the share of profitable trades during the testing period. I am not able to set the expiry time of a deal. I use the OrderSend operator:

OrderSend(Symbol(),OP_BUY,1,Ask,10,0,0, "5",15167,Expiration,clrGreen);

Everything works well when performing automated trading, but according to broker's terms, the expiration period is specified in the comment to the position. In this case my comment is "5". It is five minutes. However, the tester, of course, does not consider the comment as an indication of the expiry period. The tester does not react at all to different values of the Expiration parameter. First it opens trades following the strategy's signals and then closes all open trades within the testing period at the moment of expiration of the testing period. As a result, the result of testing is absolutely incorrect.

How to specify an understandable expiry period for the tester? I am still mastering the "old" version of the code.

Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
Тестирование стратегий - Алгоритмический трейдинг, торговые роботы - MetaTrader 5
  • www.metatrader5.com
Тестер стратегий позволяет тестировать и оптимизировать торговые стратегии (советники) перед началом использования их в реальной торговле. При тестировании советника происходит его однократная прогонка с начальными параметрами на исторических данных. При оптимизации торговая стратегия прогоняется несколько раз с различным набором параметров...
 
kirson-7:

How do I set an expiry period that the tester can understand?

Close the position if the current time = opening time plus 5 minutes or at the opening of a new bar if the timeframe is M5.
 

How do I makeHigh[i+1] +/-10*Point not exactly equal to the price of the fractal?

 {
//---
   if(rates_total<2) return(0);

   int limit=rates_total-prev_calculated;
   if(limit>1)
     {
      limit=rates_total-2;
      ArrayInitialize(BufferUP,EMPTY_VALUE);
      ArrayInitialize(BufferDN,EMPTY_VALUE);
     }
   for(int i=limit; i>=0; i--)
     {
      // BufferUP[i+1]=EMPTY_VALUE;
      
      //
      for(int y=i+2;y<=i+100;y++)
        {
         if(low[i+1]==iFractals(Symbol(),0,MODE_HIGH,y))estb=true;
        }
      if(estb)
        {
         BufferUP[i+1]=low[i+1]-distance*Point;//НЕПРАВИЛЬНО СТАВИТ СТРЕЛКУ
        }
      estb=0;
      //==//
      for(int y=i+2;y<=i+100;y++)
        {
         if(high[i+1]==iFractals(Symbol(),0,MODE_LOWER,y))ests=true;
        }
      if(ests)
        {
         BufferDN[i+1]=high[i+1]+distance*Point;//ПРАВИЛЬНО СТАВИТ СТРЕЛКУ
        }
      ests=0;

      //Comment("");
     }
   return(rates_total);
  }
 
bij:

How do I makeHigh[i+1] +/-10*Point not exactly equal to the price of the fractal?

The difference in values is greater than 10*Point, but we need to consider whether the difference will be positive or negative.
 
bij:
Close the position if the current time = position opening time plus 5 minutes or at the opening of a new bar, if the timeframe is M5.
And why can't the standard expiry period in the OrderSend operator's parameter list work? It is marked as Expiration in my example.
 
kirson-7:
Why can't the standard expiry period in the OrderSend operator parameter list work? It is marked as Expiration in my example.
This is for pending orders
 
Please help me to write a function : close orders from a bigger lot to a smaller one (string Symbol, int type, bool hand orders, int Magic)
I.e. symbol selection, type, whether hand orders are taken into account, magic number.


 
Hello All: Can I prescribe in a user-defined function opening a position(eg buy on the market), and call this function when there are different buy signals? I.e. MACD-were addressed to this function - position opened, _Muwings signal-were addressed to this function - buying again.... etc. Or in each specific case, when the signal is worked out, it is necessary to write OrderSand(Symbol,OP_BAI, etc.);