1. Advanced Guide To MetaTrader 4 - Introduction
  2. Advanced Guide To MetaTrader 4 - Automated Trading
  3. Advanced Guide To MetaTrader 4 - Expert Advisors
  4. Advanced Guide To MetaTrader 4 - Custom Indicators
  5. Advanced Guide To MetaTrader 4 - Scripts
  6. Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization

Scripts are programs that are intended to perform a single action. Unlike an indicator or Expert that works continually, a Script stops functioning once it has completed its function one time. Like Custom Indicators, Scripts are created, setup and launched in much the same manner as Experts. When launching the Experts Wizard, select "Scripts" as the object to be created. Continue in the same manner as creating an Expert or Custom Indicator (see the Expert Advisor Creation and Custom Indicator Creation sections of this tutorial).

To set up Script parameters, open the Options window and select the "Expert Advisors" tab. To open the window:

  • In the Main Menu > Tools > Options; or
  • Pressing CTRL + O on the computer keyboard.
Five options influence the operation of Scripts:

  • Allow live trading - to enable Experts in real-time mode (rather than testing an Expert on historical data).
  • Ask manual confirmation - to send trade confirmation prior to submitting the order.
  • Allow DLL imports -to use DLLs to enhance Expert functionality.
  • Confirm DLL function calls - to allow control over the execution of each called function.
  • Allow external experts imports - to allow the Expert to access functions from other Experts or MQL4 libraries.
Removing a Script
A Script automatically shuts down once it has completed its function one time. Traders can, however, remove a Script manually. To remove a Script from a chart, right-click on the chart and select "Remove Script," as shown in Figure 20.

Figure 20 - To remove a Script from a price chart, right-click on the chart and select "Remove Script" from the chart context menu.

Options for Non-Programmers
People who are not interested in learning how to program in the MQL4 language can still take advantage of Experts, Custom Indicators and Scripts. A growing number of commercially available products can be purchased at various trading-related businesses online, and MT4 users can also hire a qualified MQL4 programmer to perform the coding.

It is important to note that when working with a programmer, all ideas must be quantifiable and objective. For example, if the trader wants to enter a long position when price goes above a moving average, he or she will have to specify the moving average length, the precise entry point (next bar on open, for example) charting interval and even the trading instrument. Most programmers will not accept jobs that entail a lot of guesswork on the part of the programmer, and so project specifications need to be absolutely clear.

In general, if a commercial Expert, Custom Indicator or Script has been purchased, it will come with specific installation instructions. Similarly, a programmer will typically include instructions for installation. It is always valuable to read the instructions before attempting the installation to avoid any complications.

Advanced Guide To MetaTrader 4 - Strategy Testing And Optimization

Related Articles
  1. Investing

    This Leader Is 18% Undervalued... And That's Just the Beginning

    Trading on headlines can be some of your best investments on the long- or short-side. Investors get so caught up in the herd mentality that even headlines with little real fundamental importance ...
  2. Small Business

    How Express Scripts Makes Money

    The pharmacy benefit manager claims to lower prescription drug costs for consumers, medical providers, and health insurance companies and makes a tidy profit along the way.
  3. Investing

    Streaming Services Spur Record Scripted Shows This Year

    The number of scripted shows on television will reach record highs this year and streaming services are responsible for the record.
  4. Investing

    Express Scripts Names a New CEO (ESRX)

    The doctor, it seems, has ordered a change in management. That's the case at prescription drug benefits manager Express Scripts (NASDAQ: ESRX), which this week named its new CEO. The man tapped ...
  5. Personal Finance

    Amazon Studios vs. Hollywood: Is Netflix the Better Pick? (AMZN, NFLX)

    Amazon Studios is a relatively new division of Amazon that is trying to revolutionize Hollywood. While it may succeed, is Netflix actually the better option?
  6. Personal Finance

    Establishing Yourself As An Expert

    Here are some tips on putting yourself on the path to becoming an expert in a field.
  7. Insights

    3 Of History’s Largest Acquisitions

    The largest acquisition of 2011 was barely one-sixth the size of the largest from a dozen years ago. Find out what they were.
  8. Investing

    Top 5 Positions in Morgan Stanley's Portfolio (MS, SPY)

    Learn about Morgan Stanley and the type of business it operates. Understand what makes up its portfolio as well as the top five positions in its portfolio.
  9. Trading

    Using Technical Indicators To Develop Trading Strategies

    Unfortunately, there is no perfect investment strategy that will guarantee success, but you can find the indicators and strategies that will work best for your position.
Frequently Asked Questions
  1. Depreciation Can Shield Taxes, Bolster Cash Flow

    Depreciation can be used as a tax-deductible expense to reduce tax costs, bolstering cash flow
  2. What schools did Warren Buffett attend on his way to getting his science and economics degrees?

    Learn how Warren Buffett became so successful through his attendance at multiple prestigious schools and his real-world experiences.
  3. How many attempts at each CFA exam is a candidate permitted?

    The CFA Institute allows an individual an unlimited amount of attempts at each examination.Although you can attempt the examination ...
  4. What's the average salary of a market research analyst?

    Learn about average stock market analyst salaries in the U.S. and different factors that affect salaries and overall levels ...
Trading Center