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

 
Sysmart:

Question on testing (see picture from the tester)

- we open a Sell order (green arrow in the picture), it has a Take Profit of 1.10439;

- we add a pending Sell Stop order (yellow arrow in the picture) with the price 1.10441;

The question is why the Take Profit order did not trigger at 1.10439 and the Sell Stop (red arrow) at 1.10441?

When you buy at 1.3000, you buy expensively at the bad price 1.3003 (for example), when you close the position you set TP to sell at 1.2020, your trade will close at a price where Bid is at 1.2017 and Ask at 1.2020, i.e. you pay 2 times the spread for managing your position, and the difference goes into the office pocket. Alternatively you can trade in more liquid accounts like NDB (5 digits)

 
novichok2018:
Hello! I have a question not in the branch, but where to ask it, to get a really competent answer, I do not know. Google did not help. The question is: Today the DAX30 index suddenly started trading not at 9:00 am, but at 2:15 am. Nowhere, including on the site of the Frankfurt Stock Exchange I have not found any explanation or warning. Maybe someone is more informed and can give me a hint where to find the information?

Well, since no one is aware of this issue, then please advise how to bind the start of the EA to the start of trading on a symbol. Right now I have a simple binding to time: if(Hour()==9) {CODE}. Therefore, when I change the start time from 9:00 to 2:15, the condition on opening positions stops working. And if I simply change the time, there is no guarantee that the trading starts time will change again, and I won't notice it.

 
novichok2018:

Well, since no one is aware of this issue, then please advise how to bind the start of the EA to the start of trading on a symbol. Right now I have a simple binding to time: if(Hour()==9) {CODE}. Therefore, when I change the start time from 9:00 to 2:15, the condition on opening positions stops working. And if we simply change the time, there is no guarantee that the trading starts time will change again, and I won't notice it.

Search the kodobase.

here's the first onehttps://www.mql5.com/ru/code/27315

 
Sysmart:

Question on testing (see picture from the tester)

- we open a Sell order (green arrow in the picture), it has a Take Profit of 1.10439;

- we add a pending Sell Stop order (yellow arrow in the picture) with the price 1.10441;

The question is why the Take Profit order did not trigger at 1.10439 and the Sell Stop (red arrow) at 1.10441?

Just remember, Sell orders are opened at Bid price and closed at Ask price, for Buy orders it is vice versa. That is all.

 
Igor Makanu:

search for codobase

here's the first onehttps://www.mql5.com/ru/code/27315

Thank you, of course, but this example is off-topic. We need a link tothe start time of trading on a particular instrument or to the start time of the exchange that trades that instrument. I couldn't find it in the kodobase.

 

Hello, I was writing code and encountered this problem.

The code works if you exclude a line:

#property strict

With the same, it immediately stops working.

Here is the code fragment itself where the error is detected:

void manageAlerts()
{
   if (alertsOn)
   {
      if (alertsOnCurrent)
           int whichBars = 0;
           else whichBars = 1; 
         if (arrup[whichBars]  != EMPTY_VALUE) doAlert(whichBars,"up");
         if (arrdwn[whichBars] != EMPTY_VALUE) doAlert(whichBars,"down");
   }
}

And here are the results:

'whichBars' - undeclared identifier; line 7 of the fragment

The 'whichBars' - undeclared identifier; 8 line of the fragment


How can this be fixed?

 
pykachilo:

Hello, I was writing code and encountered this problem.

The code works if you exclude a line:

With the same, it immediately stops working.

Here is the code fragment itself where the error is detected:

And here are the results:

'whichBars' - undeclared identifier; line 7 of the fragment

The 'whichBars' - undeclared identifier; 8 line of the fragment


How can this be fixed?

whichBars should be defined at the beginning of the function, not in the condition.
 

Good afternoon.

Here is a question: In the documentation under "Graphic Event Types" (https://docs.mql4.com/ru/constants/chartconstants/enum_chartevents)
for eventCHARTEVENT_KEYDOWN it is defined that parameter sparam is "String value of bitmask describing the status of keyboard buttons".

However, I can't find information on which bits are responsible for what.

For the event CHARTEVENT_MOUSE_MOVE there is a similar parameter sparam which is a "String value of the bitmask describing the status of mouse buttons".
is described in detail on the same page...

Where can I see documentation on sparam="string value of bitmask describing the status of keyboard buttons" for CHARTEVENT_KEYDOWN event ?

Thank you.

Типы событий графика - Константы графиков - Константы, перечисления и структуры - Справочник MQL4
Типы событий графика - Константы графиков - Константы, перечисления и структуры - Справочник MQL4
  • docs.mql4.com
Существуют 9 видов событий, которые можно обрабатывать с помощью функции предопределенной функции OnChartEvent(). Для пользовательских событий предусмотрено 65535 идентификаторов в диапазоне от CHARTEVENT_CUSTOM до CHARTEVENT_CUSTOM_LAST включительно. Для генерации пользовательского события необходимо использовать функцию EventChartCustom...
 
Maksims Ignatovs:

Where can I see the documentation for sparam="string value bitmask describing the status of the keyboard buttons" for the CHARTEVENT_KEYDOWN event ?

you can print via Print(sparam) for the desired buttons.

I don't know your task, but I prefer to use lparam myself, so I don't have to think about language, caption and other variations.

 
Igor Zakharov:

you can print via Print(sparam) for the desired buttons.

I don't know your task, but I prefer to use lparam myself, so I don't have to think about language, caption and other variations.

This is an interesting solution for a general case. It is clear that for a particular key, you can go through all possible combinations (language, caps, etc.) to see what happens and even try to draw some conclusions from it,
BUT, this issue should be reflected in the documentation. For mouse events it is - everything is available in documentation. What about the keyboard?

Reason: