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

 
Vladimir Tkach:

For two days, I've been making a nice panel. But it turned out that I could not change the Expert Advisor parameters set as inputs through it.

What do I do now?

no imagination at all?

input double _PARAM=1.0; // да, input менять в коде нельзя, они типа const

double PARAM=0;         // но никто не заставляет использовать только и исключительно их

int OnInit()

{

   if (MoonPhaze()==0 && _PARAM>0.1) {

       PARAM=_PARAM;       // всё что задаёт пользователь через input должно проверяться и использоваться только внутри OnInit - это просто хороший тон

   }

}
 

I seem to be misunderstood.

I change the parameters on the panel (which is on the graph), but they don't change in the Expert Advisor. Sadness, sadness.


 
Although their values change over the course of the programme. OK, that's fine.
 
missha32:

Please help me, I am completely confused in writing this function

I need the function to return the number of orders closed in one day


I would write it like this:

int CountInHistoryCloseOrder() 
{
int kp=0;
for(int i=OrdersHistoryTotal(); i>=0; i--) 
 {
  if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) 
   {
    if(OrderSymbol()==Symbol() && OrderMagicNumber()==mn) 
     {//mn - должна быть глобальной
      if(TimeToString(OrderCloseTime(),TIME_DATE)==TimeToString(TimeCurrent(),TIME_DATE))
       {
        kp++;
       }
     }
   }
 }
return(kp);
 
missha32:

Please help me, I am completely confused in writing this function

I need the function to return the number of orders closed in one day

int OrdersClosedInDay(datetime time) {

datetime from=time-TimeHour(time)*60*60-TimeMinutes(time)*60-TimeSeconds(time);

datetime to=from+24*60*60;

int count=0;

for(int pos=OrdersHistoryTotal()-1;pos>=0;pos--) {

   if (!OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY)) continue;

   if (OrderCloseTime()>=from && OrderCloseTime()<to)   count++;

}

return count;

}

 
Valerius:


I would write it this way:

Thanks for the help, it is starting to make sense, but only at the beginning of a new day are the values reset, and we need it to stay until the next series of orders to be closed in one day

I figured it out and added another function

 
Artyom Trishkin:
You can't draw objects. But you can draw using CCanvas class - you can there
Thank you!
 
Vladimir Tkach:

I seem to be misunderstood.

I change the parameters on the panel (which is on the graph), but they don't change in the Expert Advisor. Sadness.


If you don't want to create duplicated instances and further use them in the program, you can always set user parameters as "extern" - their values can be changed programmatically in the process of work.
 
Please advise. How do I set my EA to close on the next candle?
 
AlGuru:
Please advise. How do I specify in the EA to close on the next candle?
If the bar on which the position was opened is 1, then close that position.