Function that returns an Array? - page 2

 
Nicholishen:
OK, I am successfully adding functions with pointers to libraries, and it works as long as I am passing an array. When I try to do it just referencing a single variable, I does not work in a library but works when the function is in the same source file as the start(). Can anyone advise as to why?

Nick

not sure what you ment by the question just above this post.

I tryed to warn that labrary modules function calls work very differently. You can pass arrays by referance to a library function but not simple varibles they are past by value only. Now if the function is discribed with in an include file, that is the function is totally decleared in the include file not imported into the file it will work just like if it were writen in the main run module. When you use the import comand it changes the way you do things. also If you are useing default values on some of your parameters they will not be reconized accoss modules either.

Hope that helps

The CockeyedCowboy

 

Question on Array, please help!

Hi,

I am new to using array, I managed to properly setup two single dimension arrays, namely Profit[] and MagicNo[].

I will try to explain what I would like to achieve using the following example,

Array# Profit[] MagicNo[]

[1] 30 100

[2] 5 101

[3] 10 102

[4] 40 103

[5] 5 104

I am trying to incorporate into my EA to pick out the first possible combination from longest profit to smallest profit, and the operation will break as soon as the total profit reaches a pre-determined amount, for example 50. Hence, the result should have been Array[4]+Array[1], then the outcome of the operation will be the associated MagicNo, so that the EA can properly close the associated opened position(s) with selected MagicNo. In this case, the outcome should be MagicNo[4] and Magic[1], which then in turns become 103 and 100.

I am not sure, but I believe I may need a third array to temporary store information.

I hope I have explained myself clearly.

Please kindly help, any contribution will be appreciated.

Thanks.

 
 

Thanks...

Many thanks cockeyedcowboy.

Initially, the reason why I had them setup as two arrays is because the profit array is a double type and the MagicNo array is a int type.

After looking at it, the MagicNo array has no reason that restrict it to be a double type. So I guess it is ok to apply a two dimensional array in double.

I am going to look into what you have suggested.

Thanks once again for boosting my learning curve ahead.

 

Passing Array Elements Between Arrays.

Can someone help me, I have spend hours trying to figure out how to pass array elements from one array to another so that I can display them in an indicator. I have looked at many indicators and still cannot get my array elements to show up in my indicator line. Attached is my program code.

Files:
 

Passing Array Elements Between Arrays.

Can someone help me, I have spend hours trying to figure out how to pass array elements from one array to another so that I can display them in an indicator. I have looked at many indicators and still cannot get my array elements to show up in my indicator line. Attached is my program code.

Files:
 
mcertini:
Can someone help me, I have spend hours trying to figure out how to pass array elements from one array to another so that I can display them in an indicator. I have looked at many indicators and still cannot get my array elements to show up in my indicator line. Attached is my program code.

You code doesnot make sence. Why not place the data directly into your indicator buffers? There is other problems in your code that needs correction, like redefineing the arrays as ArraySetAsSeries() on each pass of the while loop.

Give a little more information as to your plans. You dont need to give any information on the indicators themselfs just the operation and out come you are looking for.

I made an indicator pack that I called an iPack File. The iPack file construction could contain any number of different indicators. There are 3 different classifications of indicators that one could choose from. any one of or combinations of or all classes for viewing and data extrations. They only used two data buffers and one level line object. The key was to transfer the indcator array into the buffers at the time of viewing. You could only view one complete indicator at one time and they would rotate at a preselect interval between the indicator classes that were choosen. It was some thing that has not been done before and I spent a lot of time on it as MT doesnot make things easy. There are a few things that you must be for warn of; One the ArrayCopy() doesnot work for some reason the last bar the zero bar is not transfered. and you must empty the buffer each time before you fill it with data or your indicator will be set to the scale of the old data that occupied the buffer. There are a few more things that you have to do to get it to work for the amount of indicators I was working with anyways. I would have to go back to that code to refressh my memory. It was quit an undertaken but I did get it to work really nice.

as a sidebar: I also equipted the iPack to reject any probing for data by an EA. Any EA with the use of the iCustom() function could be shout out of the data stream altogether! It too could ask for any one of the avaiable indicators for data at will if it was granted permission to access the iPack.

I used the same techneque to print different screen pages of information to the screen of EAs. and to page through different screen graphics of out puts. here Iam running on again....

Keit

 

arrays

hey mc..... your code has several errors but even seeing those it's still not clear to me exactly what your trying to do.....

if your just trying to tie your alert to the macd, it might be simpiler just to include the alert line in the standard macd indicator......h

//---- signal line counted in the 2-nd buffer

for(i=0; i<limit; i++)

SignalBuffer=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);

Alert(SignalBuffer[0],"***",SignalBuffer[1],"***",SignalBuffer[2],"***",SignalBuffer[3],"***",SignalBuffer[4],"***",SignalBuffer[5]);

//---- done

return(0);

}

//+------------------------------------------------------------------+
 

Arrays

hayseed,

I am a newbie trying to learn how arrays work.

Thank you for the response.

 

Array problem and random generator

Hello coders,

i have a bug/problem with array's. i'm programming a multi-agent-system in mql4 and use array's. what i found out is that at array index 26 there is a bug.

then i created a new EA with only one array filling code in a for() loop i fill up arrays with random numbers and the same bug happens with index 26.there is nothing i mean NULL. this array index is empty. could someone confirm this?

is this really a bug?

another question. i need a better random number generator for mt4. the generator included in mt4 has to much cycles, patterns and not to much noise. do someone know a goog library?

thanks

PriNova

Reason: