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

 
Alexey Viktorov:

Well, in that case, what are these self-written functions for anyway?

I got the maximum and minimum prices of yesterday and from these values to determine the middle.

I don't know... I wasn't thinking... I'll rewrite it now... It's easier that way... Thanks!

 
Igor Makanu:

Money Management

as for the random entries the pending orders follow the price, in the optimizer the selection is performed according to the formula y=kx+b , later I will use polynomial and exponent, but the optimizer searches only for the factors and the order values, in general not to put a fog on it - it is a grid, well, almost, but the goals have not been reached yet

When I look at the markets (though I've been doing it with a great pause), I've been dealing with them since I registered on the forum. Of course, it took me a long time to improve the layer of programming in MQL, but the general idea I got during the year of related writing of experts following the workers' requests )))

No problem, go ahead.

I see, very well understood, because I've been through this before.
All the same it's all about finding some parameters (in this case at least coefficients k and b in linear y=kx+b or a,k,x in exponential y=ax²+kx+b). These coefficients should preferably change withevery tick, that's why I said that optimization should sit in the program itself and take place automatically and constantly, but not in an external tester in manual mode from time to time (once a day or week or month...). Also you need to control the period, in which the observed linear or parabolic (exponential) regression occurs. This period should also change with every tick. Though finding a line or a parabola is the same as finding the optimal period of the linear or parabolic regression at present.
But an external tester can always find such constant static parameters, which will be universally guaranteed to fit only that set of historical data, on which the test is executed, and on this, the past historical period, of course, a stable profit and beautiful profit lines will be observed, but we need the present and the future.

All the same, it all comes down to controlling the channel width, channel length, channel breakdown, return to breakdown line of a linear or higher degree of channels. And this is a pattern recognition problem and should only be solved internally, not externally.

 
Nikolai Semko:

I see, very well understood, for I have been through it before.

So have I, and more than once.

Nikolai Semko:

But the external tester will always be able to select such constant static parameters, which will be universally guaranteed to fit only that set of historical data, on which the test is running, and on this, already past historical period, of course, a stable profit and beautiful profit lines will be drawn, but we need the present and future.

That's the problem - no, everything is the same as in the book test and forward, charts are different, but the trend is there, as far as I understand my EA is not hitting the future price itself, but the future price trajectories.

 
Guys, here's a question. Look, there is a prefix increment ++q and postfix q++, using their features we can get quite different and interesting effect, for example the priority of this q++ increment performs addition late/backwards i.e. after and not immediately, how can this be done with prime numbers and is it possible, for example I want this addition q+5, first I need to use q and then add 5?
 
Seric29:
Guys, here's a question. Look, there is a prefix increment ++q and postfix q++, using their features we can get quite different and interesting effect, for example priority of this q++ increment performs addition late/backwards i.e. after and not immediately, how it can be done with prime numbers and is it possible, for example I want such addition q+5, first I need to use q and then add 5?

Well if this is to be used as a loop counter then simply

for(int q = 0; q <= 25; q+=5)
 
Alexey Viktorov:

Well, if you use it as a loop counter, it's easy

And if you pass a q+5 expression into a function and first execute q and then add 5, you can't do it, right?

int q
void Funk(int pr){}
вызвов Funk(...q+5...) сначала используем q а после прибавляем 5
как здесь например Funk(q++) сначала используем q а после прибавляем 1
 
Comments not relevant to this topic have been moved to "OOP, templates and macros in mql5, tips and tricks of the trade".
 
Seric29:

And if you pass a q+5 expression into a function and first execute q and then add 5, you can't do it, can you?

Is 5 a constant or a variable? If it's a constant, no problem: pass q into the function and add 5 after you use it. If it's a variable, pass two variables and add the second variable after you use q. Another option is to declare variables globally. Then you don't need to pass anything at all.
 

Hello, I want to close differently directed positions when profit =0 Different number of buy and sell positions, different lot sizes.

What is wrong with the average price search function, i.e. the zero profit point?

 double AveroProf(string sy="", int op=-1, int mn1=-1) 
   {
   int i=0;
   int kol=0;
   double lots=0;
   double sum=0;
   double sum1=0;
   double zeroprice=0;
   double tick_value;
   for (i=0; i<OrdersTotal(); i++)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
      if (OrderSymbol()!=Symbol()) continue;
      if (OrderMagicNumber()!=mn1) continue;
      if (OrderType()==OP_BUY)
      {
       lots=lots+OrderLots();
       sum=sum+OrderLots()*OrderOpenPrice();
       sum1=sum1+OrderProfit()+OrderSwap()+OrderCommission()  ; 
      }
      if (OrderType()==OP_SELL)
      {
       lots=lots+OrderLots();
       sum=sum+OrderLots()*OrderOpenPrice();
       sum1=sum1+OrderProfit()+OrderSwap()+OrderCommission()  ;
       kol=kol+1;
      }
   
   }
   if (lots>0)
   { 
   zeroprice=sum/lots;
   zeroprice=NormalizeDouble(zeroprice,_Digits);
   zeroprice = (MathRound(zeroprice*MathPow(10,Digits)))/MathPow(10,Digits);
    }   
   return( zeroprice);
   }
 
Please can someone help me with this problem: https://www.mql5.com/ru/forum/322133
Как использовать WinApi для преобразования времени в StrategyTester MT5?
Как использовать WinApi для преобразования времени в StrategyTester MT5?
  • 2019.09.12
  • www.mql5.com
Я успешно создал CustomSymbol в MT5, и я получаю эту таблицу в приложении...
Reason: