[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 236

 
solnce600:
I'm not quite sure what binary search means. Is it a search in a two-dimensional array? But I have a one-dimensional one.

Sort the array, if you haven't done it so far, and for control of correct preparation in init() unprint its content, not all but the first 20-50 elements.

P.S. Do you see the identity of binary and two-dimensional? The terminal sees your digits in "binary" code and for correct work of the ArrayBsearch() function, it requires preliminary sorting of the array.

 
TarasBY:

You don't see anything there???

I see that ArrayBsearch() returns 0 (as an element index) EVERYWHERE. In the 0th cell of your array is the number 1.0408. Let's go back to the code:

Now substitute the obtained variable values in this condition (on the carite Bid is in the range 0.8-0.9, let's take the maximum of this range - 0.9): if (0.9000 - 1.0408 <= 0) OrderSend(). The condition is fulfilled RIGHT!!! Look for errors in completing your array. You presumably did not pay attention to this clause in the ArrayBsearch() function:

Note: Binary search only handles sorted arrays. The ArraySort() function is used to sort a numeric array.

P.S. Print should not be provided as picture, but by simultaneous selection of several lines (using SHIFT - if you don't know how to do it) of this very print (10-20 lines is enough) in terminal window, then copy and paste selected lines in your post as code with SRC button.

I understood that the problem is in ArrayBsearch() function

But I still do not understand why this function should not immediately return the single N item of the array with the value closest by value to value

Why else should massiv[S-1] and massiv[S+1]participate in calculations ?

 
solnce600:

I understand that the problem is in ArrayBsearch() function

But I still do not understand why this function should not immediately return the single N item of the array with the value closest by value to value

Why else do massiv[S-1] and massiv[S+1]participate in calculations ?

The problem is not in ArrayBsearch() function, but in preparation of array passed into this function!!!

And then it's just a "flight of fancy"... Your imagination...

The ArrayBsearch() function returns the ONE value, and in order to find the cause of the code's crookedness, I printed out the values: (in order) the value of array cell with index S (it was returned by function ArrayBsearch()), the value nearest to the left in the given array (massive[]) with index S-1, the value nearest to the right with index S+1, price at the moment of order opening.

You came to 1st grade, and you are trying to peek into a graduating class... Go back to your class!!! - analogy. :))

 
TarasBY:

The problem is not in the ArrayBsearch() function, but in the preparation of the array passed to this function!!!

And then it was just a "flight of fancy"... Your imagination...

The ArrayBsearch() function returns the ONE value, and in order to find the cause of the code's crookedness, I printed out the values: (in order) the value of array cell with index S (it was returned by function ArrayBsearch()), the value nearest to the left in the given array (massive[]) with index S-1, the value nearest to the right with index S+1, price at the moment of order opening.

You came to 1st grade, and you are trying to peek into a graduating class... Go back to your class!!! - analogy. :))

Got it. Thanks very much for your help.... I'm always in a bit of a hurry and getting ahead of myself.... I think there are more pros than cons to this overall.

The only thing I don't understand yet....

Here I need to initialize an array with 3000 values.And I did it using EXCEL.

It seemed to me this long, multi-step and tedious process.

Are there any better algorithms for this process?

Thanks.

 
solnce600:

I did it using EXCEL.


Through DDE or through Lazybones?

Write a macro and automate it, if you have a history. You open it in Word with macro writing enabled, convert it there, then save it to csv with macro and use DDE. I don't know about metatrader and metastock data files format, I have no time to understand it myself. And if double array[3000] with zeros, then use for, but they are initialized with zeros, if I'm not mistaken.

 
solnce600:
Got it. Thanks a lot for your help.... I'm always in a bit of a hurry and getting ahead of myself....I think there are more pros than cons to this overall.

The only thing I don't understand is....

I need to initialise an array of 3000 values, and I've been doing it using EXCEL.

I found it to be a long, multi-step and tedious process.

Are there any better algorithms for this process?

Thank you.


Please post the file where the initialisation values are written...
 
gyfto:


Through DDE or through the Loafer?

Write a macro and automate it, if you have a history. Open it in Word with macro writing enabled, convert it to Excel, save it as a csv macro and use DDE. The format of metatrader and metastock data files is not up to me, I have no time to figure it out. If by zeros, then through for, but zeros are initialized, if I'm not mistaken.

Thanks, I'll study it. I just went to Service - saved the history of a pair in EXCEL file.

I split a single column with all data by columns, put a comma after each value in the column with opening prices - transpose it into a line - sorted - and paste it into the editor, i.e.

included mqh file.

If there are references to DDE or Lazybear info, please give.

Thank you.

 
solnce600:

I simply went into Service and saved a couple's history to an EXCEL file.

I split a single column with all the data into columns. In the column with the opening prices, I put a comma after each value - transpose it into a line - sort it - and paste it into the editor, i.e. into the

included mqh file.

If you have references to DDE or Lazybear, please let me know.

Thank you.



You don't need DDE or lazybones. You just need a function (10 lines of code). Throw the file in the terminal directory and the array will be initialized... Give me the file.
 
Dima.A.:

You don't need a DDE or a Lazybones. You just need a function (10 lines of code). Throw the file in the terminal directory and the array will be initialized... Give me the file.

I need to initialise 2 arrays

1.double

2.datetime

In the first array, some values after line 1120 for some reason - they converted to a different format after I changed the separating sign from comma to dot.(I had a comma there)

If not difficult please send me these 10 lines of code as well ...... I will study them.... I want to learn to do it myself in future.

Thank you very much for your help.

 
solnce600:
Strange, the file is 140 kilos, I've archived it and attached it to the post..... and it's not there.


Cut the file down, I only need a couple of lines in it...
Reason: