Getting Started
Getting Started
Analytics
Graphical objects
Technical Indicators
Technical indicator is a mathematical manipulation of a security price and/or volumes aimed at
forecasting of future price changes. Decisions about how and when to open or close positions can
be made on basis of signals from technical indicators. According to their functionalities, indicators
can be divided into two groups: trend indicators and oscillators. Trend indicators help to assess the
price direction and detect the turn moments synchronously or with a delay. Oscillators allow to
find the turning moments ahead or synchronously.
Indicators are imposed into the chart from the "Navigator" window by means of Drag`n`Drop
technique, by execution of the "Insert – Indicators" menu command, or by pressing of the
tb_charts_indicators button of the "Charts" toolbar. A technical indicator can be drawn in a
separate indicator window that has a specific vertical scale (for example, MACD)
Besides analytical parameters, one can set colors for various elements, thickness of lines, and sizes
of signs used, at setting up of the indicator. Moreover, the visualization mode of the object for
different timeframes can be changed in the "Visualization" tab. At that, indicator will be shown on
at timeframes that have been selected. This function can be useful if the tool has different settings
for different timeframes. Using the "Show in the Data Window" option in the same tab, one can
control over visualization of information about indicators in the "Data Window".
All settings can be changed. To do so, one has to select the desired indicator in the "Indicators List"
window and press the "Edit" button or execute the "Properties..." command of the indicator
context menu.
Indicator context menu can be called by clicking with the right mouse button on a line, sign, or
diagram of the desired indicator. To remove an indicator, one has to execute the "Delete Indicator"
indicator context menu command or the "Delete Indicator Window" command in the chart or
indicator context menus. The "Delete Indicator Window" command closes the indicator window.
Accumulation/Distribution
Bears Power
Bulls Power
Demarker
Envelopes
Force Index
Fractals
Gator Oscillator
Ichimoku Kinko Hy
Momentum
Moving Average
The Moving Average Technical Indicator shows the mean instrument price
value for a certain period of time. When one calculates the moving average,
one averages out the instrument price for this time period. As the price
changes, its moving average either increases, or decreases.
There are four different types of moving averages: Simple (also referred to as
Arithmetic), Exponential, Smoothed and Linear Weighted. Moving averages
may be calculated for any sequential data set, including opening and closing
prices, highest and lowest prices, trading volume or any other indicators. It is
often the case when double moving averages are used.
The only thing where moving averages of different types diverge considerably
from each other, is when weight coefficients, which are assigned to the latest
data, are different. In case we are talking of simple moving average, all prices
of the time period in question, are equal in value. Exponential and Linear
Weighted Moving Averages attach more value to the latest prices.
The most common way to interpreting the price moving average is to
compare its dynamics to the price action. When the instrument price rises
above its moving average, a buy signal appears, if the price falls below its
moving average, what we have is a sell signal.
This trading system, which is based on the moving average, is not designed
to provide entrance into the market right in its lowest point, and its exit right
on the peak. It allows to act according to the following trend: to buy soon
after the prices reach the bottom, and to sell soon after the prices have
reached their peak.
Moving averages may also be applied to indicators. That is where the
interpretation of indicator moving averages is similar to the interpretation of
price moving averages: if the indicator rises above its moving average, that
means that the ascending indicator movement is likely to continue: if the
indicator falls below its moving average, this means that it is likely to
continue going downward.
Here are the types of moving averages on the chart:
Simple Moving Average (SMA)
Exponential Moving Average (EMA)
Smoothed Moving Average (SMMA)
Linear Weighted Moving Average (LWMA)
Calculation
Simple, in other words, arithmetical moving average is calculated by summing up the prices of
instrument closure over a certain number of single periods (for instance, 12 hours). This value is
then divided by the number of such periods.
SMA = SUM(CLOSE, N) / N
Where:
N — is the number of calculation periods.
Exponentially smoothed moving average is calculated by adding the moving average of a certain
share of the current closing price to the previous value. With exponentially smoothed moving
averages, the latest prices are of more value. P-percent exponential moving average will look like:
Where:
CLOSE(i) — the price of the current period closure;
EMA(i-1) — Exponentially Moving Average of the previous period closure;
P — the percentage of using the price value.
The first value of this smoothed moving average is calculated as the simple moving average (SMA):
SUM1 = SUM(CLOSE, N)
SMMA1 = SUM1/N
The second and succeeding moving averages are calculated according to this formula:
PREVSUM = SMMA(i - 1) * N
Where:
SUM1 — is the total sum of closing prices for N periods;
PREVSUM — smoothed sum of previous bar;
SMMA1 — is the smoothed moving average of the first bar;
SMMA(i) — is the smoothed moving average of the current bar (except for the first one);
CLOSE(i) — is the current closing price;
N — is the smoothing period.
In the case of weighted moving average, the latest data is of more value than more early data.
Weighted moving average is calculated by multiplying each one of the closing prices within the
considered series, by a certain weight coefficient.
Where:
SUM(i, N) — is the total sum of weight coefficients.
A popular method of analyzing the RSI is to look for a divergence in which the security is making a
new high, but the RSI is failing to surpass its previous high. This divergence is an indication of an
impending reversal. When the Relative Strength Index then turns down and falls below its most
recent trough, it is said to have completed a "failure swing". The failure swing is considered a
confirmation of the impending reversal.
Stochastic Oscillator
Trading
The fundamental and simple rule of profitable trading at financial markets is to buy cheaper and
sell dearer. Thus, the entire trading activities at financial markets come to the successive
operations performed to sell or buy securities. To do so, one has to open, modify, and close trade
positions. Trade position is a market commitment (order), the number of bought or sold contracts
for which no set-off transactions have been made. The entire trading in the terminal is
implemented through trade positions.
To open a trade position, one has to make a transaction, and to close a position, one has to make an inverse
operation. A position can be opened by a brokerage company at a market order or at execution of a pending order.
An open position can be modified if values of the Stop Loss and Take Profit orders levels attached to the position
are changed. Positions can be closed on the trader's demand or at execution of Stop Loss or Take Profit orders.
Besides, positions can be opened, modified, or closed with an expert advisor — this mechanism is described in
another section.
Order Types
Client terminal allows to prepare requests and request the broker for execution of trading operations. Moreover,
terminal allows to control and manage open positions. For these purposes, several types of trading orders are
used. Order is a client's commitment to brokerage company to perform a trade operation. The following orders are
used in the terminal: Market order, Pending order, Stop Loss and Take Profit.
Market Order
Market order is a commitment to the brokerage company to buy or sell a security at the current price. Execution of
this order results in opening of a trade position. Securities are bought at ASK price and sold at BID price. Stop Loss
and Take Profit can be attached to a market order. Execution mode of market orders depends on security traded.
Pending Order
Pending order is the client’s commitment to the brokerage company to buy or sell a security at predefined price in
the future. This type of orders is used for opening of a trade position provided the future quotes reach the
predefined level. There are four types of pending orders available in the terminal:
Buy Limit -- buy provided the future “ASK” price is equal to the predefined value. The current price level is
higher than the value of the placed order. Orders of this type are usually placed in anticipation of that the
security price, having fallen to a certain level,will increase;
Buy Stop -- buy provided the future “ASK” price is equal to the predefined value. The current price level is
lower than the value of the placed order. Orders of this type are usually placed in anticipation of that the
security price,having reached a certain level,will keep on increasing;
Sell Limit -- sell provided the future "BID" price is equal to the predefined value. The current price level is
lower than the value of the placed order. Orders of this type are usually placed in anticipation of that the
security price, having increased to a certain level, will fall;
Sell Stop -- sell provided the future "BID" price is equal to the predefined value. The current price level is
higher than the value of the placed order. Orders of this type are usually placed in anticipation of that the
security price, having reached a certain level, will keep on falling.
Orders of Stop Loss and Take Profit can be attached to a pending order. After a pending order has triggered, its Stop Loss and Take Profit
Stop Loss
This order is used for minimizing of losses if the security price has started to move in an unprofitable direction. If
the security price reaches this level, the position will be closed automatically. Such orders are always connected to
an open position or a pending order. The brokerage company can place them only together with a market or a
pending order. Terminal checks long positions with BID price for meeting of this order provisions (the order is
always set below the current BID price), and it does with ASK price for short positions (the order is always set
above the current ASK price).
To automate Stop Loss order following the price, one can use Trailing Stop.
Take Profit
Take Profit order is intended for gaining the profit when the security price has reached a certain level. Execution of
this order results in closing of the position. It is always connected to an open position or a pending order. The order
can be requested only together with a market or a pending order. Terminal checks long positions with BID price for
meeting of this order provisions (the order is always set above the current BID price), and it does with ASK price for
short positions (the order is always set below the current ASK price).
Attention:
execution prices for all trade operations are defined by the broker;
Stop Loss and Take Profit orders can only be executed for an open position, but not for pending orders;
history charts are drawn only for BID prices in the terminal. At that, a part of orders shown in charts is drawn for ASK prices. To enable
displaying of the latest bar ASK price, one has to flag the "Show Ask line" in the terminal settings.
Trailing Stop
Stop Loss is intended for reducing of losses where the symbol price moves in an unprofitable direction. If the
position becomes profitable, Stop Loss can be manually shifted to a break-even level. To automate this process,
Trailing Stop was created. This tool is especially useful when price changes strongly in the same direction or when
it is impossible to watch the market continuously for some reason
Trailing Stop is always attached to an open position and works in client terminal, not at the server like Stop Loss, for
example. To set the trailing stop, one has to execute the open position context menu command of the same name
in the "Terminal" window. Then one has to select the desirable value of distance between the Stop Loss level and
the current price in the list opened. Only one trailing stop can be set for each open position.
After the above actions have been performed, at incoming of new quotes, the terminal checks whether the open
position is profitable. As soon as profit in points becomes equal to or higher than the specified level, command to
place the Stop Loss order will be given automatically. The order level is set at the specified distance from the
current price. Further, if price changes in the more profitable direction, trailing stop will make the Stop Loss level
follow the price automatically, but if profitability of the position falls, the order will not be modified anymore. Thus,
the profit of the trade position is fixed automatically. After each automatic Stop Loss order modification, a record
will be made in the terminal journal.
Trailing stop can be disabled by setting "None" in managing menu. And trailing stops of all open positions and
pending orders will be disabled if the "Delete All" command of the same menu has been executed.
Trailing Stop works in the client terminal, not in the server (like Stop Loss or Take Profit). This is why it will not work, unlike the above
orders, if the terminal is off. In this case, only the Stop Loss level will trigger that has been set by trailing stop.
Trailing Stop is processed once per tick. If multiple orders with Trailing Stop are open for one symbol, only the trailing stop of the latest
Types of Execution
There are three order execution modes in the client terminal:
Instant Execution
In this mode, the order is executed at the price offered to the broker. At sending the order to be executed, terminal
sets the current prices in the order. If broker accepts the prices, the order will be executed. If not, the so-called
"Requote" will occur: Broker returns prices at which the order can be executed.
Execution on Request
In this mode, the market order is executed at the price previously received from the broker. Prices for a certain
market order are requested from the broker before the order is sent. When the prices comes, order execution at
the given price can be either confirmed or rejected.
Execution by Market
In this order execution mode, broker makes a decision about the order execution price without any additional
discussion with the trader. Sending of the order in such a mode means advance consent to its execution at this
price.
Attention: Execution mode for each security is defined by the brokerage company.
Trade Positions
The fundamental and simple rule of profitable trading at financial markets is to buy cheaper and sell dearer. Thus,
the entire trading activities at financial markets come to the successive operations performed to sell or buy
securities. To do so, one has to open, modify, and close trade positions. Trade position is a market commitment
(order), the number of bought or sold contracts for which no set-off transactions have been made. The entire
trading in the terminal is implemented through trade positions. Client Terminal gives a large amount of
opportunities in controlling and managing trade positions. Trader gives instructions (orders), and brokerage
company opens or closes a position. Managing trade positions consists in:
•opening of a position — buying or selling of a security as a result of a market or a pending order execution;
•modifying of a position — changing of the Stop Loss and Take Profit levels attached to the open position;
•placing of pending orders — placing of pending orders like Buy Limit, Buy Stop, Sell Limit, or Sell Stop;
•modifying and deletion of pending orders — modifying or deletion of pending orders that did not trigger;
•closing of a position — buying or selling a security in order to close the existing open position.
Open Positions
Opening of a position, or entering the market, is the first buying or selling of a certain amount of the security
traded. Position can be opened either by execution of a market order or by automatic triggering of a pending
order.
Market Order
To open a position using a market order, one has to execute the "Tools — New Order" menu command, press the
New Order button of the "Standard" toolbar, press F9, or double-click on the symbol name in the "Market Watch"
window. One can also execute the "New Order" context menu command of the windows of "Market Watch" and
"Terminal — Trade". At that, the "Order" window will open that is used for managing trade positions.
Attention: Zero values of Stop Loss/Take Profit orders mean that the orders have not been placed at all.
•Comment — write a comment (optionally). The comment length may not exceed 25 characters. The brokerage
company may add a comment not above 6 characters long, or it can completely replace the existing one. After a
position has been opened, the comment cannot be changed;
•Type — the execution mode specified by the broker for the given symbol is displayed in this filed on default.
You can also choose the "Pending order" in the list here, which allows you to go to placing a pending order.
•Enable maximum deviation from quoted price — enable/disable the use of deviation. If a broker requotes the
price of order execution, the deviation of the new price from the quoted before will be calculated. At that, if the
deviation is below or equal to the specified parameter, the order will be executed at the new price without any
additional notifying. Otherwise, the broker returns new prices at which the order can be executed;
•Maximum deviation — the value of maximum permissible deviation in pips.
•Price deviation at placing of orders is used only in the instant execution mode.
•The trade window displays current best Bid and Ask price (except for the Execution on Request mode).
After all necessary data have been specified, one has to press the "Sell" or "Buy" button. At that, the order for
opening of a short or long position, respectively, will be sent to the broker.
Once the order is sent the window will display the result of its execution — a successful trade operation or a
reason why it has not been executed. If the "One click trading" option is enabled and the order has been
successfully executed the trading window is closed right away without displaying the execution result.
Attention: If orders for a given symbol are executed at request, it is necessary to press the "Request" button to
receive quotes first. Quotes offered after requesting will be active for just a few seconds. If no decision is made
within these seconds, "Sell" and "Buy" buttons will be locked again.
If the Stop Loss or Take Profit level is too close to the current price at opening of a position, the message of "Invalid
S/L or T/P" will appear. It is necessary to shift levels from the current price and re-request for placing of the order. A
trade position will be opened after the brokerage company has made a trade and set Stop Loss and Take Profit. At
that, the status bar of the opened position will appear in the "Terminal — Trade" tab, and open price, Stop Loss
and Take Profit levels will be shown in the chart (if the "Show trade levels" option is enabled).
Pending Orders
To open a position with a pending order, one has to place it first as described in the "Placing of Pending Order"
section. If the current prices meet its provisions, the pending order will be executed automatically, i.e., a new trade
position will be opened. At that, the status bar of the pending order will be deleted in the "Terminal — Trade" tab,
and the newly opened position status bar will appear. If Stop Loss and Take Profit orders were attached to the
pending order, they will be attached to the new position automatically.
Modifying of Positions
Modifying of the current position consists in setting of new levels of Stop Loss or Take Profit attached to it. To
modify a position, one has to execute the "Modify or Delete Order" command of the opened position context
menu or doulbe-click with the left mouse button in the fields of "Stop Loss" or "Take Profit" of the opened position
line in the "Terminal" window.
Then, one has to set new values of Stop Loss or Take Profit and press the "Modify" button.
To change the Stop Loss or Take Profit values, one has to enter the new values in the corresponding fields. To place
the order in points from the current price, one has to set the desired value in the "Level" field and press the "Copy
as" button. If values of these fields are zero, the minimum permissible deviation is used to be set by broker.
If Stop Loss or Take Profit level is too close to the current price, the "Modify" button will be locked. It is necessary
to shift levels from the current price and re-request for position modifying. A trade position will be modified after
the brokerage company has set a new value for Stop Loss or Take Profit, or both. Values in the fields of "S/L" and
"T/P" will be changed in the opened position status bar in the "Terminal — Trade" tab. At that, levels of the
modified orders will be changed if the "Show trade levels" option is enabled.
Attention: Zero values in the fields of "Stop Loss" and "Take Profit" mean that these orders were not placed.
Position Close
Buying or selling of a security opens a trade position. Then, in order to gain profit of the bid-and-ask price
differences, one has to close the position. The latter trade operation is reverse towards to former one. For
example, if the former operation consisted in buying of one lot of GOLD, then one lot of the same symbol must be
sold to close the position. Positions can be closed differently in the client terminal: It can be closing of a single
position, closing of a position by an opposite position, and multiple close by several positions.
Attention:
•in the "Execution on request" mode, the offered quotes will be active for just a few seconds. If no decision has
been made within these seconds, the "Close... " button will be locked again;
•client terminal allows to close positions partially. To do so, one has to specify the amount of lots less than that
given for the opened position in the "Volume" field before pressing of the "Close... " button;
•broker can close positions, as well. For example, it can be done when prices reach the "Stop Out" level that was set
by the broker;
•history charts are drawn only on BID prices in the terminal. At that, a part of orders shown in charts is drawn on
ASK prices. To get ASK price of the latest bar shown, one has to flag "Show Ask line" option in the terminal settings.
Trading on Chart
The client terminal allows traders to perform trading operations right on the symbol's chart. Combined with one
click trading function, this enables users to open, modify and close positions quickly, as well as manage pending
orders.
If One click trading option is enabled in the terminal settings, trading commands described in this section are
executed without additional confirmation (trading dialog is not displayed).
Using this panel you can instantly send buy or sell market orders with specified volumes.
•When trading in the instant execution mode, the acceptable deviation of price in the orders is set according to the
"Deviation" option.
•When a getting a requote, the corresponding message is written to the terminal journal and the requote sound is
played.
Place mouse cursor on the necessary price level on the chart and execute the appropriate command to install a
pending order in the context menu.
According to the cursor's position, available order types are displayed in the menu. If the menu is activated above
the current price, user can place Sell Limit and Buy Stop orders. If the menu is activated below the current price,
Buy Limit and Sell Stop orders can be placed.
Available distance between the selected and current price for the symbol is additionally checked ("Stops level").
The volume for the orders placed is selected via the quick trading panel on the chart.
After executing the command, Order window will appear allowing users to adjust its parameters more precisely. If
"One click trading" option is enabled in the terminal settings, orders are placed at a specified price instantly
without displaying the trading dialog.
When moving an order there is a tooltip displaying the distance to the current price in the deposit currency and
pips.
After setting the level, order modification window will appear allowing users to adjust the level more precisely. If
"One click trading" option is enabled in the terminal settings, modification is performed instantly without
displaying the trading dialog.
You can change or remove your pending orders, as well as set a trailing stop using pending order's context menu
on the chart:
•Modify or delete Modify — open the window of the selected order modification;
•Delete order Delete — open the window for deleting the selected order. If "One click trading" option is enabled in
the terminal settings, deletion is performed instantly without displaying the trading dialog;
•Trailing Stop — open the menu of Trailing Stop level selection for an order.
Auto Trading
Term
Market depth
In finance, market depth is a real-time list displaying the quantity to be sold versus unit price. The list is organized
by price level and is reflective of real-time market activity. Mathematically, it is the size of an order needed to move
the market price by a given amount. If the market is deep, a large order is needed to change the price.
Factors influencing market depth
Tick size. This refers to the minimum price increment at which trades may be made on the market. The major stock
markets in the United States went through a process of decimalisation in April 2001. This switched the minimum
increment from a sixteenth to a one hundredth of a dollar. This decision improved market depth.[1]
Price movement restrictions. Most major financial markets do not allow completely free exchange of the products
they trade, but instead restrict price movement in well-intentioned ways. These include session price change limits
on major commodity markets and program trading curbs on the NYSE, which disallow certain large basket trades
after the Dow Jones Industrial Average has moved up or down 200 points in a session.
Trading restrictions. These include futures contract and options position limits as well as the widely used uptick
rule for US stocks. These prevent market participants from adding to depth when they might otherwise choose to
do so.
Allowable leverage. Major markets and governing bodies typically set minimum margin requirements for trading
various products. While this may act to stabilize the marketplace, it decreases the market depth simply because
participants otherwise willing to take on very high leverage cannot do so without providing more capital.
Market transparency. While the latest bid or ask price is usually available for most participants, additional
information about the size of these offers and pending bids or offers that are not the best are sometimes hidden
for reasons of technical complexity or simplicity. This decrease in available information can affect the willingness of
participants to add to market depth.
In some cases, the term refers to financial data feeds available from exchanges or brokers. An example would be
NASDAQ Level II quote data.
Key Takeaways
Market depth refers to the market liquidity for a security based on the number of standing orders to buy (bids)
and sell (offers) at various price levels.
In addition to price levels, market depth considers the order size, or volume, at each price level.
The greater the market depth, the less likely that large trades will greatly impact a security's price.
Market depth can be ascertained by looking at level 2 price quotes that can be found in a security's order book.
Bid Price/Ask Price
The term "bid" refers to the highest price a buyer will pay to buy a specified number of shares of a stock at any
given time. The term "ask" refers to the lowest price at which a seller will sell the stock.
The bid price will almost always be lower than the ask or “offer,” price. The difference between the bid price and
the ask price is called the "spread."
Q1: provide me with codes for an Expert advisor on Metatrader 4 which works based on the following conditions:
Sure! Please provide the specific conditions you want the Expert Advisor (EA) to
follow. Here are some details to consider:
1. Entry Conditions
What indicators should the EA use? (e.g., Moving Average, RSI, MACD, Bollinger Bands)
Should it buy/sell based on crossovers, price action, or other conditions?
2. Exit Conditions
Do you want a fixed Stop Loss (SL) and Take Profit (TP)?
Should the EA close trades when an opposite signal appears?
3. Trade Management
Provide these details, and I'll generate the MQL4 code for you!
Q 2:
provide me with codes for an Expert advisor on Metatrader 4 which works based on the following
conditions:
# Entry Conditions
## indicators should the EA use Moving Average
## Buy based on crossovers
# Exit Conditions
## Do you want a fixed Stop Loss
## the EA close trades when an opposite signal appears
# Trade Management
## Fixed lot size
## only one at a time
## Trailing Stop