Array parameters

 

Hi there,


I'm just getting started with MQL4 but I'm not new to programming.


I've had fun setting up a few indicators preparatory to writing some EAs to implement and test trading strategies.


Can anyone tell me how I pass array parameters?


For example I want to take a mean of a range out of a time series with something like:


double ts_mean(double range[],int end, int start=0){
   //
   // Return the arithmetic mean of the specified range of the specified time series
   double sum=0.0;
   for(int i=start; i<end; i++){
      sum+=range[i];
   }
   return(sum / (end-start));
}
This wont compile and I believe its because of my attempt to define the input array with c syntax.
 
whippy:

Hi there,


I'm just getting started with MQL4 but I'm not new to programming.


I've had fun setting up a few indicators preparatory to writing some EAs to implement and test trading strategies.


Can anyone tell me how I pass array parameters?


For example I want to take a mean of a range out of a time series with something like:


This wont compile and I believe its because of my attempt to define the input array with c syntax.

Solved this myself with the list that came up after the post - I tried searching before posting - how do I search to see that list before asking the question?

 

Hello whippy

That list, with the lightbulb top left corner?... is I'd imagine thread context sensitive and pulls up relevant topic headings. Should my imaginings be reasonable, then you cannot search for this list.

.

Searching???

1. have you learned to use MetaEditor's context sensitive help?

2. The location of items is somewhat hit 'n miss at times but perseverance is KEY to anything on this site or within the ClientTerminal realm :)

3. You will most certainly find ALL that you need in the editor docs related to functions, formal arguments,... is all there.

4. Also, you can find much info with pretty pics by diving into THE BOOK - see link top all site pages.

5. Also, Articles..., see link top all site pages. They offer a massive wealth of ideas and things to learn

6. perseverance*10 to the sixth is all that is required - nothing more

7. use Print() freely = your window into your code and surely... is the most valuable builtin you will ever use!!!

8. use (7) in making up quicky scripts to test out single concepts - keep it simple - scripts are like couple second's affairs and your friend at all times when it all seems to be going pear shaped :)

.

Regards

 
fbj:

Hello whippy

That list, with the lightbulb top left corner?... is I'd imagine thread context sensitive and pulls up relevant topic headings. Should my imaginings be reasonable, then you cannot search for this list.

.

Searching???

1. have you learned to use MetaEditor's context sensitive help?

2. The location of items is somewhat hit 'n miss at times but perseverance is KEY to anything on this site or within the ClientTerminal realm :)

3. You will most certainly find ALL that you need in the editor docs related to functions, formal arguments,... is all there.

4. Also, you can find much info with pretty pics by diving into THE BOOK - see link top all site pages.

5. Also, Articles..., see link top all site pages. They offer a massive wealth of ideas and things to learn

6. perseverance*10 to the sixth is all that is required - nothing more

7. use Print() freely = your window into your code and surely... is the most valuable builtin you will ever use!!!

8. use (7) in making up quicky scripts to test out single concepts - keep it simple - scripts are like couple second's affairs and your friend at all times when it all seems to be going pear shaped :)

.

Regards

Thanks for the pointers, fbj.


I'll find out more about the context sensitive help.


You are right, I was referring to the 'tips list' and its a shame I can't search on that basis because it gave me exactly what I wanted. After being driven mad with the bell when using Alert(...) I switched to using Print() - How do I clear/reset the Expert window (from code and/or from the GUI)?


I have found THE BOOK and the reference documentation very valuable, if a little hard to access effectively. The source indicators that came with the platform and other code examples have also been extremely useful.


I will persevere!

 

Hello hippy,

"How do I clear/reset the Expert window (from code and/or from the GUI)?"

unsure. anyway, the tabs are scrolling so not going to see that much.

afaik, they clear out when kill app and restart, else they just pushdown, eg, my pc 24/7 with editor and terminals on all times, so the tabs hold many days...

I do quicky sunday restart to let windoz sort it's internals out... and that's it.

.

Coool!

The Book and articles etc. are really VIP items.

I confess to not looking at it all but I am always surprised at what is there when I do poke around and for sure is always something interesting to read and learn about.

The reading about helps me to firm up on my ideas and ultimately crushes many of them too! - lol

.

Really enjoy the trip - is great fun [at times;] and just maybe we achieve financial freedom!!!

 
fbj:

Hello hippy,

"How do I clear/reset the Expert window (from code and/or from the GUI)?"

unsure. anyway, the tabs are scrolling so not going to see that much.

afaik, they clear out when kill app and restart, else they just pushdown, eg, my pc 24/7 with editor and terminals on all times, so the tabs hold many days...

I do quicky sunday restart to let windoz sort it's internals out... and that's it.

.

Coool!

The Book and articles etc. are really VIP items.

I confess to not looking at it all but I am always surprised at what is there when I do poke around and for sure is always something interesting to read and learn about.

The reading about helps me to firm up on my ideas and ultimately crushes many of them too! - lol

.

Really enjoy the trip - is great fun [at times;] and just maybe we achieve financial freedom!!!

Thanks again,


Financial freedom is the goal but it could be a long way off.


Building indicators and EAs to implement trading strategies is certainly a good way to prove and then crush most ideas - I just hope I have a few good ones left at the end of it :)

Reason: