0% found this document useful (0 votes)
25 views12 pages

V Terminal

This document provides instructions for using the manual trading strategy tester in MetaTrader 4. It describes downloading necessary files, setting up a chart template, configuring the expert advisor, and using the toolbox to manually place trades and orders for testing strategies without programming. The manual strategy tester allows visualizing and optimizing trading strategies through a graphical interface rather than programming an expert advisor.

Uploaded by

Arkip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views12 pages

V Terminal

This document provides instructions for using the manual trading strategy tester in MetaTrader 4. It describes downloading necessary files, setting up a chart template, configuring the expert advisor, and using the toolbox to manually place trades and orders for testing strategies without programming. The manual strategy tester allows visualizing and optimizing trading strategies through a graphical interface rather than programming an expert advisor.

Uploaded by

Arkip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Testing Visualization: Manual Trading Page 1 of 12

Testing Visualization: Manual Trading

Introduction
A function of testing visualization has now appeared in the MetaTrader 4 Client Terminal. The function allows controlling of
Expert Advisors' testing. But not every strategy can be programmed, not every trader can code a good Expert Advisor.
This article describes how to use visualizing function to test manual strategies that are not programmed in form of an
Expert Advisor. Only basic knowledge of the terminal and no knowledge of programming are needed to trade on Manual
Strategy Tester, so every trader will be able to use it.

The article mentions programs that realize 'Trade' and 'Account History' tabs during visualization. The use of these
programs is described in more details in articles named Testing Visualization: Functionality Enhancement and Testing
Visualization: Trade History.

If you have never worked with visualizer, you have to read the article named Testing of Expert Advisors in the MetaTrader
4 Client Terminal: An Outward Glance.

Preparation for Use

So you can use testing visualizer and would like to start testing your strategy immediately. What should be done for this?
First of all, download all necessary files from CodeBase to your PC:

n Expert Advisor vHandsTrade.mq4 to the directory of \MetaTrader 4 Work\experts\;


n the included file VisualTestingTools.mq4to the directory of \MetaTrader 4 Work\experts\include\; and
n 2 indicators - vTerminal.mq4 and vHistory.mq4 - to the directory of \MetaTrader 4
Work\experts\indicators\.

Note that file VisualTestingTools.mq4 mentioned in the preceding articles has been changed, so it is the version from
the above source (CodeBase) where you should download it from.

After that, open Expert Advisor vHandsTrade.mq4 in MetaEditor and compile it (use F5). Message in the "Tools" window
will confirm that the EA has been successfully compiled:

Now, when the program is ready, we can start preparing the chart template. To do it, open a chart, set it up according to
your taste, attach indicators vTerminal.mq4 and vHistory.mq4, and save the template as vHandsTrade.tpl:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 2 of 12

Please keep in mind that there must be enough space in the right part of the chart to work with Tester of Manual
Strategies - the controls will be placed there. So the "Chart shift" option must be enabled when creating the template:

Now we can go to the EA's setting as such.

Setting of the Expert Advisor

Every trader has his or her own trading habits. To make the use of Manual Strategy Tester most comfortable for yourself,
spend about five minutes on adjusting the Expert Advisor to your preferences.

In your trading, you will open and close positions, place pending orders, move Stop Loss and Take Profit levels of positions.
You will be able to choose the lot size for positions to be opened, expiration time and date for pending orders and so on.
Each of adjustable characteristics corresponds with a line on the control panel:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 3 of 12

and two lines in the Expert Advisor's code:

Their function is intuitive:


- RISK (Risk) - % of the deposit to be used for opening a position;
- LOT (Lot) - lot size to be used for opening a position if RISK = 0;
- STOPLOSS (SL) - StopLoss value for positions to be opened, if the StopLoss line does not move when opening;
- TAKEPROFIT (TP) - TakeProfit value for positions to be opened, if the TakeProfit line does not move when opening;
- TRAILINGSTOP (TS) - size of the TrailingStop that will follow all the positions;
- EXPIRATION (Exp) - pending order expiration time in hours.

