Learning and writing together in MQL5 - page 16

 
AUser:
People! Some hints for beginners in programming, how to work with the handle. What is it - some file in a buffer? How to extract information from it in order to work with it?

Take a look:

MQL5 Reference Guide / Technical Indicators

MQL5 Reference Guide / Access to timeseries and indicators / CopyBuffer

In brief, the handle is a certain pointer (link) to the program created a copy of the indicator, to be used in the CopyBuffer function.

Look also at articles for beginners, it`s described there.

 
AUser:

Can you tell me how to assign the value of the current price to a variable?

The article "Migration from MQL4 to MQL5" might be easier to read.

You should also check the documentation more often.

This is the answer to the question from the SymbolInfoDouble function example

double ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);
double bid=SymbolInfoDouble(Symbol(),SYMBOL_BID);
 

AUser:

I also wonder if it is possible to load historical data into the indicator handle?

To be more precise, the data is not loaded into the indicator handle, the data is loaded into special arrays using the functions from the section "Access to timeseries and indicator data".

At least these functions should be studied further.

CopyBuffer

Gets data of a specified buffer from a specified indicator into an array

CopyRates

Gets history data of the Rates structure for a specified symbol and period into an array

CopyTime

Gets history data on bar opening time for a specified symbol and period into an array

CopyOpen

Gets history data on bar opening price for a specified symbol and period into an array

CopyHigh

Gets history data on maximal bar price for a specified symbol and period into an array

CopyLow

Gets history data on minimal bar price for a specified symbol and period into an array

CopyClose

Gets history data on bar close price for a specified symbol and period into an array

 

AUser:

And with the history of the indicator, not everything is clear. The problem is the following: before to compare the values of the indicators on the bars, they should be collected in the arrays of indicators. The values from the 15-minute bars can be expected, but what about the weekly ones? I have looked through the manual - I do not understand))) Suppose this one: CopyClose(Gets the history data of bar close prices for the appropriate symbol and period into an array) We get the data, but how to make the indicator calculate them? I do not understand something.


I understand that you are writing an Expert Advisor using indicators?

If the handle is received and there are no obvious problems, the data from the custom indicator is obtained using the CopyBuffer, for standard technical indicators it's better to apply the following functions

This code should write the data of 20 bars from the 0 buffer into the buffer array and return the number of actually copied elements of the array or -1

int Res = CopyBuffer(MyHandle,0,0,20,buffer[]);

Moreover, 20 bars are counted from bar 0, hence we should not forget about the seriality (for details see here). You can read about getting additional data here.

 
AUser:
It's blowing up... what's wrong with it?

post the help for the OrderSend function here

 
AUser:
It's so written that it's hard to understand without training)

post the help for the OrderSend function here

I only hope to make you read it, otherwise you won't be able to do anything.

 

AUser, - Sergeev is right. TheOrderSend function has only two parameters. You need to spend some time studying MQL5.

 
AUser:

Written by:

OrderSend(TRADE_ACTION_DEAL,Symbol(),1,SL,TP,10,ORDER_TYPE_BUY,ORDER_FILLING_CANCEL);

It's gone wrong. What's wrong?

I want to buy at a real price.

I want to get a more detailed code of this area or a working example. 2;

2. I would like to decide right away which language this code is written in;

3. we would like people to learn how to read the help, in this case, read the description of the OrderSend function.

In this case this fragment will be sufficient!!!

The OrderSend() function is intended for the execution of trade operations by sending requests to the trade server.

boolOrderSend(
MqlTradeRequest&request, //request structure
MqlTradeResult&result// structure of the response
);

I want people to learn more about MqlTradeRequest andMqlTradeResult structures

5. I want people to get acquainted with such a wonderful thing as CTrade (the filling of this class is located in the file \MQL5\Include\Trade\Trade.mqh).

An example of its use in an Expert Advisor can be found in the standard Expert Advisor - MACD Sample.

Moreover, it would be good to know what happens with the order starting from the CSampleExpert class up to the next function of the CTrade code:

a) PositionOpen - Opens a position with specified parameters

b) PositionModify - Changes the position parameters by the specified symbol

b) PositionClose -Closes the position by the specified symbol.

PS

In conclusion, I want people not only read the help, but also know how to search for information in the files of the standard library (not bad to get acquainted with the key combination Ctrl+Shift+F) and in the examples located on this site (Code Base - a powerful thing, if you know how to use it).

 

Question about the Sleep() function. Do I correctly understand that using this function in an Expert Advisor halts execution of that EA only, and transfers CPU resources (kernel) to the next tasks in the list of tasks of that kernel? In other words, is it correct that the Sleep() function does not slow down the thread itself where the Expert Advisor is being processed, but acts as a switch between the current Expert Advisor and other programs picked up by a particular kernel?

Документация по MQL5: Общие функции / Sleep
Документация по MQL5: Общие функции / Sleep
  • www.mql5.com
Общие функции / Sleep - Документация по MQL5
 

Question about MqlTradeResult structure. I haven't found time field in it - time of successful basic request check (or something like that). Does anybody remember if there was a question about introducing an additional time field into MqlTradeResult structure? Needed for pulling out a pending order if it suddenly goes into history.

Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса - Документация по MQL5