| / | Articles |
Articles
Tester
Testing Visualization: Account State Charts
To post a new article, please log in or register
|
Testing Visualization: Account State Charts [ ru ]IntroductionI think, it is not only my wish to view the information about the account state
during testing in the visualization mode in a more informative form. Some of these questions were discussed in the articles Testing Visualization: Functionality Enhancement and Testing Visualization: Trade History. But they do not contain any tool for quick and easy viewing the information on
the account. In this article we will discuss programs for drawing charts of the
account state during testing in the visualization mode. As an example we will examine
Balance and Equity charts. The article also contains instructions on building charts
of other account attributes. Is it Easy?One would think, what can be easier than writing an indicator, displaying Balance?
The only buffer is fulfilled by the last known Balance value upon the receipt of
bars. This is the algorithm.
For passing the relevant data we will use Global variables of the terminal, and for their visualization - standard functions of custom indicators. It is easy!We need to add into the Expert Advisor, which will be tested, a code of saving the
Balance into the Global variable. All we need is add one line in the beginning
of the function start(): int start() { // saving the last value of the balance into the global variable GlobalVariableSet( "vGrafBalance", AccountBalance() ); // Expert Advisor code return(0); } The indicator code is not much more difficult: #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Blue double balance[]; int init() { IndicatorShortName( "vGrafBalance" ); IndicatorDigits( 2 ); SetIndexStyle( 0, DRAW_LINE ); SetIndexBuffer( 0, balance ); SetIndexLabel( 0, "Balance" ); } int start() { balance[0] = GlobalVariableGet( "vGrafBalance" ); return(0); } That is all! Now we can compile the indicator, the new version of the Expert Advisor and start testing! After clicking the Start button and attaching an indicator to the chart, we will
see something like this: ![]() You see, the balance curve reflects real changes - at the closing of each trade its value changes. What else can be done?All other graphs are built the same way:
Note, that the variable name for each characteristic must be unique, i.e. it must
not be identical with the names of other variables. The second example shows how to add the Equity chart to the Balance chart. int start() { // saving the last value of the balance into the global variable GlobalVariableSet( "vGrafBalance", AccountBalance() ); // saving the last value of the equity into the global variable GlobalVariableSet( "vGrafEquity", AccountEquity() ); // Expert Advisor code return(0); } The indicator code: #property indicator_separate_window #property indicator_buffers 1 #property indicator_color1 Red double equity[]; int init() { IndicatorShortName( "vGrafEquity" ); IndicatorDigits( 2 ); SetIndexStyle( 0, DRAW_LINE ); SetIndexBuffer( 0, equity ); SetIndexLabel( 0, "Equity" ); } int start() { equity[0] = GlobalVariableGet( "vGrafEquity" ); return(0); } Example of use: ![]() We may attach one indicator to the another one to view the correlation of two characteristics: ![]() ConclusionThe article describes the process of creating indicators, visualizing the account
state. We have analysed the simplest indicators - Balance and Equity indicators.
The information can be beautifully presented! Translated from Russian by MetaQuotes Software Corp.
Warning:
All rights to these materials are reserved by MetaQuotes Software Corp.
Copying or reprinting of these materials in whole or in part is prohibited.
paszo wrote: Use this code:One is I cannot write the indicator with both lines in one window (as you presented at the ned of your article). Could you paste the code of the indicator of both balance and equity in one window? #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red double balance[], equity[]; int init() { IndicatorShortName( "vGrafBalance&Equity" ); IndicatorDigits( 2 ); SetIndexStyle( 0, DRAW_LINE ); SetIndexBuffer( 0, balance ); SetIndexLabel( 0, "Balance" ); SetIndexStyle( 1, DRAW_LINE ); SetIndexBuffer( 1, equity ); SetIndexLabel( 1, "Equity" ); } int start() { balance[0] = GlobalVariableGet( "vGrafBalance" ); equity [0] = GlobalVariableGet( "vGrafEquity" ); return(0); } paszo wrote: Unfortunately, it is impossible to solve this problem.The second problem is that the indicators work only when the testing is run in normal mode. When Itry to run the indicator in the fast mode (using "skip to" function) the indicators are not drawn. I guess it is possible to solve this problem by implementing the indicator into the expert advisor body. But I have no idea how to do it. Maybe you have any idea?
2007.09.17 01:04 komposter
I think your idea of indicator of equity and balance is very usefull.
But I have 2 problems. One is I cannot write the indicator with both lines in one window (as you presented at the ned of your article). Could you paste the code of the indicator of both balance and equity in one window? The second problem is that the indicators work only when the testing is run in normal mode. When Itry to run the indicator in the fast mode (using "skip to" function) the indicators are not drawn. I guess it is possible to solve this problem by implementing the indicator into the expert advisor body. But I have no idea how to do it. Maybe you have any idea? Thank you in advance for your help.
2007.09.15 18:51 paszo
2 comments
|