Trader's Handbook: orders, prices, stack, funds, currency

 


I thought, why not make a good reference thread .

In it I would like to cover the most important questions about the work of markets, liquidity providers, MT5 platform, which are asked not only by beginners.

Приглашаю всех желающих, у кого есть какая-либо интересная и редкая инфа излагать её в справочном формате.
Обсуждение в ветке вести не надо, Только посты со справочным материалом.
Начать писать лучше в общем обсуждение в ветке черновиков, и после оценки и исправления перенести свой пост сюда.
По мере копания в гугле и нахождению буду тоже выкладывать сюда.

Please follow just a few rules for the content of the information

1. be really interesting and important ( rare, unique, empirical - in general, not a primer, but a broad disclosure of the concept).
2. be complete without reference to other forums or sites (as well as "look for I have already written or seen somewhere" - this is inadmissible)
3. Contain an indication of the original source (or your profile, if it is your authoritative opinion)

Off-topic posts will be deleted little by little to keep the beauty and order ;)

It is important for us to know how many readers after reading this thread became aware of thematerialpresented .
If this thread helped you to understand how the market works (you are able to retell it to another reader, as well as any understood material),
go here and put a like against this thread.
No feedback is required, just a like is enough.


For those who have information on some concepts:

- difference of markets (Stocks, Forex, etc.)
- simple HFT MM algorithm and necessary conditions when it is profitable.
-
peculiarities of STP and ECN/STP trading platforms.

please comment or post in the thread.



Value date on Forex
*

Swap operation

How Forex quotes are formed

Who isa market maker * *

Who is a market maker[2] * *

Who is aliquidity provider *

Square-forming exchange algorithm *

Executionof Limit Orders on the Exchange *

Execution of Limit Orderson Futures and Forex *

Types of traders *

Models of brokers' work *

Classification of brokers of the FOREX currency market .

Quants. Co-integration. Arbitrage. Markup.

Simple aggregator. Creation of a trading platform. *

Example of MM-algorithm indicators. *

11. Дата валютирования на Forex - Энциклопедия Forex
  • enc.fxeuroclub.ru
Как уже говорилось, рынок Forex в широком понимании включает не только сделки покупки и продажи одной валюты за другую с расчетами сразу, то есть сегодня, но и в другие временные промежутки. Дата расчетов - то есть дата физического перемещения средств на счета контрагентов - на финансовом языке называется датой валютирования (или Value date...
 

How to read a reference book.

hrenfx:

As it turns out, writing a reference book isn't enough, you also need to teach how to read/receive it properly.

Reading/reception speeds.

Classical reading speed (CRS) - the number of letters (words) per unit of time.

Perceptual speed of information (PSI) - the amount of understanding/digestion of the contained information per unit of time.

In most cases, each person's BCC is almost unaffected by the true content of what they read. This is a terrible scourge of information perception, from which it is necessary to get rid of in the direction of constancy not of the RAC, but of the RAS.

Let's take a simple example. Most people read fiction and scientific literature with the same RMS. That is, when reading a scientific work, the brain practically does not work, running through a set of letters. In the case of fiction, this is sometimes justified, but not otherwise.

How to Read Fiction.

It is necessary to go from the widespread constancy of BCC to the infrequent constancy of SWI.

For example, it takes orders of magnitude longer (if necessary) to get into the meaning of a few sentences than if you just read it with your BCC.

The fact is, most people read a given piece of literature within ~half an hour. And this time depends, as a rule, only on the individual BCC. As a result - "abstruse and unnecessary". Which, of course, is not true.

In fact, the amount of information contained in the presented lecture is so much that the time of its perception should be measured in days.

If you have not spent a few days to occasionally digest what you have read here, then with a high probability you have not fully understood what has been written.

You will hardly get into it if you don't start parsing each paragraph with pen and paper, building various schemes and variants. Trying something in the terminals and finding or refuting various conjectures/assumptions that arise during thinking.

Determining the quality of the level of perception.

When any question (one's own or someone else's) can easily fit into the created near-market understanding, we can say that the picture about the market fundamentals is qualitatively collected. If something does not fit - close the gap by any means except one: closing your eyes.
 

Forex Value Date*


As we have already mentioned, the Forex market in a broad sense includes not only transactions of buying and selling one currency for another with settlements immediately, i.e. today, but also at other time intervals.

Thesettlement date - that is, the date on which funds are physically moved into the accounts of counterparties - is known in financial language as the value date (or Value date ).

The following value dates are commonly used in the financial market:

  • Today (Tod) - settlements are made today, on the day the transaction is concluded
  • Tomorrow (Tom) - settlements are made on the next working day after the day of conclusion of the deal
  • Spot - settlements are made on the second working day after the day of conclusion of the deal.

    Note: all deals concluded with settlement date before the second business day are called cash conversion transactions.

    Note: the day of conclusion of the deal is the day on which agreements on the main parameters of the deal were made:

  • definition of the parties' actions (purchase and sale);
  • name of the currency being bought and sold;
  • the amount (volume) of the transaction;
  • transaction exchange rate (transaction rates for SWAP-type transactions) ;
  • value date (value dates for SWAP-type transactions) ;
  • payment instructions of counterparties;

    Forex market also uses transactions with value date more than 2 working days from the date of conclusion of the transaction - they are called forward transactions or forward conversion transactions. Value dates are agreed upon at the time of the transaction.

    Derivatives such as options are also traded on the Forex market.
    There are two types of options:

  • American option - the right (but not the obligation) of the buyer to buy or sell the underlying asset at a certain price before a certain date.
  • European option - the right (but not the obligation) of the buyer to buy or sell the underlying asset at a certain price on a certain date.

    Depending on what right arises when buying an option, to buy or sell the underlying asset, there are Call (Call) and Put (Put ) options, respectively.

    The most popular on the Forex market are operations carried out on Spot terms. Usually it is connected with the need for time for registration and settlement with a counterparty located in another time zone.
    SWAP or Swap transactions are also carried out on the Forex market (more details on which are given in the next section).

  • 11. Дата валютирования на Forex - Энциклопедия Forex
    • enc.fxeuroclub.ru
    Как уже говорилось, рынок Forex в широком понимании включает не только сделки покупки и продажи одной валюты за другую с расчетами сразу, то есть сегодня, но и в другие временные промежутки. Дата расчетов - то есть дата физического перемещения средств на счета контрагентов - на финансовом языке называется датой валютирования (или Value date...
     

    Swap operation

    Swap, sometimes also called Rolover or Overnight in Forex, is a simultaneous conclusion of two opposite transactions with different value dates, one of which closes an already open position and the other immediately opens it. The swap rate and the swap value are determined at the time of the transaction. The purpose of the transaction is usually to extend an open position.

    Example of a Swap transaction :
    Let's say you bought 500,000 eur/usd at 1.2347 on 17 August 2004 (Tuesday) on Spot terms (i.e. with a settlement date of 19 August - Thursday). On 19 August you will receive 500,000 eur in your account and you should be debited 617,350 (500,000 x 1.2347) usd.


    However, if you are on a leveraged margin trade, you probably do not have that many dollars in your account and will not be able to meet your obligations to the counterparty on 19 August (settlement day). Therefore, you must extend or "unwind" your position. Suppose, being confident in your movement, you did not close your position on 17 August intraday and do not intend to close it on the next day, 18 August. In this case you do a Swap - Tom - Spot operation, i.e. you execute two opposite trades with different settlement dates.
    Let's assume that you are right in your decision and the price of Eur/Usd has indeed risen over the previous day, stopping at 1.24.

    On the 18th of August you sell 500,000 eur/usd (at 1.2400) on Tom terms, i.e. with settlement date of the 19th of August and buy them (at 1.2400) on Spot terms with settlement date of the 20th of August.

    In time deals are distributed in the following way.


    Since you first had a purchase on the 17th of August with settlement on the 19th and now a sale on the 18th with settlement on the 19th, your claims of 500,000 euros and your obligations to deliver 500,000 euros are mutually destroyed (netting) as a result of the Swap transaction. The position in dollars is also netting, but partially, because the 2 transactions (settlement on the 19th) are carried out at different prices (1.2347 and 1.2400). And since you have to transfer 500,000x1.2347 = $617,350 and you have to transfer 500,000x1.2400= $620,000, the netting will result in a net difference of $2,650.

    After the Swap operation, you will have an open position that will be settled in 2 business days, i.e. on the 20th.

    Suppose again, the next day on the 19th of August (Thursday) you do not want to close the position (settlement of which should take place on the 20th of August), and the price has dropped a bit (to 1.2387), then you perform the Swap operation again. You sell 500 000 eur/usd (at 1.2387) by tom settlement (20 August - Friday) and buy them (at 1.2387) by Spot settlement (23 August - Monday).


    As a result of the swap operation you will have an open position with the settlement date 2 working days away from the current day (the day of the deal).

    In tabular form it will look as follows.


    There is one more very significant point in swap calculation, which is not described above (in order to simplify the explanation). In fact, simultaneous Tom and Spot transactions are usually not done at the same price, but at different prices that differ slightly from each other.

    For example, you are trying to extend your open buy position. Then, you can sell the Euro at 1.2378 (tom) and immediately buy back the position at 1.237760 (Spot) or 0.4 pips cheaper. It turns out that you (all other things being equal) earn money just by being in the position.

    However, it can be the other way round: if you are trying to shed a sell position and you buy Euros on Tom and sell on Spot, the swap is likely to be negative for you (or in other words you will pay to extend the position by buying a bit more expensive than selling).

    The answer to why the swap price can be different (negative and positive, as well as varying) lies in what the dealer who executes your orders actually does.

    Calculating a Swap

    Let's see what it does with an example.
    Let's say you are trying to extend a long position (euro buy position) and move the value date from 19 to 20 August, for example. For the dealer it means that he will have to give you the euros (devalue) one day later, but he will receive the dollars from you one day later. The dealer (on the 19th) has an "extra" (for a day) amount in euros equal to your position and on the same day a shortage (for one day) of dollars, which you are not going to deliver to him.

    Accordingly, the dealer takes and places (gives interbank credit) the amount in euros for 1 day, and attracts (takes interbank credit) for 1 day the required amount in dollars.

    Now let's add interbank lending rates to the calculation.
    Suppose the interbank rates for euros and dollars are as follows:

    Rate Euro Dollar
    Attraction Placement Attraction Placement
    1 day 3,5 3 2,5 2,3

    So, the dealer places "extra" 500 000 euros at the rate of 3% per annum, receiving for this (500 000x3%)/365=41.095 euros, which is equal to 41.095x1.2378=50.88 dollars.

    At the same time, the dealer raises the sum of $500,000 x 1.2378 = $618900 at the rate of 2.5% per annum and gives for this (618900 x 2.5%)/365 = $42.39.

    The net income for the transaction will be $50.88-42.39=$8.49.
    This is the Swap in dollars that he can give to you.
    For many reasons (such as accounting), the dealer cannot credit you this money for nothing, so he puts it into the price of your swap transactions. It's more convenient that way, and that's why it's accepted in dealing.

    If 1 pip on a 500,000 euro lot equals $50, then 8.49 equals about 0.2 pips. That is why the dealer performs the operation with you in the following way: for example, you sell euros by tom (19th day) at 1.2378 and buy it immediately at 1.237780 (i.e. 0.2 points cheaper), thus receiving these 0.2 points and the corresponding amount in dollars.

    The point of a positive swap is that the placement rate for the currency you buy in the position is higher than the borrowing rate for the currency you sell in the position.

    If you were trying to extend a sell position, the dealer would give you a negative swap (i.e. charge you) because the placement rate for dollars is less than the draw rate for euros. Calculate the amount of swap points yourself.

    Thus, swap rates depend on the rates of borrowing and placing in currencies on the interbank market. Usually, holding a buy position in a currency with higher rates will earn you a swap, and holding a sell position in a currency with higher rates will pay a swap.

    Why is a large swap charged and debited exactly from Wednesday to Thursday?
    Because by moving the date of position conclusion from Wednesday to Thursday, you move the settlement date from Friday to Monday (three days later). You will be paid swaps for 3 days, but you will also be charged swaps for 3 days.

    Факторы, влияющие на EUR/USD - Энциклопедия Forex
    • enc.fxeuroclub.ru
    США К ключевым факторам, оказывающие влияние на курс eur/usd относится монетарная политика США. Инструментами монетарной, с помощью которых центральный банк может увеличивать или сокращать денежное предложение в стране являются: операции на открытом рынке (open market operations); регулирование учетной ставки (the discount rate); и...
     

    How Forex quotes are formed

    Since the forex market is an interbank market, the main and practically the only source of quotes are banks. The others only relay bank quotes.

    What is a bank quotation.
    Practically every large bank quotes to its clients (legal entities and individuals) and other banks-counterparties (banks with which agreements have been signed and payment details have been exchanged) the rates at which it is ready to make a transaction at the moment. The quotation process itself is carried out through special technical means(trading terminals, Internet, and sometimes by phone).
    This is an indicative quotation, and the bank is usually not obliged to conclude the transaction exactly at this price, because the real price may depend on many facts: the status of the client (whether there is a risk of currency delivery or not), the volume of the operation (small, ordinary or very large volume) the value date (actual settlement of the transaction), etc.

    Where quotes go
    These
    quotes, as well as quotes of real transactions, go to specialised information systems (Reuters, Bloomberg, Tenfor, DBC, etc.), and from the information systems they go all over the world - to the clients of the information systems (back to all banks, individuals, legal entities, etc., all those who are connected to the systems).



    Thus, quotations received from information systems are indicative and do not mean that somewhere in the world a deal has been made on them. Moreover, not all quotes of real deals can get into the information system.
    Dealing centres are also clients of information systems and provide the general flow of quotations to their clients, including their own quotations, as well as quotations on which deals were made with their own clients.
    Ордерa, позиции и сделки в MetaTrader 5
    Ордерa, позиции и сделки в MetaTrader 5
    • 2011.01.05
    • MetaQuotes Software Corp.
    • www.mql5.com
    Надежный торговый робот не может быть создан без понимания механизмов работы торговой системы MetaTrader 5. Клиентский терминал получает от торгового сервера информацию о позициях, ордерах и сделках. Чтобы правильно обработать эти данные средствами MQL5 необходимо хорошо представлять как происходит взаимодействие mql5-программы и среды исполнения терминала.
     

    Market maker

    ( Market maker - a broker/dealer firm that assumes the risk of acquiring and holding securities of a certain issuer on its accounts in order to organise their sales. Market makers act on the exchange and over-the-counter market as direct participants of transactions. At the New York Stock Exchange market-makers are called "specialists". Typically, market makers act on both sides - as both sellers and buyers. Typically, a market maker has an obligation to sell at least 1,000 shares for each of his or her clients (approximately 20-30 for one market maker). Transactions are done over the phone or Internet and take seconds.

    On the stock exchange, a market maker can be, for example, a brokerage firm which, under a contract with the exchange, undertakes to hold simultaneously placed orders with a difference between the buy and sell prices (see Spread (finance)) of no more than a specified value for a specified time (say, at least 90 per cent of trading time), for which the exchange grants the market maker certain privileges, e.g. commission fees.

    Top 10 largest market makers in the foreign exchange market according to Reuters:

    1. Deutsche Bank - 19.30 %
    2. UBS - 14.85 %
    3. Citi - 9.00 %
    4. Royal Bank of Scotland - 8.90 %
    5. Barclays Capital - 8.80 %
    6. Bank of America - 5.29 %
    7. HSBC - 4.36 %
    8. Goldman Sachs - 4.14 %
    9. JP Morgan - 3.33 %
    10. Morgan Stanley - 2.86 %

    Market Maker Functions

    The main function of Market Makers is to maintain Bilateral Quotations for purchase/sale of securities, and within the framework of a trilateral agreement - also to provide services to the issuer on inclusion and maintenance of securities in Quotation Lists.

    What is Bilateral Quotation

    Bilateral quotation is an Order (or Orders) to buy and an Order (or Orders) to sell securities for a certain security announced by the Market Maker, which meet the Spread and Quotation Volume requirements set for the security.

    TheBilateral Quotation Spread is a value calculated as a percentage and defined as the difference between the best price in a Sell Order and the best price in a Buy Order relative to the best price in a Buy Order for a particular security.

    Bilateral Quotation Volume is a value calculated as the sum of products of prices and the number of securities indicated in the Orders in each of the above cases:

    • in the Orders for purchase in the Bilateral Quotation;
    • in Orders to sell in Bilateral Quotation,

    the prices of which satisfy the Quotation Spread set for a certain security. The quotation volume is calculated in the currency in which the Orders are announced.

    In addition to the Spread and the Bilateral Quotation Volume, the following parameters of their maintenance shall also be set:

    • Duration of maintaining Bilateral Quotes, (70% of the duration of the Trading Session);
    • Maximum volume of deals concluded on the basis of the Market Maker's Orders, upon reaching of which the Market Maker is released from obligations on maintenance of Bilateral Quotations.

    The Exchange may also set other additional parameters for a particular security.

     

    Liquidity providers


    The term "liquidity" refers to the state of certain goods, resources, securities, in which they can be purchased or sold quickly and without significant losses in price. The highest degree of liquidity is possessed by cash.

    The main indicator of liquidity

    The main indicator of liquidity is the trading volume. The more transactions are made with an asset, the higher its liquidity. The daily trading volume on the FOREX market is trillions of US dollars, which exceeds many times the volume of the world stock market. That is why the FOREX market has the highest possible liquidity.

    Liquidity in the Forex market

    In FOREX trading practice "liquidity" means, first of all, the ability to quickly sell or buy this or that currency in the necessary volume. Thus, instruments that can be sold or bought quickly are called highly liquid, and assets that take a long time to sell or buy are called low-liquid.

    Liquidity is provided by market makers - large market participants(such as banks), the more market makers provide liquidity to the company, the higher the probability that transactions can be made regardless of time and trading sessions in different countries of the world.

    Liquidity providers

    A liquidity aggregator (provider) is a large market participant that networks the world's largest banks, financial institutions and funds to form a pool of price, quote and news flows for smaller market participants such as brokers, dealing centres, etc.

    Some of the major liquidity providers are Currenex, Integral, LMAX, LCG,

    Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
    Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
    • www.mql5.com
    Получение рыночной информации / SymbolInfoSessionQuote - Документация по MQL5
     

    Market makers

    Many people know that one of the first things they say at a technical university is to forget everything they went through in school. This recommendation is relevant here as well. It is useful to start with a clean slate sometimes.

    At the moment, all markets are automated. For this reason, some economic explanations of pricing are some rudiments. Algorithms + some manual intervention rule.

    The task of every trading algorithm is always the same - to bring money to the owner. The better the algorithm is, the more money it is able to bring.

    Among the algorithms in the market there are so-called market maker algorithms. I can probably explain on my fingers from a simple example to a more complex one (by the way, I wrote a lot of things on forexsystems, arbitrageurs and mql5):

    Imagine you have a task to create a new symbol for trading. Suppose there are people who want to trade it for some reason. What is required of you? You need to form Level2 of your symbol from their orders at any moment. I.e. fill the symbol with prices and liquidity. At the beginning you can make a very stupid MM-algorithm - Level2 does not change. I.e. the client bought or sold, after which you added liquidity to the original Level2. Obviously, such an algorithm will give the owner money all the time. But the problem is that people are not complete idiots, and they will not trade on a symbol-constant - there is not even a potential opportunity for them to earn money.

    So we have to make people make trades somehow. The next dumbest MM-algorithm can be a simple sine wave - Level2 goes up and down. Many people will also lose, but there will be geniuses who will see the pattern and start to bend the owner of MM-algorithm.

    It turns out that it is necessary to invent something so that the MM-algorithm has the maximum difference between those who drain and those who earn. This is where various mathematical models, which are far from being trivial, start to be developed.

    Of course, there are many MM-algorithms with different owners on the market. There are large owners (big banks), who also have insider knowledge - they know which traders (because they are their clients) where they stand and how they traded. That's why the mathematical models are well thought out. But the task is always the same - to squeeze as much money as possible out of the meat (ordinary market participants).

    I.e. you understand that even you can be a market maker, you just need a good MM-algorithm and solution of some organisational issues.

     

    Square-forming stock exchange algorithm

    It seems to have become clear that everything in our automated times is held together by algorithms. There are many types of them. Let's try to consider a purely technical algorithm for creating a trading platform. The simplest algorithm of this type is the stock exchange algorithm. We will talk about it.

    So, there is some symbol that will be traded only on our exchange. And there are many people willing to trade it. This means that there are ready-made MM-algorithms and meat, without which everything is meaningless (profitless).

    A stock exchange algorithm is purely technical, i.e. it brings profit to its owner by the fact that its results are used by everyone paying a commission. In this case, even a negative commission can be invested in the algorithm, for example, for MM-algorithms. The commission grid is again some uncomplicated mathematical model.

    So, there is Level2 (FOREX terminology, in exchanges it is also called MarketDepth) - these are levels: buy/sell price and how much (volume). Each such level (price + volume) is called a gang. The best bands for selling and buying are called Bid and Ask (some people call them Offer, but this is just terminology).

    Level2 is formed from client orders(limiters) - these are both MM algorithms + some other types of algorithms and meat. Spread is the difference between the current Ask and Bid (in particular, for this reason there is a very inaccurate phrase that MMs make money on the spread).

    Any limit stock algorithm almost always puts a limit on the corresponding Bid in the stack. It is for this reason, putting the limiters inside the spread there is a corresponding narrowing of the spread. I will not explain it on my fingers, the algorithm is simple (you can google it or ask).

    If the limit is set worse than the current corresponding price (for example, SellLimit <= Bid), then the exchange execution algorithm does not execute at a price worse than the market price, but starts licking (by volume) the bands from the best to the worsening side, until the whole limit is filled, or until the bands run out to the level at which this limit is set.

    Of course, there are sometimes extra-regular moments in stock exchange algorithms, when information about your bid, before getting into the stack, goes, for example, to the MM-algorithm. And it acts in advance (ahead of time) in a simple way so that you do not get a positive slippage from the limiter at a price worse than the current one, but take it away as a net profit. This is some tech. insider, which, of course, is bought, i.e. has quite a clear price tag (money rules). Let's not forget the main task of any algorithm - money. Therefore, there should be nothing surprising here - the truth of life.

    On stock exchanges during a trading session, a pre-arranged limit order is executed in 99% of cases exactly at the price - without slippage. This means that in order for the price to cross your limit, it must be executed.

    Limiters in Level2 are covered by market orders. There are plenty of order types, as the exchange wants (prescribes). It is an algorithm. For example, MT5 has its own types of orders, which the exchange could well legalise - implement in its exchange algorithm of execution. A market order is a derivative of a limit order: a limit order at a price that is worse than the current one, and this worse price is almost unmeasurable. You will get as much as you need to execute with a market order, but only with a good negative slippage. The main users of market orders are meat.

    It is obvious that the price can move along almost any trajectory without making deals - look at MM-algorithms. If a deal is made, its price and volume is called Last. And this information is also broadcasted by the exchange. The flow of Last-data is called T&S(Time & Sales ed.).

    Some exchanges (not all of them) add to the Last-data a conditional flag - the direction of the transaction (Buy or Sell). This marker is a kind of classifier: on passive and active participants. I.e. on those whose limit has been fulfilled and those who have filled it. Obviously, this classifier is a time filter: whose execution of the two sides of the transaction was initiated by a later/earlier trade order.

    It is clear that the exchange algorithm is obliged to be sequential - i.e. a queue of orders is formed and they are sequentially processed. But there are variants of the so-called snapshots, when orders are accumulated for some relatively short time and then issued at once in level2 with the corresponding execution.

     

    Execution of limit orders on the exchange

    A correct exchange algorithm does not allow public Bid >= Ask situations in pricing. In the algorithm itself, as bids are received, a stack is formed at the initial stage, in which Bid >= Ask situations often occur. In such a situation, the executive part of the exchange algorithm is switched on, the task of which is to break this situation to the state Ask > Bid. And only after the destruction the already formed bet with correspondingly formed Last-data becomes public - available to everyone.

    SellLimit is always executed at Bid price, BuyLimit is executed at Ask.
    But only these Bid and Ask are non-public prices of the stack formed at the initial stage, as described above.

    If you put SellLimit - it is a desire by you to sell, which equals an offer for others to buy from you. For this reason SellLimit falls into Ask gangs. For example, if you put SellLimit inside the spread, the best Ask band is formed with the level and volume of your Limit. I.e. by putting SellLimit inside the spread, you change the Ask price. If someone wants to buy at Ask-price, he will fill your Limit. Saying in such a case that SellLimit is executed at Ask-price or is executed without spread is a very vague wording. It is better to just understand the mechanism, like everywhere else.

    Here is an example of an execution. You have set SellLimit inside the spread, so Ask is equal to SellLimit. Now you set BuyLimit equal to Ask. In this situation (see the first paragraph) in the stock exchange algorithm it turns out that Bid is equal to BuyLimit. In other words, it turns out that Bid = Ask. That's it, the situation is being sorted out until Ask becomes greater than Bid. No one will see a correct bet until the algorithm does it. For simplicity, let SellLimit and BuyLimit volumes be equal to Vol. It turns out that both limiters collapse, Bid and Ask become equal to the next best bands in the stack, i.e. Ask > Bid. Next, Last-data contains the execution price, which is equal to your SellLimit (== BuyLimit), Vol volume and BUY direction (because BuyLimit was sent later than SellLimit).

    Note that if in the same situation you send BuyLimit first and then SellLimit, the result is the same - you buy/sell to yourself, losing on double commission. But only in Last-data the direction flag will be opposite - SELL.

    Returning to the question of the price at which limiters are executed:

    If you look at the bars of a shallow TF on some weakly liquid symbol, you will see that Bid bars are clipped at the bottom (BuyLimits) and Ask bars are clipped at the top (SellLimits).


    Let's consider the SellLimit situation again. In the bar tester, SellLimit will be executed only when its HighBid >= SellLimit. Note that HighBid (as well as LowAsk) is practically not cut on exchanges. And looking ahead - they are not trimmed at all on ECN/STP. I.e. if you need to test a strategy with limiters, the main information for you on SellLimit execution is the value of Bid-price, or rather its High. This can be another argument in favour of the statement that SellLimit is executed exactly at Bid-price.

    Digressing a bit, we can say that ZigZags with tops on Bid-data and lows on Ask-data are constructed for the same reasons. And it is on the basis of such construction that the maximum potential profitability is estimated.


    P.S. I have not made a single transaction on the exchanges. Simply, the algorithm of exchange platform formation is a very special case of more complex platform-forming algorithms - decentralised markets (darkpools). I will write about it only when everything will be clear about exchanges.
     

    Execution of Limit Orders in Futures and Forex

    Sell Limit order. Forex.

    This order on the Forex market is always executed at the Bid price and is placed abovethe current market ask price (in our example 1.4990).

    You decide to sell the Euro when its price is 1.5000. You click on the Sell Limit button, set the number of lots, for example, 10, and specify the price at which you would like to sell - 1.5000 and thus tell the broker - "Dear broker, when the euro price will be 1.5000 I want to sell 10 lots of euros". OK, says the broker, I understand, I will send your order to the banker and if he decides to buy at that price, I think he will do it right.

    The moment comes when the banker announces that he is ready to buy the euro at 1.5000. Our broker reminds the banker about your order, the banker tells him - no problem, but before you, I was sent orders that they want to sell euros at 1.5000, so I am now only ready to buy 20 lots, and I have 25 orders. 20 were sent before you and 10 came from you, so darling, as a decent banker I will buy those 20 and your 5 first. Since the banker was able to buy only 5 of your lots of euros, the broker had nothing to do but to buy only 5.

    That is, you set your Sell Limit order at the price of 1.5000, and when the Bid price came to this price, you were able to buy only 5 lots at this price, but exactly at the price you specified in the order. This is the basis of the fundamentals of this order. The quantity may not be enough, but the price is strictly the price specified in the order. That is 1,5000.


    Sell Limit order. Futures.

    This order at the exchange is always executed at the Last price and is placed above the current market bid price (in our example 1.5033). In practice, it is best to focus on the Last price on futures and practically place the order above the Last price.

    Be careful. This is the fundamental difference between order execution on the stock exchange and the forex market. Never forget that on the forex market you see charts that are drawn at the Bid price, on the stock exchange the chart is always drawn at the Last price.

    You decide to sell a Euro futures contract when its price will be 1.5039, you click on the Sell Limit button, set the number of contracts, for example 10, and specify the price at which you would like to sell - 1.5039 and thus tell the broker - "Dear broker, when the Euro price will be 1.5039 I want to sell 10 Euro futures contracts". OK, says the broker, send the order and you will see that it will be displayed in the exchange stack. You press the Send button and you will see that your order has hit the exchange and at the price of 1.5039 the number of orders should be changed from 80 to 90 (in the example).


    The moment came when the price of Last came to the price of 1.5039. If we say that the Last price came, it means that at this price, at least one deal was concluded, at least for 1 contract out of 90.

    And since a deal was made, the invisible fun at 1.5039 begins at this price level. The sellers want to sell 90 contracts. You have 10 to sell, you're last in line, based on our example. If there will be buyers for 90 contracts or more, then your order will be fully executed.

    What are the options here.
    Situation one.

    There were only 80 contracts of buyers, so all orders except yours will be executed and the Last price will return to the price of 1.5038. That is, you will see that the price seemed to be at the level of your order, but it did not work. It happens.

    Thesecond situation.

    There were only 85 contracts of buyers, so they will fulfil all orders and 5 contracts from yours and the price of Last will return to the price of 1.5038. That is, you will see that the price seemed to be at the level of your order, but only 5 contracts were triggered, but strictly at the price of 1.5039. And it happens.

    Thethird situation.

    Buyers had only 100 contracts, so they will fulfil all orders for 90 contracts, the price will rise to the level of 1.5040, then sellers will sell 10 more contracts and the price will return to the level of 1.5039.

    You should always be aware that if the Last price is even a tick above the price you specified in your Limit Order, your order must be executed in full and at the price specified in it.

    Let's assume that in our example there were more buyers than sellers. That is, you set your Sell Limit Order at the price of 1.5039, and when the price of Last came to this price, you were executed all 10 contracts exactly at the price of 1.5039. There can be no other variants with the price, only variants with the number of contracts.