Monday, March 2, 2009

History of the Russian currency market


... On behalf of direct participants of the events

Igor G. Doronin. He graduated from the Monetary MGIMO office in 1965, worked at the Market Institute of the Ministry of Foreign Trade. He was engaged in monetary and financial problems of foreign countries and the USSR. Since 1984 he has worked in IMEMO, participated in the formulation of monetary management mechanism foreign economic relations. From 1993 to 2002 he worked at MICEX as an adviser. From 2002 to present Senior researcher IMEMO RAS.

What began with the currency market in Russia?

The beginning of change in the management of monetary and financial relations goes back to the beginning of the process of restructuring in the mid 80-ies. Then talk about the market was not. The challenge was to improve the calculations of foreign trade, enterprises interested in exporting their products to combat the "scourge of the import, move away from commodity-oriented export. And the improvement to be implemented within the planned operating system and command control systems.

The situation in foreign trade at the time it became alarmingly disturbing. Imports grew rapidly themes outpacing exports. Shops are increasingly purchased on credit. Growing public debt. Western firms have become the cup to deny credit. There was a feeling that the country is close to financial bankruptcy. You had to do something.

Initially, to encourage exports and curb imports of foreign exchange rates have been coined. Then currency allocations. But all these changes have not infringed on the principle of targets in foreign trade, which was the main factor in the imbalance in trade. They spoke only 5 - 10% of the foreign trade turnover of the USSR.

The prototype for the future of the foreign exchange market became Vneshekonom bank auctions the USSR, and the subject of trade were the relatively paltry sum of foreign currency payments, which companies can keep in their possession. This trade did not do the weather. Lion's portion of the currency has continued to transfer the state under the plan.

Is it not clear then, that for the foreign exchange market should have been to allow businesses to sell foreign exchange earnings in the market, as importers buy it on the course, which emerge on the market?

Of course, it is clear. Moreover, already in 1990 the idea of monetary exchange. But by then the moment was lost. Almost all currency received from exports was to pay off the debt the state. Trading was nothing.

And, as was found out of the situation?

In December 1991 the USSR ceased to exist. At the same time, it meant bankruptcy and its external obligations. Russia, as is known, became the legal successor of the external debt of the USSR. Under the obligation to repay the debts of the Soviet Union Russia and the West agreed to the foreign exchange market to delay repayment of external obligations of Russia. So the opportunity to trade currency.

Start of work on the formation of the Russian currency market put the Decree of the President of November 15, 1991 on the liberalization of foreign trade activities in the territory of the RSFSR. " It contains revolutionary for its time position. In particular, banks authorized to conduct foreign exchange transactions, were allowed to open foreign currency accounts to all legal and natural persons. Exchange rate to foreign currencies to emerge on the basis of supply and demand at auctions, exchanges, the interbank market, with buying and selling of currency by commercial banks and other legal entities and citizens. With this decree the Russian ruble began to possess qualities of internal convertibility, which was a prerequisite for the emergence of the domestic currency market.

Why the emergence of the foreign exchange market in Russia is linked with the Moscow Interbank Currency Exchange?

At first, the element of the foreign exchange market was a major threat. Then a lot of brokerage companies operating in various commodity exchanges are ready to serve foreign exchange operations of enterprises and organizations. If you recall, almost every shop and stall currency bought and sold, along with soda water.

The overriding need of the time was to streamline and organize the trade exchange. The creation of the Moscow Interbank Currency Exchange in January 1992 and has been organizing such a beginning. Market from the very beginning acted as an organizer of trade exchange between banks.

As a result of stock trades to determine a single official exchange rate of ruble to the dollar, on which banks are calculated in business and on which the fixed exchange rates. Clear rules for bidding on the stock exchange to ensure the transparency of the process of forming the ruble, which was needed as the Central Bank of Russia, and the banks who participated in the auction.

At that time, stock trading, without exaggeration, was a symbol of the transition to a market economy. They go ... Yes, yes, as in the theater! Tenders must be clearly be carried out not only technologically, but also a true movement of hands, brace up the phrase into the microphone, prompt a smile. It was art, which at that time owned the exchange broker Alexei Mamontov, now president of the Moscow Interbank Currency Association.

Press and television require accreditation to bid. It was in that look and what to write. All compared with western counterparts. We pride ourselves on: now we are. Traders - representatives of commercial banks were going to trade hall. In the MICEX trading system prior to bidding "upload" currency for the sale and purchase of currency for rubles. So by the beginning of the trading was well known, as proposed currency for sale and how much currency you want to buy. Typically, the demand always exceeds supply. Bring into balance the demand and supply could be due to the strengthening of the dollar. With the gradual growth of dollar traders, in consultation with the leadership of the bank (kept us on the phone) to add a currency for sale, and bids and shot. Once achieved equilibrium exchange broker said - "fixing, gentlemen." Exchange equilibrium becomes official dollar before the next auction. How significant was the difference between supply and demand, the higher the dollar rose, the longest lasted for bidding, the more arts and skills required of course a broker.

Introduced the principle of mandatory sales of export currency earnings of at Interbank Currency Exchange allowed the Central Bank of Russia to control the sale of currency by banks and ensure liquidity in the foreign exchange market.

Participation of the Central Bank in the Interbank market as a buyer and a seller allowed to smooth fluctuations in currency exchange rate to foreign currencies.

What do you think the changes have occurred in the exchange currency market since its inception?

The current market is not similar to that which existed in the early years of its establishment. First, a market characterized by high volatility. Course rublyastremitelno decline. The main reason was persistent fiscal deficits, which require significant emissions. As a result, demand for the currency is constantly exceeding supply. The Central Bank due to extremely low levels of foreign reserves had not been able to have an appreciable effect on the dynamics of the course. Memorable event in the exchange currency market have become so-called "black Tuesday" in October 1994 and August 1998, accompanied by a significant fall of the ruble to the dollar.

The situation in the market opposite to that which existed at the time - offer the currency in the market exceeds demand. Reduce inflation. Confidence in the ruble grew. New tools for embedding free ruble funds. Became more profitable to invest ruble funds in shares and bonds of companies, to keep funds in rubles in bank deposits. Increase confidence in banks.

Secondly, the current foreign exchange market more liberal. The requirement established by the compulsory sale of export proceeds in foreign currency exchange. Now it can be sold in the interbank market. Moreover, the lowered standard of compulsory sale. If earlier it was 50%, now - 30%, and in the future are invited to abandon the compulsory sale.

The third change is exchange. In fact the modern market - a powerful server, software, communication links that connect remote locations to the trading server and the people who serve this technical complex. Passed away last bazaar, where traders are banks. It replaced the server, and traders - remote workstations located in the offices of the banks-participants of the foreign exchange market. Technology has changed auctions. Instead of fixing bid being in the double auction. Exhibited cross-application for the purchase and sale and in the case of convergence rates and volumes on the purchase and sale, the transaction is automatically. Based on the weighted average rate chopping-up of transactions was determined by the official rate.

Changes in the market place not by themselves. They are the result of policy formulation in which the active participation of the former General Director of MICEX AV Zakharov and Exchange Board Chairman A. Potemkin.

How important the role of stock exchange market at the present time?

I think the stock exchange trading will retain its value for a long time. They will remain an important, unique feature of the Russian currency market. With the latest technologies we have a national stock exchange market. The MICEX trading system combines regional currency exchanges in St. Petersburg, Novosibirsk, Rostov-on-Don, Vladivostok, Ekaterinburg, Nizhny Novgorod, Samara in a single trading system. Stock trades are carried out simultaneously, in real time in all markets simultaneously. This is something that is not available to any Russian commercial banks. Applying the latest technology has enabled a significant speed up the calculations, minimize risk and reduce fees for ongoing operations, which expand the bidders.

Finally, the Russian interbank market perform not only trade currency, and trading floors have become universal. They are traded government securities, equities and corporate bonds. This trade is conducted simultaneously in all exchanges within a single trading session.

What are the prospects for the Russian currency market?

The market involves competition. On the currency market, competing currencies, financial institutions, trade and payment systems. Liberalization and technological progress will exacerbate competition.

However, the position of any currency in the market are determined by monetary authorities pursued fiscal and monetary policies. From it depended the credibility of the stability of the currency and its rate relative to other currencies. Competition leads to weaker currencies in the market pushed more powerful not only in international payments, but also nationally. Accordingly, changing the structure of foreign exchange turnover in the market, changing the ratio of rates quoted currencies.

Another factor in the development of the foreign exchange market is the integration of various segments of financial markets. Operations of currency exchange market is increasingly linked to the overflows of capital between countries, investments in various financial instruments. Investment companies, pension funds, insurance companies form a diversified portfolio of securities, change their structure depending on the risk, profitability, prospects for the movement of currencies, which are expressed in these instruments. The attractiveness of investment in financial instruments depends on the level of development of the domestic financial market, the quality of the market, the protection of investors' rights, as well as the stability of the currency.

Given the prevailing global trends we can say that the future of Russian foreign exchange market will depend on how reasonable and balanced would be fiscal and monetary policy of the Russian authorities how it will ensure the credibility of the Russian ruble, both domestically and abroad. Finally, it is important to the position of the ruble to the dynamics of the Russian financial market, the growth of confidence in financial institutions market, broadening the range of traded financial instruments protecting the rights of investors in the financial market.



Alien Money

John M. Berry, "Greenspan leaves no doubt about the increase in rates"


John M. Berry - Analyst information agency "Bloomberg News"

Chairman of U.S. Federal Reserve Alan Greenspan removed any ambiguity about how the Central Bank intends to move in the matter lifting interest rates to remove some of the incentives of monetary policy that will strengthen American economic growth.

June 15, in his speech related to his claim for the fifth four-year term as chairman, Greenspan told the U.S. Senate Banking Committee that "inflationary pressures are unlikely to cause serious concern in the coming period of time."

This observation definitively clarified if it was not already clear before, that the Fed will raise its key interest rate by 25 basis points at the meeting of 29-30 June, and that Greenspan is currently intends to continue to move in the "moderate" pace in the matter increases in interest rates.

Last week the other comments the Head of the Federal Reserve and many other high-ranking officials of the Central Bank is widely interpreted by some analysts as an indication of "policy-meykerov" that they were sufficiently concerned about inflation and that "moderate" policy may have to give way to the "aggressive" in the increase of rates.

Sending a signal
Once the markets have received this message on 15 June, yield on all Treasury coupon securities fell almost 18 basis points, reducing the increase that occurred during the previous week.

Part of the fall of profitability, of course, also occurred because of the relatively soft report on consumer prices for May. The report came out, largely in line with expectations, although after a few more concerns increases the consumer price index, was the feeling of relief that all the same data are consistent with expectations.

There are so many high-ranking officials of the Federal Reserve estimated the need to lift interest rates, as no other initial increase in interest rates, the Central Bank was not so well marked. Some officials even praised the market for the correct perception of the signal, which was sent to officials.

Market reaction was interesting because Greenspan actually gave a kind of warning, which caused distress to investors last week: "If our assumption about how the economy is going to evolve, and how inflation will prove wrong, then we will change its policy, he said.

Greenspan wants to move slowly
In other words, solutions that are members of the Federal Open Market Committee (FOMC) will be at the meeting in August, September, November and December will depend on economic data. It would be preferable, according to the Head of the Central Bank, to move relatively slowly, perhaps with subsequent increase of 25 basis points in two or three of these meetings.

Some of the other FOMC members may well want to see the increase at each meeting. But this seems unlikely, especially if the economy and inflation will follow the rate expected by Alan Greenspan.
Fed officials, including the chairman, was surprised by how quickly the inflation picture has changed this year. A key question is - will be a weakening labor market and productivity to limit the recent rise in the prices of some goods and services.

Not all FOMC members shared this interpretation of the inflationary process in the U.S., although some of the few in the same puzzled actual behavior of inflation this year.

Payments to employees
One important question - whether the increase in payments to workers in the first quarter of this year, a harbinger of that situation should change for the better. Greenspan himself said that he expects the payments will increase, especially given the fact that the strong growth of productivity has an unusually high returns.

Maybe that part of the increase in payments in the first quarter were not a result of the fact that employers had to pay more to hire workers that they need, or to retain those already working. Most of the higher payments occur in the form of increased compensation costs, including some very high bonuses to certain major corporate pension plans.

If so, there may be less meaningful progress with respect to unit labor cost than the first quarter figures.

The model of price increases
Version Greenspan on the process of inflation can be described as "a model of price increases." This means that companies set prices, in fact, going on the road to higher prices, in proportion to their costs, including labor costs. If productivity growth to compensate for higher wages and costs, there is no pressure to raise prices.

In his speech, June 15, Greenspan said, "a problem that will concern us most - that the slowdown in the extraordinary pace of productivity, because the average hourly wage has increased."

Regarding this point, the core of the consumer price index rose by 1.7% over the past 12 months - an increase which is almost all, if not absolutely all, FOMC members very satisfied. This includes even such as the president of the Federal Reserve Bank of Kansas City, Thomas M. Hoeniga, who has a reputation as man with a rather "yastrebinoe 'attitude towards inflation.

Last week at the roundtable in Denver, Hoenig said the press clearly, "I'm not concerned about inflation around 1.8%. It was a 12-month change in core consumer price index for April.

Now everyone, including policy-meykerov, will wait to see how events develop.




bloomberg.com

Terms of trade for the price models


Surprisingly, many traders do not even imagine how to work a good trade. They instead go after the market, hoping to earn on the latest news or views of various analysts. This approach may work for short periods of time, but will, ultimately, lead to very large losses.
Image pricing models are the mechanical language of market forecasting. Take the time to explore their inner work, because they show the nature of opportunity. In other words, they tell us when to sell, how to trade and why trade should operate.
Here are 15 ways to manage opportunities through price graphic models:
1. First of all, learn the classical models to recognize them immediately, at any price schedule. These models describe the broad, predictable forces that affect all time formats and offer a good deal. Then move on to more original and complex models.
2. Traded on models that correspond to the current market phase and reduces the size of the positions where the forces are in conflict. For example, most models fail to be a breakthrough in the weak market, regardless of how nice they look at the price chart.
3. Models predict the subsequent motion, since they show the desire to crowd. They point to the time and direction, because the behavior of the market crowd is generally a desire to market to key intersections. Models lose their effectiveness when the market crowd, finally, to understand the prevailing mood of the market.
4. Opportunity may be multifaceted. Popular models, such as head-shoulders at the top, capturing the attention of traders, but the graphs show the many lesser-known predictable formations. Since these models did not raise the interest of market crowds, they are reliable for a longer period of time and less susceptible to rapid spread.
5. Ideal model is rarely appear in the current market environment. Learn to effectively operate in a "cross". Conversely, no gonites for each intersection of the rolling average for both the main signal and distinguish the wanton umeyte candle combination, as set out in textbooks of really applicable in practice.
6. Recognition of graphical models does not work for everyone. Some people learn much more benefit, building a trading system or carefully analyzing your balance. Avoid mixing systems and the uncontrolled trade in a strategy, because they are not very well combined.
7. A good trading model does not gives any signal as to when to sell or when to stand aside. She points to the coincidence of time and direction, which should lead to predictable movements in appropriate circumstances. This is a task for the trader - use the right tactics, which brings a good profit, if the model works, and protect the balance of trade from large losses if the model fails.
8. There is no single unequivocal method of trading for any model, and no market situation will not pass on the same path twice. The chosen strategy of trade should be expected to use the opportunity in the management of unexpected risks.
9. Spread each model in the category as the original or classical. It predicts the level of involvement of the public and the potential for rapid spread. Dismiss the strategy to a more defensive situation, where a large crowd at a popular selling model. Consider the possibility of movement in the other hand, if the model fails, or stand aside and let other traders initially risking their capital.
10. Log in to the model before it will develop, where possible. The risk remains low until the price has not been raised or not spread, providing signals for all other players. Early entry allows traders to open positions with low risk while waiting for more movement when the model becomes apparent.
11. Always know the time. Time eventually turned against the model, if the price of just sits there. Technical indicators are beginning to turn, and the model could have degenerated into a lot of unpredictable price bars. Wisely choose the levels of entry and exit immediately if the model deteriorates.
12. Be patient, after the model launched without you. Focus attention on a possible entrance in the back and be prepared to stand aside if the market starts to run. Trading on the back must be seen, based on its own merits after the breakthrough model. Keep in mind that many models predict only one price fluctuations, and the potential gains to evaporate after the first movement.
13. Make sure your installation at the entrance to the market consistent with the natural tendencies of time. Do not miss significant periods of movements caused by fundamental news, and other objective factors, consider the natural periods of greatest activity and low, the output in different markets, seasonal periods of recession. And do not get to conduct a market azhiotazhnoe crowd after weekends and holidays.
14. Models should be consistent with the distinct levels of support or resistance. Use multiple formats temporary, to confirm that a large picture of the market does not contradict this possibility. Check the basic Moving averages and technical indicators to identify the divergence that may damage the trade.
15. Determine the level of the entrance to the market with low-risk targets for profit and stop-order for each model. Consider the impact of the failure model for each new installation of the entrance to the rynok.Kogda price goes in the wrong direction, it can yield a greater profit than if the expected result.




www.hardrightedge.com

Programming in MQL 4: Options

Article about programming in MQL 4 in the previous issue of the journal Forex Magazine ended promise to consider the options - new language MQL 4 missing in MQL II. In fact, the language MQL II allows to write custom functions that are compiled by individual modules, but work with them have some restrictions that prevented the full benefit of this achievement, structured programming.

In this article we will try to explain that such a function in MQL 4, for which they want as their right to declare and use.

As noted in the previous article, the functions - it is one of the "bricks" for constructing programs. This concerns not only the language MQL 4, it refers to almost all programming languages. Programmers of all stripes use a function to create a more intuitive programming and more effective programming. If it were not for the functions (as in MQL II), often to several times during the same program to copy the code that performs the same action. Such duplication of code not only increases the labor of writing and debugging programs, it also impairs its readability. Features a large help to solve this problem.

Options can be viewed as named blocks programs that hide themselves in the details of an algorithm. Once written and debugged the function can be used in several places in the program (or even in several different programs) without much effort. They usually have a descriptive name that facilitates the understanding of its purpose. Well written and documented using the function does not require understanding of the algorithm of its work. It is as if a black box, which at the entrance to take any parameters, and on completion of their work gives no result.

Options MQL 4 can be made in two ways. First - this is the successor of custom functions, the language MQL II, is executed as a separate module. In the new version they are called "script". Second - it is writing functions in the same module as the main program for local use.

To create Script'a enough to run the wizard to create a program in the editor 4 Meta Editor and select "Script program". The wizard will guide you through the entire process of creating a custom function, after which you will be open skeleton code script'a.

To create a second type of functions is simply to describe it in the same file, where it will be used.

Language MQL 4 has three predefined function names which should not be used as the names of their own functions, it is init, deinit and start. Also, function names should not begin with numbers. Otherwise, by choosing a function name, the programmer has complete freedom.

The function can have input parameters. To specify the parameters of the function should list their names and types separated by commas in the line of ads function.

double SomeFunction (color LineColor, string LineName, int Range)

In the above example shows the definition of the function SomeFunction with three parameters: the parameter is of type LineColor color, setting LineName - type string and the parameter Range - type int.

You probably have already noticed that the front of the type of function, too. The point is that functions can not only take some parameters as input parameters, they can return values. These values can be used in different ways.

In the case where the result of the work function should be a single value, you can do so, that function will be to recover it. Suppose that our function SomeFunction must display some sort of line, and as a return value of the maximum closing price over the last few bars. Since we are talking about the functions of some of the "black box", then let's not think about the implementation of the functions just assume that it has already been written by someone, but we only known about it that:

1. The first parameter specifies the color that you need to put a line on schedule;
2. The second parameter specifies the signature to be affixed on the schedule next to the line;
3. The third parameter specifies the number of bars that will be processed by the function for finding the maximum cost-closure;
4. When the function returns a value of type double, which is equal to the maximum cost of closure on the period specified in the third parameter.

Use this function in your code will be as follows:

/ / Somewhere in the code declared variable of type double,
/ / Which will hold the greatest value closing double fHighestClose;

/ / Perform some action
...

/ / Then, to execute code "hidden" in the body function
/ / SomeFunction need her to call.
fHighestClose = SomeFunction (Yellow, "Line subscript", 50);

/ / Now the variable contains the result fHighestClose
/ / Function SomeFunction

Also, often a function return value is used to indicate the correctness of the conclusion of "hidden" in its algorithm, or occurred during the execution error. How to use it, shows a little lower.

But it is not always necessary that the function returns a result. To describe such a role exists type void. For example, the following ad features suggests that the function OtherFunction nothing to return:

void OtherFunction (int Param1)

Options can take a variety of options, and usually only part of them should be unique to address the functions of the program, as ostavshayasyachast repeated calls to the call from. For ease of use features, the opportunity to ask MQL4 built default values for parameters of functions. This means that using the function, the parameters of which already have some predefined value, we can either use them or specify your own. For ads such parameters should function immediately after him, through a sign ravno specified by the default. One important note - if you specify a default value for one of the parameters of the function, then all options facing him right in the ad must also have default values. Parameters with no default values, called "required parameters". Consider this example:

/ / This is the correct ad - all options
/ / Param2 has the right to Defaults
int SomeFunction1 (int Param1, int Param2 = 10, int Param3 = 123)
(
/ / Do something
)

/ / This is wrong ads - parameter
/ / Param2 right do not have default values
int SomeFunction2 (int Param1, int Param2 = 10, int Param3)
(
/ / Do something else
)

Accordingly, the call SomeFunction1 could be three options, indicating the importance of only the first mandatory parameter, by specifying the first two parameters, and specifying all three parameters.

/ / Somewhere in the code declared variable of type int,
/ / That will store the value returned by the function
/ / SomeFunction1
int nSomeResult = 0;

/ / Call SomeFunction1 indicating only compulsory
/ / Parameter. Other parameters and Param2 are Param3
/ / Have a value of 10 and 123, respectively
nSomeResult = SomeFunction1 (10);

/ / Call SomeFunction1 indicating the two parameters.
/ / Parameters Param3 will be a factor 123
nSomeResult = SomeFunction1 (10, 20);

/ / Call SomeFunction1 with a clear indication of all three
/ / Parameters
nSomeResult = SomeFunction1 (10, 20, 30);

Now back to the fact that through the return value of functions to communicate the user code, which can be used to determine whether the function completed, or in the process of its implementation has occurred is a mistake.

