[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 406

 

Hi all.

I need a function, or an operation, which would give the last x values from a number.

For example there is a number 123456789, variable x = 4. The result should be 6789, i.e. the last 4 characters of 123456789

 
Killa:

Hi all.

I need a function, or an operation, which would give the last x values from a number.

For example there is a number 123456789, variable x = 4. The result should be 6789, i.e. the last 4 characters of 123456789

First DoubleToStr(), and then try StringSubstr() searching for a substring
 
Thank you all for responding to the question.
 
Killa: For example, here is number 123456789, variable x = 4. The result should be 6789, that is the last 4 characters of 123456789

Source number is A. Result is integer variable result.

int x = 4;

int A = 123456789;

int divisor = MathPow( 10, x ); /// 10^4

int result = A % divisor; /// остаток от деления А на divisor


If you want to speed up calculations, instead of MathPow() just make a loop of multiplication of tens - it will still be faster, and much faster.

 
Dear Experts! Looking for a script that opens orders when the normal SMA crosses the horizontal line on the chart. If the SMA crosses the line from below - buy, opposite - sell. The trades are on the close of the candle. Can you give me a link where to find it, if it has been posted.
 
Colleagues, please advise what and where to change in the EA code to work in a brokerage company with five-digit quotes.
 
NIKOLAStaom:
Dear Experts! Looking for a script that opens orders when the normal SMA crosses the horizontal line on the chart. If the SMA crosses the line from below - buy, opposite - sell. The trades are on the close of the candle. Can you give me a link where to find it, if it has been posted.
1. Apparently not a script, but an EA that constantly tracks the crossovers and opens orders.
2. The easiest way is to find an EA that works on MA crossings and prescribe a horizontal line level instead of one of the MAs.
3. An example of search in the base of the Expert Advisor on MA crossings. http://www.google.ru/search?as_sitesearch=mql4.com&as_q=советник by MA crossings
 
Bihkul:
Colleagues, please advise what and where to change in EA code to work in DC with five-digit quotes.
First, look at TP and SL. What and where to change - depends on the logic of a particular EA. For example ТР and SL may be expressed not in points but in percentage points of securities or of the price and won't depend on the number of digits of brokerage companies.
 

Dear colleagues, I don't have much programming experience yet, so I'm asking for advice. It is not always possible to get the value of a variable via some function, but it is possible to write out all the values in the required range in advance. You will get something like this

if (a==17) b=1329;

if (a==243) b=15;

And so on. But what to do if there are about a thousand of such strings? Shall I create a file? But how can we quickly find the value of "b" by the value of the "a" variable, especially since the "a" variable is not numbered consecutively? And so that there would be no lags ?

 
Elenn:
...But what if there are about a thousand such lines? Create a file? But how to quickly find the value of variable "a" and immediately find the value of "b", taking into account the fact that the numbering of "a" is not consecutive? And so that there would be no lags ?
Array.
Reason: