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

 
BarCloseB1 = iClose(nameSym,xPeriod,xshiftBar);
BarCloseB1Signal = iClose(nameSymSignal,xPeriod,xshiftBar)

Good day!

I learn the closing value for the current instrument and the other one (the signal one for the current bar) when opening a new hourly bar.

But in reality the value for the current instrument corresponds, while the value for the signal instrument takes the value of the previous bar, i.e. if xshiftBar = 1, then it takesxshiftBar=2 for the signal one, i.e. one bar more

 
Vitaly Muzichenko:

You can only withdraw what you have earned from this resource, which is the sale of software, signals and computer power. What is entered can only be spent on this resource.

Vitaly, you've got it wrong. You have to withdraw first, and then when and if you need it, you can deposit it.

 
Yerkin Sagandykov:

Good day!

I learn the closing value for the current symbol and the other one (the signal one for the current bar) when opening a new hourly bar.

But in reality the value for the current instrument corresponds, while the value for the signal instrument takes the value of the previous bar, i.e. if xshiftBar = 1, then it takesxshiftBar=2 for the signal one, i.e. one bar more

To check this, replace the variables with values 1 and 2. Then you will know where the error is.

 
Alekseu Fedotov:

With iCustom

Thanks, but can you please tell me why the drawn levels fly down too quickly?
Files:
snake.mq4  16 kb
 
Alexey Viktorov:

To check, put values 1 and 2 in place of the variables. Then you will know where the error is.

The problem is not in the variable values in my opinion. I just have a recalculation in my code at the arrival of a new hour. and it turns out that by the current symbol new bar appears and calculates the value of bar = 1, but by the signal symbol is a new bar has not yet formed or something and calculates values for bar = 2

 if  ( iTime(nameSym, LPeriod, 0 ) == counted_bar ) return; 
Обработчик события "новый бар"
Обработчик события "новый бар"
  • www.mql5.com
Для создателей индикаторов и экспертов всегда был актуален вопрос написания экономичного кода с точки зрения времени выполнения. Можно подойти к решению этой задачи с разных сторон. Из этой обширной темы в данной статье будет затронут, казалось бы уже решенный вопрос: проверка появления нового бара. Это достаточно популярный способ ограничения...
 
Yerkin Sagandykov:

The problem is not in the values of the variable in my opinion. I just have a recalculation in my code, and it turns out that for the current symbol a new bar appears and calculates the bar =1, but for the signal symbol a new bar has not yet been formed and calculates the values for bar =2

I want it to be exact and not "according to my opinion". Then I can say with certainty that the new bar appears on the signal symbol. And somehow wait for this new bar. There are several options, it's up to you to decide which one to use.

 

Greetings. Could you please give me a hint?

I need to calculate the maximum drawdown on the orders of a particular EA.

If I count by all orders, then I do so, and it fits with the results of MT itself:

      if(AccountEquity()>max_equity){
         max_equity=AccountEquity();
      }   
      if(max_drawdown_total<max_equity-AccountEquity()){
         max_drawdown_total=max_equity-AccountEquity();
      } 

I calculate it this way for one Expert Advisor:

      if(MoneyCount()>max_equity_1){
         max_equity_1=MoneyCount();
      }   
      if(max_drawdown_total_1<max_equity_1-MoneyCount()){
         max_drawdown_total_1=max_equity_1-MoneyCount();
      }

double MoneyCount(){
   double count=0;
   for(int i=OrdersTotal()-1; i>=0; i--){
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic){
            count+=(OrderProfit()+OrderSwap()+OrderCommission()); //
         }   
      }
   }
   return count;
}

I believe the results should be the same in the tester, but there is a difference (not immediately) of a little over a percent. What am I counting wrong?

 
Good afternoon. Could you please advise which language to prefer mql4 or 5? And why does mt4 have a built-in meta-editor 5, or is it for mql4 as well?
 
Hello, could you please advise how to reflect indicator values in the code when one is superimposed on the other, e.g. ATR is superimposed on MA, is it possible in MT4?
 
ZahvatkiN:
Hello, could you please advise how to reflect indicator values in the code when one is overlaid on another, e.g. ATR is overlaid on MA, is it possible in MT4?

For MQL4 use iMAOnArray(), for MQL5 - when creating an iMA handle specify the handle of a previously created ATR instead of the price at which the moving average is calculated

Reason: