Anyone know how to develop a multicurrency indicator ? - page 2

 

The first time you call ACR you get error 4066. That's it. Call it again and you get a valid count but no data in the arrays. Accessing the arrays will not result in out of range.

 
WHRoeder:

The first time you call ACR you get error 4066. That's it. Call it again and you get a valid count but no data in the arrays. Accessing the arrays will not result in out of range.

I have to disagree, as I am not seeing what you have just described. However, this may be due to the fact that most of the time on my Real Live usage, all the data is usually available, and on my demo/test environment I have generated ".hst" and ".fxt" from external data.

I will try to re-create the "clean slate" conditions of no local data and see if I can replicate what you are describing.

 

I have re-created the "clean slate" conditions and coded a small script to test this in a continuous loop with no sleep function. I ran the script twice against a "EURUSD" chart, but had the code request data on "NZDCAD" which was never loaded before.

The results on the first run are as follows.

  • During the first 73607 iterations (that lasted approximately 516ms), the “ArrayCopyRates” always returned a count of -1, and generated an 4073 error (Error 4073 - No history data). The array size was always 0 during these iterations.
  • Finally on the 73608th iteration, it returned a count of 512 and the array size was set to 512 as well and the time for the 0th element had a valid time (and not 0) and no errors were generated.
I then did a second run of the Script, since the data was already loaded and these were the results:
  • During the first and only iteration, the “ArrayCopyRates” returned a count of 2048 but generated an 4066 error even though the return count was valid (Error 4066 - Requested history data is in updating state). The Array size was also 2048 and the time for the 0th element was valid (and not 0).
I have attached a ZIP file with the test script as well as the resulting log files.

A leave you to draw your own conclusions!

PS! My conclusion, is to combine all the tests before proceeding. (i.e. test the return code of  “ArrayCopyRates”, check the error codes, test the array size of the MqlRates array and (as a safe guard as WHRoeder suggests) also test the validity of the date of the array elements.

EDIT: Had I solely used the "pair[0].time == 0" test, it would of given an array index error (and caused execution to halt) during the first iterations of the first run when no data was available. Therefore, I stand by my statement, that one needs to check the return code and array size, but agree that the time test can offer a subsequent level of verification once the other conditions have been met.

Files:
testacr.zip  217 kb
 
Strange, as how there has not been a single comment by the original poster since this thread was started. Is he even following this?
 
FMIC:
  • During the first 73607 iterations (that lasted approximately 516ms), the “ArrayCopyRates” always returned a count of -1, and generated an 4073 error (Error 4073 - No history data). The array size was always 0 during these iterations.
  • Finally on the 73608th iteration, it returned a count of 512 and the array size was set to 512 as well and the time for the 0th element had a valid time (and not 0) and no errors were generated.
This is just the opposite behavior of the pre-build 600 version.
This is what I originally expected but had been proven wrong.
They finally got it right and I will note this for the future.
 
FMIC:
 

EDIT: Had I solely used the "pair[0].time == 0" test, it would of givenan array index error (and caused execution to halt) during the first iterations of the first runwhen no data was available. Therefore, I stand by my statement, that one needs to check the return code and array size, but agree that the time test can offer a subsequent level of verification once the other conditions have been met.


This is all very useful, thanks for the research and results.

 
FMIC:
Strange, as how there has not been a single comment by the original poster since this thread was started. Is he even following this?

Why should he/she be following this post, the subsequent posts have gone way beyond the level of understanding for most people in this forum.

How about trying to just answer the question in simple and precise manner !

 

Now to answer the original question just in case there is a small chance the original poster is still around, Google is your friend. 

 
4x_Gypsy:

How about trying to just answer the question in simple and precise manner !

We did answer the question which was in essence: "I want to choose BETWEEN 1 to 10 different currencies and 5 bars for each currency."

Since, he did not supply any example code, or more details, it was not possible to give a simple and precise answer. All we could do was provide general answers and an awareness of the problems that he would face. We answered that he should use of "ArrayCopyRates()" or using the "iFunctions()" and that he would need to keep track of the inherent delay and errors he would obviously get. We then supplemented the information by discussing the pitfalls and problems, such as the lack of the sleep function in Indicators and the different behaviors between pre-600 and post builds.

If you say, this was all over his head, all he had to do was to post something to the effect of: "Sorry, I don't understand! Can you simplify it for me!". But since there was never any such post (or any other for that matter), the discussion continued in the belief that he and others were able to follow it.

Now, as you wrote, he could use Google and find many Multi-time-frame Indicators out there, but if he still does not know HOW it works, he won't get very far in making his indicator work as he wishes.

EDIT: PS! NB! After thinking about it again, WHRoeder did actually provide skeleton code as a solution to the problem. You can't get more simple and precise than that, given the lack of details in the original question.

 
FMIC:

We did answer the question which was in essence: "I want to choose BETWEEN 1 to 10 different currencies and 5 bars for each currency."

Since, he did not supply any example code, or more details, it was not possible to give a simple and precise answer. All we could do was provide general answers and an awareness of the problems that he would face. We answered that he should use of "ArrayCopyRates()" or using the "iFunctions()" and that he would need to keep track of the inherent delay and errors he would obviously get. We then supplemented the information by discussing the pitfalls and problems, such as the lack of the sleep function in Indicators and the different behaviors between pre-600 and post builds.

If you say, this was all over his head, all he had to do was to post something to the effect of: "Sorry, I don't understand! Can you simplify it for me!". But since there was never any such post (or any other for that matter), the discussion continued in the belief that he and others were able to follow it.

Now, as you wrote, he could use Google and find many Multi-time-frame Indicators out there, but if he still does not know HOW it works, he won't get very far in making his indicator work as he wishes.

EDIT: PS! NB! After thinking about it again, WHRoeder did actually provide skeleton code as a solution to the problem. You can't get more simple and precise than that, given the lack of details in the original question.

 The question was "Anyone know how to develop a multicurrency indicator ?".

The obvious answer was "Yes we (FMIC and WHRoeder) do just watch us discuss it", without asking or waiting for details into what the OP actually needs.

What he/she wanted to do with that indicator was "I want to choose BETWEEN 1 to 10 different currencies and 5 bars for each currency."

Yes examples were provided. But they were provided as more of contest between you two. Interesting debate? Yes. I learned something I didn't know. Was the example provided in such a way a newbie may be able to understand? Not so much. People come to this forum because of the lack of assistance and tutorials from MetaTrader. Most people who post here have a minimum understanding of what they wish to do and when the discussion goes too far pass their understanding they wander away. Which is a absolute shame.

Big clue was "But i don't know how to do this.". 

From the lack of any kind of response from the OP is a indication that there is something wrong. My "guess" is the OP got frustrated from the lack of understanding and abandoned the thread. There was a time years ago when I did the same thing. I learned more from different sites/forums than this one because nobody was taking the time to realize how new I was and continually posted examples and had discussions completely above my understanding at the time.

But none of that matters anymore since the OP has disappeared. 

Again this is a shame, who knows this person may be or become the next guru this and other forums need so badly. 

 
4x_Gypsy:

Big clue was "But i don't know how to do this.". 

From the lack of any kind of response from the OP is a indication that there is something wrong. My "guess" is the OP got frustrated from the lack of understanding and abandoned the thread. There was a time years ago when I did the same thing. I learned more from different sites/forums than this one because nobody was taking the time to realize how new I was and continually posted examples and had discussions completely above my understanding at the time.

From your viewpoint you might be right, on the other hand I have seen many many questions which simply were answered if one risks a quick look in the documentations and I really feel being a fool answering those kind of questions again and again.

Further there is google and a search option here. If I don't know how to do something this would be my next step trying to solve the problem on my own.

Now to the topic of this thread: "...how to develop a multi-currency system". That sounds to me like "teach me coding for free" which is pretty close to "can you code that for me". All this is not quite serious.

As there is so much code available for free my answer to this would have been: "Use google or the search here to find free code and change it!"

If people are offended by this I think it's their problem.