• Get access

Extend MQL!! - page 3

To add comments, please log in or register
forexaim
47
forexaim  

do you guys recommend VSP?

Brandon Wilhite
163
Brandon Wilhite  

Extend MQL!!

I have had enough!!

Enough of re-writing code. Enough of writing very basic functions that, IMO, *should* be a part of MQL. So I'm going to do something about it. I've started to develop a set of libraries to extend the functionality of MQL. Yes, I know that I can use DLLs and extend MQL that way, but frankly for a lot of this stuff I shouldn't have to! Besides, I still can't compile a DLL that works with MQL to save my life!

So, over time I'll be posting the libraries that I develop that I think will have general interest and purpose. Before going further I just want to note that these technically aren't MQL libraries, but includes, so they go in the "Include" folder. I'll start with three.

1) My "General Library.mqh" contains some generalized Date/Time functions (like ConvertToGMT, Increment/Decrement Date and some other useful ones), some generalized trading functions (PctBarCross and things like that), and some all out general functions! (Like an array search that will work with any type of array.)

2) My "Account Manager Library.mqh" contains some functions for a utility I'm writing called, you guessed it...Account Manager. Of particular note in this library are the Reporting functions which I am using to write out reports of my account activity on a daily basis (which I will then link to an Access database and also Excel for the purpose of gathering statistics...any volunteers?). There are also some nifty little functions in there to facilitate implementing a 'margin siren.' When your account margin comes close to a defined limit it calls a little windows program I wrote that plays a tornado siren.

3) "Shell.mqh" IS NOT MINE, IT BELONGS TO CODERSGURU. I hope he doesn't mind my posting this here, but for completeness sake it is necessary because the margin siren makes use of this file. THANK YOU CODERSGURU!!! If you have a problem with this PM me and I will remove it.

If I am re-inventing the wheel with all of this please kindly inform me as I have better things to do with my time!

I would really like to see this thread develop into a sort of open-source extensibility project, but I'm not going to hold out hope for that. There are many helpful people on this forum, to which all I say 'thank-you,' including CodersGuru and DwMcQueen in particular. But...I've learned that if you want something done you're probably going to have to do it yourself and do it alone. So I'll be occassionally posting updates here and stopping by. Feel free to leave suggestions/requests/and bugs that you find!

Right now the #include file paths are specific to my setup...something I've gotta change. But I figured it was better to just go ahead and get the ball rolling than to wait for perfection.

It's time that we started to help MQL grow up!

Brandon Wilhite

Gee....all that typing and now I can't get the files to attach!

I'll try again later, promise.

3-5-7 Ok, for some reason the forum wouldn't allow me to upload the files with '.mqh' extension so I converted them to '.txt' and attached them that way. If anyone knows what I'm doing wrong please PM me or post here. Also, the margin siren itself would not attach, it is an '.exe' file. It's just a simple little program that loads a window and plays a tornado siren. If you want it let me know and I'll send it to you.

3-6-7 Per prasxz' excellent suggestions, here they all are zipped. The margin siren is now included. Just point the path in CheckMargin() or MarginSiren() to wherever you put this. Warning: it's loud and annoying, especially to wives! But it gets your attention, which is what it is supposed to do

3-7-7 Uploaded .txt file with definitions from current version of General Library

prasxz
1259
prasxz  

hi

Thanks for effort I'll try it first...:)

You can zip your files then upload it here....

===================

Forex Indicators Collection

Amritendu Maji
1448
Amritendu Maji  

Thanks Brandon for the nuggets of gold.

omelette
784
omelette  

Excellent, well done!!!

Brandon Wilhite
163
Brandon Wilhite  

Encouraging so far...but wait until you try them !

If you find any bugs let me know. The date/time functions ARE NOT supposed to be hemisphere and timezone specific. If you find them not working for you please let me know and I'll try to figure it out. I live on EST.

BW

ryanklefas
598
ryanklefas  

Thanks. This library looks like it will be very helpful.

Eric Venturi-Bloxs
1064
Eric Venturi-Bloxs  

I coded like this and it works good:

total = OrdersTotal();

int j, orders;

for(j=0;j<total;j++)

{

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) orders++;

}

FerruFx

Yuri Predborski
561
Yuri Predborski  
pengie:
I noticed a lot of programmers are using OrdersTotal() to get the total number of orders in order to determine whether to open a new position or not.

Well... Thanks... Really... You are one smart guy, you know?

But I don't think everyone wants to use a bicycle with automatic transmission and nitrous....

What I mean:

Instead of plain OrdersTotal() make a counter like

int OrdersTotalExpert1=0;

if(MagicNumber==MagicNumberExpert1)

OrdersTotalExpert1++;

any problem using that?....................................................

FerruFx

if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) orders++;

thanks

thats the same thing I'm talking about

BUT

please

use

if(OrderSymbol()==Symbol())

{

if(OrderMagicNumber()==MagicNumber)

...

}

instead. that saves time.

DON'T put && into if's - that really slows them down. I've already re-wrote some experts into that way and guess what - they work up to 10 times faster (each condition is checked if && is used, even if one is FALSE, others are still checked. if you use separate if's you save time because you stop at first FALSE you get)

I hope this helps...

ryanklefas
598
ryanklefas  
FerruFx:
I coded like this and it works good:

total = OrdersTotal();

int j, orders;

for(j=0;j<total;j++)

{

OrderSelect(j, SELECT_BY_POS, MODE_TRADES);

if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) orders++;

}

FerruFx

The majority of people make their EAs just like that, myself included. Plus, any additional data you want to include for the order criteria can be included in magic number (such as timeframe) which I also do.

To add comments, please log in or register