You can change values of any predefined characteristic directly in the code. For example, if you usually open positions with
volumes of 1.0, 2.0, 5.0, 10.0 or 50.0 lots, replace the line indicating lot size for such a line:

double LOT[] = { 1.0, 2.0, 5.0, 10.0, 50.0 };

After you have compiled and restarted it, you will see the following:

If you want 5.0 lots to be selected by default at startup, replace "int SELECTED_LOT = 1;" with:

int SELECTED_LOT = 3;

Now, the 3rd äù å will be selected by default:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 4 of 12

Values of any other characteristics can be changed in the same way. The rule is common: in the array, in braces, there
must be 5 numbers separated by commas, value of variables SELECTED_*** must range from 1 to 5.

External Variables and Starting

Now we can start our Manual Strategy Tester. Let us open the Tester window, select the vHandsTrade in the Expert
Advisors list, select a currency pair and a timeframe, and enable modelling on "Every tick" for testing to be as real as
possible:

Before pressing the "Start" button, let us look at the Expert Advisor's properties window. In this way, we will complete
adjusting the Expert using external variables:

Actually, the Expert has only four external variables, it inherited other ones from the included file VisualTestingTools.mq4.
All variables must be set up for normal and convenient working:
- CommentsCount - maximal amount of messages to be displayed by the Expert;
- SelectedColor - color of the selected value of Risk, Lot, SL, TP, etc.;
- ModifyColor - color of the order modification icon to be used for manual modification;
- TrailingColor - color of the order modification icon to be used for TrailingStop;
- TerminalRows - maximal amount of the 'Terminal' tab lines to be displayed. If you set TerminalRows = 0, the terminal
will not be updated;
- HistoryRows - maximal amount of the 'Account History' tab lines to be displayed. If you set HistoryRows = 0, the
account history will not be updated;
- BigText - set true if you want to enlarge the font size;
- SignalPoints - the distance in points, starting from which the Stop Loss, Take Profit and Open Price fields for pending
orders will be highlighted. For example, for SignalPoints = 10, the Stop Loss field will change its color when the price is at
the 10-point distance from the Stop Loss of the position;
- ShowCancelled - set true if you want to see cancelled orders in the trade history;
- ShowExpired - set true if you want to see expired pending orders in the trade history;
- MainColor - color of headlines of "Terminal" and "Account History" and of the Terminal account information line
(Balance, Equity, ...).
- BuyColor - color of information about Buy positions;
- BuyOPColor - color of the Open Price field in the Terminal tab; this color will replace the main color when the current
price approaches to the open level of Buy Stop and Buy Limit;
- BuySLColor - in the "Terminal" tab: color, which will replace the main color when the price approaches to the Stop Loss
of Buy positions; for the "Account History" tab: color, which will replace the main color if the Buy position has been closed
by Stop Loss;
- BuyTPColor - the same as for BuySLColor, but applied to the Take Profit of positions;
- SellOPColor, SellSLColor è SellTPColor - the same for Sell positions.

It must be noted that the Expert Advisor was created to be used on a chart with black background, this is why many

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 5 of 12

default colors are light. If you use white background, set dark colors. This is what I have done when testing the Expert for
this article.

Starting

Well, finally, we press the Start button. The first thing we see in the chart is the Toolbox mentioned before:

It helps to open positions, place pending orders and choose values of predefined characteristics. We will study each of the
actions listed before in the corresponding section. Now, I would only remark that all operations with the Toolbox are safer
to be performed in the pause mode. Any action will be understood by the Expert as a command and cannot be cancelled.
Since the Expert is intended for testing only, inaccuracy will not cause material losses for you, but you can ruin in this way
the results obtained in your long-term and diligent testing.

The "Terminal" anf "Account History" windows are below in the chart. they remain empty until we start trading:

We can close and modify positions using the "Terminal" window, while the "Account History" window brings us information.

Position Opening
Let us try to open a position. First of all, it is necessary to define the lot size and the distances to StopLoss and to
TakeProfit since we don't want to waste our time on modifications later.

As it was said before, the values are set using the toolbox: We must select the object containing the desired value and
move it to any point in the screen. Any amounts og objects can be moved simultaneously, i.e., if we want to set lot size for
1 and TakeProfit for 100, we have to drag the corresponding values to a random point:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 6 of 12