Below is the circuit function, which returns a value of type int. Condition is that if funktsiyavernula value is nonzero, then it occurred some error. If the function returns zero, then it has successfully completed its programmed algorithm:

int SmartFunction ()
(
bool bReturn = false;
/ / Do something
...
if (bReturn) (
return (1);
)
/ / Do something else
...
if (bReturn) (
return (2);
)
return (0);
)

Due to the fact that the function returns different error codes, we can diagnose the presence of errors and locate the place of its occurrence.

When writing programs are often enough to pay attention to the return code of a function. Well, that, in MQL 4 the opportunity to analyze the return code of the function, but this same procedure, and parse error occurs almost always in one scenario - namely, when an error occurs, it is necessary to inform the user as can be more informative. Why not "turn" into a separate function of the code analyzing the return value of some function?

AnalyzeIt (bool bCondition, string sModuleName, string sDescription = "Something is wrong")
(
if (bCondition) (
Alert ( "WARNING:" + sDescription + "in" + sModuleName);
)
)

In the above example shows a function that analyzes the return value of another function, and in case of error, the user is warned. Next, an example of its use:

AnalyzeIt (SmartFunction (), "MyFileName.mq4");

SmartFunction will return an error code, it is transmitted as the first parameter to the function bCondition AnalyzeIt. In the event that an error code other than zero, the user will see the message "WARNING: Something is wrong in MyFileName.mq4".

In case you need to get more clearly a description of the bug - you can use a third parameter, as is done in the following example:

AnalyzeIt (SmartFunction (), "MyFileName.mq4", "Wrong SmartFunction termination");

Now you will see the message "WARNING: Wrong SmartFunction termination in MyFileName.mq4".

Today all. We hope that this article was able to show which opens the horizons for the introduction of more flexible roles in the language MQL 4. Their skilful use will greatly facilitate the life and work of programmers writing software for the new version of the trading system Meta Trader 4.



Alexander Ivanov

Writing Experts for MetaTrader. Lesson number 20

Hello, dear readers. In the last issue we wrote AMA Kaufman. Thanks to one of the readers of the magazine, under the nick of Simca, in the code indicator errors. So they had an interesting prepositional pattern optimization code. This issue will be an answer to a question from readers of the magazine.

Correction of errors and optimization

The fundamental problem is the computation of the variable signal.
In the past, the code variable is as follows:
signal = abs (c [shift]-c [shift + n-1]);

Revised looks like this:
signal = abs (c [shift]-c [shift + n]);

Variable signal was considered to be at 1 bar less regulation.

Some readers may say that the optimization of a small code does not make sense, especially if the computer several GHz processor and RAM, a few hundred MB. In fact, it is not, load the MT that it would not display a custom indicator for all history, it is not difficult. Especially when the code is not optimized.

Rather than a beautiful time of the last Law is that the past value of the indicator we read directly from the array of indicators. This can be easily avoided. We know that when you restart indicator (expert), the old values are saved. It is therefore easier to use the structure of this type.

AMA (new) = AMA (old) + ....

Give part of a letter which I wrote Dear Simca.

<... Your piece looks like this:

AMA1 = c [Nbars];
For shift = Nbars Downto 0 Begin
...
AMA = (c [shift] * ssc * ssc) + GetIndexValue (shift +1) * (1-ssc * ssc);
if shift = Nbars then AMA = (c [shift] * ssc * ssc) + AMA1 * (1-ssc * ssc);
SetIndexValue (shift, AMA);
End;

I would have written the same thing like this:

AMA = c [Nbars];
For shift = Nbars Downto 0 Begin
...
AMA = (c [shift] * ssc * ssc) + AMA * (1-ssc * ssc);
SetIndexValue (shift, AMA);
End;

I so easily. :) There is no point in taking the previous value of AMA array, and so it will continue from the previous cycle. A primary value that you set through an AMA1 and checks at each iteration, it is possible to simply assign the first cycle of the variable AMA. The essence remains unchanged, but the algorithm much easier. Chance of AMA1 in this case did not need. :) ....>

But that did not stop Dear Simca, quote the following letter.

<... In general, my algorithm is an indicator of changes made after as follows:

---
Inputs: Range (10), FastMA (2), SlowMA (30);
Variables: cb (0), i (0), Noise (0), ER (0), SSC (0), AMA (0);
SetLoopCount (0);
AMA = Close [Bars-Range];
for cb = Bars-Range-1 downto 0 begin
Noise = 0;
for i = cb to cb + Range-1 begin
Noise = Noise + Abs (Close [i]-Close [i +1]);
end;
ER = Abs (Close [cb]-Close [cb + Range]) / Noise;
SSC = ER * (2 / (FastMA +1) -2 / (SlowMA +1)) +2 / (SlowMA +1);
AMA = Close [cb] * SSC * SSC + AMA * (1-SSC * SSC);
SetIndexValue (cb, AMA);
end;
---

As you can see, I do not use the "number of bars for displaying" (Nbars) and displays it on all the available range of bars. This is certainly not a question of principle, just my comp. perfectly able to calculate the entire range. :)
Instead, I used to shift writing cb (the reduction of CurrentBar). :) I think of Bars (Bars-Range-1) that the inner loop does not jump out of the number of bars. Accordingly, the values for the first AMA has the price bar before the first computed (Bars-Range). Variable signal, I did not describe the individual and moved directly into the calculation of ER because it is still not used anywhere else. Everything else we have already discussed. :) In general there, and so everything is clear and nothing special to describe. :)

Now turn to the actual improvement of what exists. Let's start with the calculation of SSC. Is obvious that in the heap calculated parameters do not depend on variable cycle. Logic would be to calculate them once before the cycle and ready to use within the meaning. I am not inventing anything here, all this was actually in the article.
2 / (SlowMA +1) - is a so-called "SlowSC" (the term of the article).
2 / (FastMA +1) - this "FastSC".
Since inside the loop itself "FastSC" We are not interested, but only important difference FastSC-SlowSC, it will use two pre-(before the main cycle) is calculated coefficient:

k1 = 2 / (SlowMA +1);
k2 = 2 / (FastMA +1)-k1;

After this calculation SSC becomes much shorter (and more importantly fast:), type):

SSC = ER * k2 + k1;

Furthermore. In calculating the AMA in the classic form of using too many multiplications (unjustified luxury). :) Then transform the formula to a more acceptable type (will be faster). Type conversion is in the article, but if it is not obvious, Sign it in more detail:

Price - Price Close [cb].
AMA1 - previous AMA (but we remember it:) that would be simple to use with the AMA last iteration cycle).

AMA = Price * SSC ^ 2 + AMA1 * (1-SSC ^ 2);
cutting brackets
AMA = Price * SSC ^ 2 + AMA1-AMA1 * SSC ^ 2;
rearrange the elements for the convenience
AMA = AMA1 + Price * SSC ^ 2-AMA1 * SSC ^ 2;
well and will make the brackets for the SSC ^ 2
AMA = AMA1 + SSC ^ 2 * (Price-AMA1)

Now the calculation of AMA is of the form:

AMA = AMA + SSC * SSC * (Close [cb]-AMA);

Here is another thing:) just two multiplications and additions are not added. :)
This type of formula too was in the article.

Well like everything that can be soptimizirovali. At least I thought so.
Total received indicator as follows:

---
Inputs: Range (10), FastMA (2), SlowMA (30);
Variables: cb (0), i (0), k1 (0), k2 (0), Noise (0), ER (0), SSC (0), AMA (0);
SetLoopCount (0);
k1 = 2 / (SlowMA +1);
k2 = 2 / (FastMA +1)-k1;
AMA = Close [Bars-Range];
for cb = Bars-Range-1 downto 0 begin
Noise = 0;
for i = cb to cb + Range-1 begin
Noise = Noise + Abs (Close [i]-Close [i +1]);
end;
ER = Abs (Close [cb]-Close [cb + Range]) / Noise;
SSC = ER * k2 + k1;
AMA = AMA + SSC * SSC * (Close [cb]-AMA);
SetIndexValue (cb, AMA);
end;
---

In order to definitively confirm that we are all done correctly (since we only optimize the algorithm without changing its substance) start to schedule both LEDs simultaneously. We see the full hundred percent match curves. So optimization is correct. :) But the second option would be to work faster. ... "

It is exemplary!

I want to reiterate one of the main points of optimization. AMA (new) = AMA (old) + .... It allows you not to read back the value of the indicator array. Since indicators used in its formula the past value itself is not small, all it would be useful to adopt this, simple and comfortable, reception.

The answer to the question

Dear Yuri asked.
<... How can I make that adviser covered position (if any) on the instrument at the close of the bar and entered the market at the time of forming the next new bar. ... "

MT is not that is about to close a bar. But the MT knows the exact time. It will come.

Here is some code that closes the position before closing the bar H1. By analogy to the opening position, I think you can do yourself.

if Minute = 59 then (
if TotalTrades> 0 then
(
for cnt = 1 to TotalTrades
(
if OrderValue (cnt, VAL_TYPE) <= OP_SELL and
OrderValue (cnt, VAL_SYMBOL) = Symbol then
(
If OrderValue (cnt, VAL_TYPE) = OP_BUY then
(
CloseOrder (OrderValue (cnt, VAL_TICKET), OrderValue (cnt, VAL_LOTS), Bid, 3, Violet);
exit;
);
If OrderValue (cnt, VAL_TYPE) = OP_SELL then
(
CloseOrder (OrderValue (cnt, VAL_TICKET), OrderValue (cnt, VAL_LOTS), ask, 3, Violet);
Exit;
);
);
);)
);

