You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Some things to add as EA options:
- unique magic number calculation, maybe foolproof to give the same result when broker changes symbol name (for example from "EURUSD" to "EURUSD.m")
- order management options (trailing stop, break even (these in pips or other values like psar, x bars high/low, ma, etc.), order close)
- extensive order info handling by order ticket (for which a text (or csv) file seems to be the simplest appropriate way). GV is limited, OrderComment() may be changed by the broker.
I am a bit worried about sharing my custom indicators and EAs because if I did and everyone started using them they wouldn't work any more... Does anyone else agree?
I know this sounds a bit selfish... but when I get to 5 million I will share ;-)
Hello guys, is the example in MQL4 tutorial just enough if we only want simple and general solution ?
My EA trade and do calculation per bar and not per tick.
int Fun_Error(int Error) // Function of processing errors
{
switch(Error)
{ // Not crucial errors
case 4: Alert("Trade server is busy. Trying once again..");
Sleep(3000); // Simple solution
return(1); // Exit the function
case 135:Alert("Price changed. Trying once again..");
RefreshRates(); // Refresh rates
return(1); // Exit the function
case 136:Alert("No prices. Waiting for a new tick..");
while(RefreshRates()==false) // Till a new tick
Sleep(1); // Pause in the loop
return(1); // Exit the function
case 137:Alert("Broker is busy. Trying once again..");
Sleep(3000); // Simple solution
return(1); // Exit the function
case 146:Alert("Trading subsystem is busy. Trying once again..");
Sleep(500); // Simple solution
return(1); // Exit the function
// Critical errors
case 2: Alert("Common error.");
return(0); // Exit the function
case 5: Alert("Old terminal version.");
Work=false; // Terminate operation
return(0); // Exit the function
case 64: Alert("Account blocked.");
Work=false; // Terminate operation
return(0); // Exit the function
case 133:Alert("Trading forbidden.");
return(0); // Exit the function
case 134:Alert("Not enough money to execute operation.");
return(0); // Exit the function
default: Alert("Error occurred: ",Error); // Other variants
return(0); // Exit the function
}
}
This may be the basis of a really good EA Shell /Template: WHR is an experienced MT coder.
It was originally intended as a source of useful EA code, it is not a "plug and play" Shell.
I have updated this EA in a couple ways:
1. I modified syntax, variable names so it compiles in current versions of MQL4.
Also added very minor changes so it compiles, commented with "Big Be".
2. Incorporated all the additional code sections that WHR put in the thread.
I left in place but commented out the sections that got replaced.
Errors in adding these sections are possible, though I was as careful as possible.
Lack of full integration with the rest of the EA is also possible.
3. Also I ran it through a program that cleans up the text format for readability.
It will start to run in the Strategy Tester.
It will not take trades, as the entry rules setup is left to you.
I have not taken it further as I have other demands on my time.
WORK NEEDED:
Although there are comments throughout, many need clarifying. Or writing if non-existent. What does each section or function do?
One Example: CallAgain() says "Skip useless ticks". What is the method or logic? It is probably only taking ticks that are far enough away and / or are in the trade direction if a Trailing Stop, but it will take some study to verify.
Doing this will make it better fulfill its role as a source of ideas, and further enable workability as an EA shell / template.
FURTHER TESTING:
Add some entry rules, and test that each section is doing what it is supposed to. This takes a lot of study in the Strategy Tester. And probably some coding here and there to get it to do what it is supposed to. When it works there, then a lot of testing on a demo account.
WARNINGS:
At least one function is incomplete, and there may be errors in this code, or changes in Metatrader since the whrea was written that are not allowed for.
To code / use an EA without understanding it is kind of like trying to fly a jet without understanding all the controls and how to use them.
But, do as you wish: it's your money.
REQUEST
Please help if you have the wide knowledge necessary and a bit of time.
Big Be (BigBe)
Please could you explain what pips2dbl is?
To convert PIPs to a tick.
What is a TICK? - MQL4 programming forum
Using Point means code breaks on 4 digit brokers, exotics (e.g. USDZAR where spread is over 500 points,) and metals. Compute what a PIP is and use it, not points.
How to manage JPY pairs with parameters? - MQL4 programming forum
Slippage defined in index points - Currency Pairs - Expert Advisors and Automated Trading - MQL5 programming forum