Now press F12 - the next tick incomes, and the Expert Advisor checks the selected values:

When opening a position, the Expert will use the selected value of the characteristic:
- the lot size is calculated according to the following formula: Free Margin * Risk * 0.01 * Leverage / Contract Size. If
Risk=0, the selected Lot value is used;
- distance to the Stop Loss is defined by the corresponding line (to be described below). If the StopLoss line has not
moved, the selected value of SL will be used;
- distance to the Take Profit is defined by the corresponding line. If the TakeProfit line has not moved, the selected value of
TP will be used;
- expiration time (for pending orders only) - the selected value of Exp will be used.

Positions are opened in a very simple way - it is sufficient just to drag the corresponding line to the chart. there are 3 lines
for each order type:
- Open Price line (solid for positions Buy and Sell, dashed for pending orders) is in the center, between Stop Loss and
Take Profit lines;
- Stop Loss line (dash-and dot) is located below the OpenPrice line for Buy positions and above it for Sell positions;
- Take Profit line (dashed) - above for Buy positions, below for Sell positions.

Pending orders placed above the current price (Buy Stop and Sell Limit) are in the upper row. Those to be placed below the
price (Buy Limit and Sell Stop) - in the lower row.

So if you want to open a Buy position with the selected values of Stop Loss and Take Profit (as for now, 50 and 100,
respectively), just drag the Buy open line of the position to the chart:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 7 of 12

Then press F12 and admire the results:

Since positions Buy and Sell are opened solely at current prices, there is no need to place the line exactly onto the price:
the Expert will substitute proper values by itself. But it is very important to specify correct prices for pending orders,
otherwise the order will not be placed.

Let us now set the Sell Stop order:


- lot size - 10% of the deposit;
- Open Price and Stop Loss to be set manually;
- Take Profit disabled;
- expiry time 30 minutes (0.5 hour).

Let's take all necessary objects and place them in the chart:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 8 of 12

Press F12 and see:

Everything seems to be ok.

Order Closing

Closing of positions and deletion of pending orders are much simpler tasks. All what we have to do is just to select the
ticket of the order to be closed and move it:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 9 of 12

The result will not keep us waiting: the Expert will have already closed the position by the next tick:

Pending orders will be deleted in the same way.

Position Modification

Copntrolling order modification combines position closing and opening elements: To select a characteristic to be changed
(Open Price, Stop Loss or Take Profit), it is necessary to move the corresponding field.

After the next tick has income, the Expert Advisor will create the Modifying Line that will help in changing the value of the
corresponding characteristic:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 10 of 12

After we have moved the line to its new position, we press F12 and see the result:

If you want to absolutely delete Stop Loss or Take Profit, just delete the corresponding field:

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 11 of 12

After deletion of the Open Price field, one can close the position (delete the order) - some traders may consider this
method to be more convenient.

There are no limitations on the amount of parameters to be modified simultaneously - you can even modify all open
positions within one tick.

Conclusion
After having read the article, you will see that it is not necessary to be a programmer in order to test your strategy on
historical data. Using the manual testing mode, you can trade on historical data manually.

The Expert Advisor, library and indicators given in the article allow simulation of the real trading terminal.

At the end of my article, I would like to remind you that the Expert Advisor is not intended for real trading. Do not
trust you money to a test program.

To simplify controlling of orders in the real-time mode, the online complex AutoGraf was created. It is this complex that
produced some ideas and code parts for this present article (by courtesy of the creator). Many thanks to the creator for
this!

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007
Testing Visualization: Manual Trading Page 12 of 12

Translated from Russian by MetaQuotes Software Corp.


Original article: http://articles.mql4.com/ru/195
Created: 2007.01.18 Author: Andrey Khatimlianskyi
Warning: All rights on these materials are reserved by MetaQuotes Software Corp. Copying or reprinting of these materials in whole or in part is prohibited.

PDF Creator: PDF4U Pro DEMO Version. If you want to remove this line, please purchase the full version
http://articles.mql4.com/301 11/5/2007

You might also like