Here is the initial value to the expert at D1: if Hour = 23 then (

Conclusion
Once again I want to express my deep gratitude, the reader, under the nick of Simca.
I am confident that all would be interesting to look at other people's work, so as not to stew in its own juice. If any of you wish to share ideas, be sure to write.




Halhalyan Arthur
artur@fxtest.ru

Linear Regression

Linear regression is a statistical tool used to predict future prices based on historical data, and is usually used to determine when prices are overheated. Use the method of least squares to build "the best" straight line through a number of price points. Price points, used as input data can be any of the following values: open, close, maximum, minimum, (maximum + minimum) / 2, (maximum + minimum + close) / 3 (opening + maximum + minimum + closure ) / 4,% change, or (open + close) / 2. These data can be pre arbitrarily narrowed to building the most appropriate line. If smoothing is not desirable, then simply choose the smoothing period equal to 1.

Calculation
To determine the best line, corresponding to a number of price points, using the method of least squares.
The standard deviation is calculated as follows:
- Summed squares of the difference between the price and the line of linear regression.
- Porluchennaya sum is divided by the number of bars in the range of the regression series.
- Calculated the square root of the result, which gives the standard deviation.

To illustrate the above presented daily schedule of Japanese candles "DKWD" (D & K Healthcare Resources). The blue line represents the central line of regression, based on the parameters selected below. The red lines represent the channel, based on standard deviations, set the example below.

The use of graphics programs
. Price - the price set by the value (opening, closing.) That are used as input data for calculating the regression line.
. Type of pre-smoothing. - The type of smoothing (simple, exponential.) Used for pre-smoothing the data before performing the regression.
. Pre-smoothing. - Smoothing period used for the pre-smoothing the data before performing the regression.
. The range of data - this group of plants contains parameters that define the beginning and end of analysis.
. Automatic use of the past X bars - this option provides for automatic movement of the regression line, always using the last X bars.
. From dd / mm / yy hh: mm: ss to dd / mm / yy hh: mm: ss - This option allows the user to define a specific start point and end point of time.
. From dd / mm / yy hh: mm: ss to Present - This option allows you to automatically move the regression line, always starting with a certain fixed start-bar, and always finish at the last bar. The range will be expanded, as is expanding the time period.
. The standard deviation up - the number of standard deviations above the regression line to make a parallel line of the channel (if 0 - line missing). You can specify multiple levels of the channel in this parameter, a comma separating the values (eg, 1, 1.5, 2).
. Standard ot.lonenie down - the number of standard deviations below the regression line to make a parallel line of the channel (if 0 - line has not done). Here you can also specify several levels of the channel, just a comma separating the values (eg, 1, 1.5, 2).
. Channels Raffi - developed by Hilbert Raffo, this method is the maximum distance between any price and the closing line of regression. This distance is then used as the basis for the channels. Channels conducted parallel regression lines, above and below the line at a distance equal to the maximum calculated distance. The upper channel is then used as a resistance, but lower as a support.
. Continue to the right - this option allows you to continue the line of regression (and through the channel, if applicable) to the right of the chart.
. Color regression - sets the color and style of the regression line on the graph.
. Color Channel - sets the color and style of the line feed on the graph.

Description of parameters
There are several options for choosing the price range that will be included in the regression analysis (range data). The first option "Automatically use the last X bars" allows you to automatically move the regression line, always use the most recent X bars. The second option is "from dd / mm / yy hh: mm: ss to dd / mm / yy hh: mm: ss", allows the user to define specific start and end point of your time. The third option is "from dd / mm / yy hh: mm: ss, to date" is the other possibility of automatic displacement of the regression line, always starting in a certain defined start bar, and always ending in the most recent bar. The range of data will grow, since growing period of time.

Some software products allow to build a linear regression by hand, for this set of tools just click the relevant icon (for example), and activates a tool for constructing a linear regression. Then the mouse cursor indicates the point on the graph, which must start a line of regression and a manual line between two points of interest. Along with the regression line can be straight lines strips parallel to the regression line. The stripes are on the user-specified distance above and below the regression line. Distance determined by the number of standard deviations from the regression line. The user is not limited to building only one line of the channel above and below the line of linear regression, because you can define several levels, simply list them separated by commas. For example, you can:

Standard deviation upwards: 1, 1.5, 2
The standard deviation below: 1, 1.5, 2

In this case, will be constructed in three channels at 1, 1.5, and 2 standard deviations from the regression line, respectively. The value of standard deviation is calculated using the same range of data that is used in determining the regression line (range data). The values specified in the parameters are the multiplier of the value of standard deviation used to calculate the distance from the channel of the regression line.

If the option Feeds Raffi will be used a different method to calculate the bands. The resulting Hilbert Raffo, this method is the maximum distance between any price and the closing line of regression. This distance is then used as the basis for the channels. Channels are parallel to the regression line above and below it at a distance equal to the maximum calculated distance. The upper channel is then used as a resistance, while the lower channel is used as support. You can also ask a number of levels, separated by commas. Levels will be used as factors in the standard channel Raffi. To simply hold a standard channel Raffo, define a multiplier of 1 for the upper and the lower channel.

Linear regression can be arbitrarily extended to the right, using the "Extension of the line for the moment." This allows you to design the line to the right edge of the schedule. Start and end points of trend line is clearly visible as a small point on the line. These points can drag to a new position at the price chart. When the transfer occurs, re-compute the regression, and a new regression line with the new range of data. If you are using a range of data with the use of options "from dd / mm / yy hh: mm: ss for the moment, (Present)", then you can transfer only the starting point for a new fixed location. Start point then remain fixed, while the end-point adjust to the most recent bar.

The following approximations offer a few rules for the use of standard deviation units:

. Plus or minus one standard deviation covers 68.3% of the expected results (price movements)
. Plus or minus two standard deviations encompasses 95.4% of the expected results (price movements)
. Plus or minus three standard deviations includes 99.7% of the expected results (price movements)

For example, the movement of prices of more than 2 standard deviations above or below the regression line is quite rare (less than 5% probability). Such movements are usually treated as a state of perekuplennosti or pereprodannosti.

Strategies to use

To better understand the practical application of linear regression, the following are the comments of existing trederov who uses this tool in their daily practice.

Trader John Meyer
As a professional trader, I try to simplify their schedules and to use only those indicators that are simple and make sense. Channels of linear regression is best suited for this. If you are an advanced trader in the options market, you know the standard deviation.

I apply the indicator, based on the "Automatically use the last 100 bars." Graphs with a more prolonged period (more than 65 minutes), I have three channels of regression from a distance of 2, 3 and 4 standard deviations (in a different color). If you have azhiotazhnye buying or panic selling, the price could reach the area by 5 standard deviations, so be careful before you automatically go against the movement of the level of 2 standard deviations. If in doubt, go for a larger temporary format.

In the quiet days when the trade is carried out in a narrow price range, I am doing the installation of 1.2 standard deviations, and traded on a 3-minute charts - it usually gives at least ten transactions per day to obtain at least a small profit on each transaction.

Also, I see the location of the price of a certain distance of the standard deviations in different time formats. This approach gives me the perfect opportunity (for example: when a growing share is at a distance of 3 standard deviations on a weekly schedule - this is a golden opportunity for sale - while the majority of traders are still buying).

Channels linear regression, of course, is not some miraculous display, but with a good understanding of how it works, and its proper use, it can help a trader on the correct side of the market!

Trader Dan Clark
I use the 6 channels of automatic linear regression on their day and intra-day schedules (all time-formats). In fact, this two-line linear regression with a different number of bars and pre-smoothing. The first uses the last 55 bars (pre-smoothing 3), while the second uses the latest 233 bar (pre-smoothing 13). All use the method of least squares from the closing price. Thus, a regression of the 55 bars and one of 233 bars, each of channels 1, 2 and 3 standard deviations (total 6).

Channels linear regression very well serve to identify points perekuplennosti and pereprodannosti and breakthroughs. Pay attention to the behavior of "EMLX" February 14, when it breached its minimum of 1-channel standard deviation. February 15, the maximum of the day he returned and touched the same line of the channel, and then declined. 20 February, the daily minimum is close to 3-th channel, the standard deviation and pushed upwards. Pay attention to the pink line - 200-day EMA, which provides additional support.

Another reason why I prefer the channels of linear regression is that they help me escape from the traditional horizontal and vertical axes, and help me determine the direction of trend. For example, in the case of the "EMLX", although we have the perfect formation "double bottom", I think the breakthrough 1-th channel, the standard deviation would be a good opportunity to trade in the short side.

Trader Michael Walker.
I use linear regression in combination with stripes Bollindzhera (both LEDs at 2 standard deviations) to identify the peaks and the grounds.

50 bar automatic 1 pre-smoothing at 2 minute schedule of S & P 500. When the price band Bollindzhera channels and regression are found all together at the top or on the basis of the schedule and price, according to the oscillator is in a state of perekuplennosti or pereprodannosti (unless this trend day), then it is time to sell or buy.



www.linnsoft.com

Expert opinion. Jin Speling

Expert opinion. Jin Speling
"The Fed and the ECB - two banks, one oil problema"



Jin Speling, was chief economic adviser to former U.S. President Bill Clinton, is a senior member of the Council on Foreign Relations and the analyst "Bloomberg News"

High oil prices are down-known desire of American President Harry Truman on one-economist, who has never offered a solution "on the one hand, on the other side."

Oil prices are twofold: on the one hand, they can increase prices throughout the economy, accelerating inflation and justify more stringent monetary policy, but on the other hand, they could reduce consumer spending, slow the nascent growth and provide a reason for monetary relief.

Hence, the recent rise in oil prices could trigger "on a single continent, one on another continent, another" - the gap between the focus on economic growth the U.S. Federal Reserve system, and more focused on inflation, European Central Bank.

Earlier this month, Federal Reserve Chairman Alan Greenspan raised the issue of oil prices, raising concerns about inflation, when he said that "the constant increase in energy prices is an element of concern in the painting costs.

Away from a compromise
But last week, observers Federal Reserve, seemed to return to the announced position that higher energy prices will do more than Greenspan's caution in raising rates. Why? The increase of 0.6% in consumer prices in May, which almost spilled at the core of inflation volunteer at the modest 0.2% - and zaveritelnye speech Greenspan, that the movement was far from a compromise.

It is hardly news last week was necessary to conclude that the cost of energy is not likely to prompt the Fed to raise rates faster than the projected 25 basis points per meeting. First, some analysts point out that investment in the growing knowledge-intensive sectors have made the U.S. economy less energy - energy consumption per dollar of real gross national product fell from 1973. by 46%.

Oil Addiction
During the same period, we have also become much more dependent on foreign sources of oil, which means that profit from price increases pumped foreign producers, not returning to the American economy. "Goldman Sachs Group Inc." estimates that net oil imports actually increased as a percentage of gross domestic product from 0.9% in 1970. to 1.2% in 2003., assuming that the impact of oil prices on U.S. real income, if anything, slightly higher than in 1970.

"Merrill Lynch and Co." recently forecast that the price of oil at $ 40 a barrel could reduce growth in gross domestic product in 2004. approximately 0.5%.

In addition, increases in energy prices could have an even greater impact on demand than economists expected, because the effect of his pockets, which have higher prices at filling stations or in the accounts for the heat, can affect ordinary families.

Difficult to answer
In his speech in April 2002. Greenspan more than hinted that economic models can not fully capture the impact that the increase in energy prices could have on consumer demand. "Sensitive response of the U.S. gross domestic product to energy prices," he explained, "is much more complex and may be quite different response of households and businesses at an extraordinary price growth. Macroeconomic models typically do not cover the effect of sudden and significant change in oil prices the economy. "

Finally, even though we are three years in exceptional circumstances, monetary, vyalaya weakness in the labor market has not been completely changed to three months of consistent growth in jobs. Real weekly wages actually fell in December 2001. And labor force participation is the lowest in 1988.

As the head of the Federal Reserve, Donald Kohn at the beginning of the month "the economy continues to be visible, although weak and declining."

The budget deficit
And with the restoration, so depending on the percentage of sensitive economic sectors such as housing and cars, the Fed has cause for concern - as the purchase of these expensive items would be affected, since the market fully adjusts to the long-term problem of a large budget deficit, even if returned to steady growth .

On the other side of the Atlantic, energy prices could force central banks, to fear inflation more than slow growth. While the European economy has recently seen a modest recovery, 9% of th unemployment and annual growth in gross domestic product to 1.3% in the first quarter, which could imply that the European Central Bank would focus more on economic growth.

Back in April, the ECB has taken into account calls for lower rates, and since then, rising oil prices have increased the percentage of inflation to 2.5% per year, the highest for two years. With the objective of inflation close to but below "2%, European Central Bank, it is unlikely, would decline in rates and may even consider the possibility of their recovery by giving Greenspan and ??? with him one more reason to fear the aggressive compression of the economy.

ECB President Jean-Claude Trichet recently reiterated that "whatever happens, our main task is to prevent repetitive effects, which would have higher inflation, a permanent feature of our economy and that will hinder us to ensure price stability."

The moral of all this is that oil prices always require that the representatives of central banks "have two hands" - to weigh the "stagnation" against inflation. " Different responses to oil prices on both sides of the Atlantic have much to say about the global monetary policy for many months in advance.



bloomberg.com