Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 214
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
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.
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:
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;
}
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
You can't draw objects. But you can draw using CCanvas class - you can there
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 specify in the EA to close on the next candle?