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

 

Hello, encountered this problem: I can't get the EA to trade in only two time periods. How do I do that? Can you please tell me how to do it? The code looks like this, but it only accepts 1 period, it ignores the second one

extern string с = "Блок № 3";
extern int    Start_H1 = 0;
extern int    Start_M1 = 30;
extern int    End_H1   = 7;
extern int    End_M1   = 59;
extern int    Start_H2 = 12;
extern int    Start_M2 = 30;
extern int    End_H2   = 20;
extern int    End_M2   = 10;



if (((Hour()>=Start_H1 && Minute()>Start_M1) && (Hour()<=End_H1 && Minute()<=End_M1 )) ||
    ((Hour()>=Start_H2 && Minute()>Start_M2) && (Hour()<=End_H2 && Minute()<=End_M2))) 
        {
         открытие ордеров
        }
 
Nikita Chernyshov:

Hello, encountered this problem: I can't get the EA to trade in only two time periods. How do I do that? Can you please tell me how to do it? The code looks like this, but it only accepts 1 period, it ignores the second one

It would be better to convert hours and minutes to full time and compare with current time

   string startTime_1, startTime_2, endTime_1, endTime_2;
   StringConcatenate(startTime_1, Start_H1, ":", Start_M1);
   StringConcatenate(endTime_1, End_H1, ":", End_M1);
   StringConcatenate(startTime_2, Start_H2, ":", Start_M2);
   StringConcatenate(endTime_2, End_H2, ":", End_M2);
   datetime startHM_1, startHM_2, endHM_1, endHM_2;
   startHM_1 = StringToTime(startTime_1);
   endHM_1 = StringToTime(endTime_1);
   startHM_2 = StringToTime(startTime_2);
   endHM_2 = StringToTime(endTime_2);
   if((TimeCurrent() >= startHM_1 && TimeCurrent() <= endHM_1) || (TimeCurrent() >= startHM_2 && TimeCurrent() <= endHM_2))
 
Hello. There are objects - triangles with names: 321fa34, 321fa53, 321fa41. How can I find out the minimum price of the freshest triangle? The price that is in the properties in the middle.
 
YanSay:

Добрый день!

Прошу помочь со следующей проблемой:

1) После выполнения некоторых условий, открывается отложенный ордер:

Подскажите пожалуйста, что нужно дописать и куда, чтобы неоткрывшийся отложенный ордер был удален в том случае, если цена уже прошла стоп лосс(этого неоткрывшегося оредра).

Извините за глупый вопрос, заблудился в форумах пока искал ответ.

Заранее благодарю!

Identifier

Description

ORDER_TIME_GTC

The order will remain in the queue until it is removed

ORDER_TIME_DAY

Order will be valid for the current trading day only

ORDER_TIME_SPECIFIED

Order will be valid until the expiry date

ORDER_TIME_SPECIFIED_DAY

The order will be in effect until 23:59:59 of the current trading day. If that time is not within a trading session, the expiration will be at the nearest trading time.


These are just the parameters for removing a pending order !

To delete the order you need to monitor the price and when it reaches the stop price to delete the order - all this has to be written in a separate code !

 

Dear Sirs,

please help me find the error:

(Errors)

')' - unexpected end of program

" - comma expected

" -semicolon expected

'Trade_BY' - function not defined

'Trade_SELL' - function not defined

 

Please advise me!

How can I use the script to change the settings (a specific variable) of the indicator on the chart!

If this is possible a piece of code would be desirable !!!

 
PolarSeaman:
Hello. There are objects - triangles with names: 321fa34, 321fa53, 321fa41. How do I know the minimum price of the freshest triangle? The price that is in the properties in the middle.

1.

OBJPROP_CREATETIME

Object creation time

datetime r/o

2.

OBJPROP_PRICE

Price coordinate

modifier=number of anchor point

 
Nikita Chernyshov:

Hello, encountered this problem: I can't get the EA to trade in only two time periods. How do I do that? Can you please tell me how to do it? The code looks like this, but it only accepts 1 period, and ignores the second one

With this approach, both timeframes will be ignored. For example, the current time is 01:15. Will the condition hold?

(Hour()>=Start_H1 && Minute()>Start_M1) && (Hour()<=End_H1 && Minute()<=End_M1 )

No, it won't. After all, the current minutes are 15, which is less than the starting 30. Similarly with the second interval. It is best to convert the time to minutes from the start of the day:

int nCurDayMinutes = Hour() * 60 + Minute();
int nStart1DayMinutes = Start_H1 * 60 + Start_M1;
int nEnd1DayMinutes = End_H1 * 60 + End_M1;
if (nCurDayMinutes >= nStart1DayMinutes && nCurDayMinutes < nEnd1DayMinutes)
{
   // внутри интервала
}
 
YanSay:

Good afternoon!

Please help with the following problem:

1) After some conditions are met, a pending order opens:

Please tell me what to add and where to delete a pending order if price has already passed stop loss (of this pending order).

Sorry for the stupid question, I got lost in the forums while searching for an answer.

I lost my way in the forums while searching for the answer. Thanks in advance!

First of all, we do not know if the order has opened, because there is no check on this. Therefore it is meaningless to check if the Stop Loss or Take Profit of an order that was not opened.

 
Игорь:

Please advise me!

How can I use the script to change the settings (a specific variable) of the indicator on the chart!

If this is possible a piece of code would be desirable !!!

Very strange question. It's the same as asking: "How do you turn on a stool with a file?