Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 178
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Yes, thank you!
No, but thanks anyway!)Good evening.
When using iOpen a shift is specified. If there is not enough history for the specified shifter, the iOpen of the oldest bar is returned.
Question: How can I make a check for a bar with the specified shifter? And in case there is not enough history, don't return iOpen?
Good evening.
When using iOpen a shift is specified. If there is not enough history for the specified shifter, the iOpen of the oldest bar is returned.
Question: How can I make a check for a bar with the specified shifter? And if there is not enough history, why should iOpen not be returned?
CopyOpen
The function receives history data of bar opening prices for a specified symbol-period pair into the open_array array in the specified amount. It should be noted that the counting of elements from the starting position is performed from the present to the past, i.e. the starting position equal to 0 means the current bar.
When copying an unknown quantity of data, we recommend using a dynamic array as the target array, because if the data is less (or more) than the array can hold, an attempt will be made to reshuffle the array so that the requested data can be copied in its entirety.
If it's necessary to copy a known quantity of data, it's better to copy it to a statically allocated buffer to avoid unnecessary memory overallocation.
Regardless of whether the as_series=true or as_series=false property of the receiving array, the data will be copied so that the oldest element will be at the beginning of the physical memory allocated to the array. There are 3 variants of the function.
Referencing by starting position and number of required elements
intCopyOpen(
stringsymbol_name,// symbol name
ENUM_TIMEFRAMEStimeframe,// period
intstart_pos,//where to start
intcount,// how many we copy
doubleopen_array[]// array for copying of opening prices
);
Accessing by start date and number of required elements
intCopyOpen(
stringsymbol_name,// symbol name
ENUM_TIMEFRAMEStimeframe,// period
datetimestart_time,// from which date
intcount,// how many we copy
doubleopen_array[]// array for copying of opening prices
);
Accessing by start date and end date of the required time interval
intCopyOpen(
stringsymbol_name,// symbol name
ENUM_TIMEFRAMEStimeframe,// period
datetimestart_time,// from which date
datetimestop_time,// till what date
doubleopen_array[]// array for copying of opening prices
);
Parameters
symbol_name
[in] The symbol.
timeframe
[in] Period.
start_pos
[in] Number of the first element to be copied.
count
[in] Number of items to be copied.
start_time
[in] Bar time corresponding to the first element to be copied.
stop_time
[in] The bar time corresponding to the last element.
open_array[]
[out] Array of type double.
Returned value
The number of copied array elements or -1 in case of an error.
Note
If interval of requested data is entirely outside available data on server, the function returns -1. If data outside TERMINAL_MAXBARS (maximum number of bars on the chart) is requested, the function will also return -1.
If the requested timeseries are not built yet or need to be downloaded from the server, the function will immediately return -1.
When requesting data from the Expert Advisor or a script, the loading from the server will be initiated, if the terminal does not have these data locally, or the building of the required timeseries will begin, if the data can be built from the local history, but they are not ready yet. The function will return the amount of data that will be ready by the timeout time, but the loading of history will continue, and the next similar request will return more data.
When requesting data by starting date and number of items required, only data with a date less than (earlier than) or equal to the specified one will be returned. At the same time, the interval is specified and taken into account to the nearest second. It means that the date of opening of any bar, for which the value is returned (volume, spread, value in the indicator buffer, price Open, High, Low, Close or open time Time), is always equal to or less than the specified one.
When requesting data in the specified date range, only data falling within the requested interval will be returned, and the interval is specified and taken into account to the nearest second. This means that the opening time of any bar for which a value is returned (volume, spread, value in the indicator buffer, price Open, High, Low, Close or open time Time), is always within the requested interval.
Thus,if the current day of the week is Saturday, then when trying to copy the data on the weekly timeframe, specifying start_time=Last Tuesday and stop_time=Last Friday, the function will return 0, since the opening time of the weekly timeframe always falls on Sunday, but no weekly bar falls into the specified range.
If we need to get the value corresponding to the current unfinished bar, we can use the first form of the call specifying start_pos=0 and count=1.
Greetings.
Gentlemen, can you tell me how to make a condition of price crossing levels with 1-2-3 zeros at the end?
Greetings.
Gentlemen, can you tell me how to make a condition of price crossing levels with 1-2-3 zeros at the end?
By comparing the past and current price value with this level, if the level is between these values then there has been a crossing.
By comparing the past and the current price with this level, if the level is between these values then a crossing has occurred.
How can I specify these levels for comparing?
Or - how do I specify that the number should have the right number of decimal places? Not by rounding but by deleting.
And how do I write these levels for comparison?
Or - how do I specify that the number should have the right number of decimal places? Not by rounding, but by deleting.
Here's the finding function.
Sergey Gritsay,Vitaly Muzichenko thank you.
I was also suggested function MathFloor() - Returns integer numeric value closest to bottom.
Dig MySQL.
Sergey Gritsay:
For this purpose you need to create a server outside your local computer and transmit data through this server. For MT an indicator or an Expert Advisor should be written to process this data, or terminals should be placed on some VPS-server and there you should set up trade copier from your account to your friends' accounts. Another option is to copy your trades executed on given levelsthroughsignalsservice. In general, you should consider your financial capabilities to order appropriate software.
MosheDayan:
Let me remind you of the prehistory. I have a daily indicator that gets data from csv and displays it (horizontal levels) on a chart. I have created a server from my home laptop (it's weak but I don't need calculations there and it will give me csvs and they are very small). On the server for the test connection poured the usual forum engine - everything seems to be visible from the outside. Help with advice. That should be on the server to read from it indicator csv files? I.e. how does the indicator communicates with the csv database? Maybe fill in the engine fTP server or something else and can for MT need to open some special ports? Or I got into the wrong direction in general? Thanks
Friends, can I ask you another question. Is it possible not to load a home laptop, but to use, to link the indicator with csv files, free cloud file storage such as, for example Yandex.Disk or Облако@mail.ru or Box.net etc. Thank you
Here's the finder's function