Главная
Каталог статей
English instructions and articles

Для того, чтобы использовать все возможности сайта, мы рекомендуем Вам person_add Зарегистрироваться или person Войти

starРейтинг: 5.0/1

date_range Posted: 27.10.2013

date_range Updated: 27.10.2020

remove_red_eyeReviews: 40

dashboardCategory: English instructions and articles

cloudsecrets, DynamicLot, Autolot, My, of


Read about Secrets of my Autolot DynamicLot Autolot

Description

Within the framework of this article, I will try to tell you about my methods of calculating the lot from% (RISK) of Free Margin, on different currency pairs and different types of deposit

And so let's start:
 

Basic concepts:

   First, let's highlight a few concepts used in this calculation:

   Free margin  ( AccountFreeMargin () ) - funds that are not used as collateral in open positions. Free margin is calculated using the formula: free margin = current state of the deposit - required margin in open positions. This indicator is used to determine the number of deals that can be opened at the moment.

 

   Ask  is the price at which you buy a certain amount of a financial instrument from a bank. And the bank, accordingly, sells it to you at this price. When trading on the Forex market, you will see this type of price everywhere: from a trading terminal to stock exchange reports and analytical articles on financial markets. 

 

   Bid  is the price at which you sell a certain amount of a financial instrument to your bank. And the bank, accordingly, buys it from you at this price. When trading on the Forex market, you will encounter this type of price wherever it comes to the international foreign exchange market Forex: from the trading terminal and exchange rates on your broker's website, to stock reports and analytical articles on international financial markets. 

   Leverage  is the ratio of the collateral amount to the borrowed amount. At the initial choice of leverage, the size of the leverage is selected, which indicates the amount by how many times the Client's deposit will be increased to carry out trading operations in the foreign exchange market. The client can choose the leverage from 1: 1 to 1: 500, that is, the Client can trade only with his own funds, or he can request an increase in his deposit up to 500 times in order to enter the market with this amount. Leverage, as the ratio of the amount with which a trader enters the market to the size of his deposit, plays an important role in the trading process, since it is leverage that allows a trader to significantly increase his capital.

   A currency pair  is a designation of two currencies that together form a currency rate. The currency pair serves as an object for carrying out financial transactions. A currency pair is denoted in the form of consecutive symbols of the two currencies that make up this currency pair, which are written either together or through a slash in the following form: base currency / quote currency. The base currency is the first currency that is bought and sold, and the quote currency is used to express the price of the base currency. A currency pair is a basic concept of the foreign exchange market that is found everywhere when it comes to a given market: from a market summary to a trading terminal.

   Lot size  - the volume of the base currency, commodity or the number of shares specified in the contract specification. The lot size depends on the amount of currency specified in the contract and is a unit of measurement in determining the size of a trading contract. The lot has a certain size, which is used to determine the amount of currency in which financial transactions are performed on the Forex market. To carry out a transaction, the Client determines the size of the transaction he makes, which is expressed in the number of lots. The volume of a trade indicates how much currency will make up a trade. A lot is a contract size, which is a fixed amount of the currency used in Forex trading.

 

    The exchange rate of one currency in relation to another is established as a result of the interaction of supply and demand for them at a certain point in time. The process of setting the exchange rate is called currency quotes. Quotes can be direct or inverse.
 
   Under the direct quotation refers to the expression of the foreign currency prices in national units. Most exchange rates are direct quotes of the US dollar against the currencies of various countries. For instance:
USD / RUR - 30, 70 - this means that one US dollar is valued or equal to 30, 70 Russian rubles;
USD / CHF - 1.0850 - in this case, one US dollar is valued at or equal to 1.0850 Swiss francs.
 
   A reverse quote is an expression of the value of a national currency in foreign units. Historically reversed quotations have been for the British pound sterling, the euro, the Australian and New Zealand dollars. For example, a quote - EUR / USD - 1.3374 means that 1 euro is worth 1.3374 US dollars, GBP / USD - 1.5970, which means that 1 British pound is equal to 1.5970 US dollars, etc.
 
     There is also such a thing as "to the Russian rate " - these are exchange rates in which the dollar is neither the base nor the quote currency, for example, EUR / JPY, GBP / CHF, EUR / GBP and others.

 

 The technical side

  1. NormalizeDouble -  Rounds a floating point number to the specified precision.
  2. MODE_LOTSIZE -  Contract size in the base currency of the instrument
  3. MODE_LOTSTEP -  Step for changing the lot size 
  4. AccountCurrency -  Returns the name of the currency for the current account. 
  5. MathFloor   - The function returns a numeric value representing the largest integer less than or equal to x. 


Important: In order for all calculations to be correct - activate all symbols in the "Market Watch " panel  $ IMAGE2 $

My calculation formula

   My calculation formula looks like this: 

Deposit USD 

USD Deposit Direct Quote ()

 Lot = Free Margin * Risk * Leverage / 100 / Contract Size

Deposit USD Reverse Quote ()

 Lot = Free Margin * Risk * Leverage / Ask / 100 / Contract Size

Deposit USD Cross rate :()

       Option 1 , if there is a current price of the base currency + USD (for example, if the settlement pair is AUDCAD, then the current price of the base currency = AUDUSD)

          Lot = Free Margin * Risk * Leverage / ( current base currency price + USD ) / 100 / Contract size

 

       Option 2 , if there is no current price of the base currency + USD (for example CADJPY)

          Lot = Free Margin * Risk * Leverage / 100 / Contract Size

Deposit EUR

 

Deposit EUR Direct quote

 Lot = Free Margin * Risk * Leverage / 100 / Contract Size

Deposit  EUR  Cross rate:

       current price  EUR +  quote currency (for example, if the settlement pair is AUDCAD, then the current price is the  quote currency  = EURAUD)   

          Lot = Free margin * Risk * Leverage / ( current EUR  price  quote currency ) / 100 / Contract size

 

 

RUR deposit

 

Deposit RUR Reverse quote (for example USDRUR)

 Lot =  MathFloor ( Free margin * Risk * Leverage / 100 / Current price / Contract size / Lot step / 20) * Lot step

Deposit RUR Cross (e.g. EURGBP)

 

  current price  = MarketInfo (StringSubstr (Symbol (), 0,3) + "RUR" + StringSubstr (Symbol (), 6), MODE_BID);     

if (pr! = 0) Lot2 = MathFloor ( Free margin  * Risk  * Leverage  / current price  / 100 / Contract size  / Lot step  ) * Lot step  ; 

else  Lot  = MathFloor ( Free margin  * Risk  * Leverage  / 100 / Contract size  / Lot step  ) * Lot step  ; 

 

The order of these functions was obtained in the course of calculating parameters on different deposits. If YOU have any opinion on these calculations, please offer your autolot functions when ordering programming

 

 

 

Autolot calculation function:

External variables Autolot calculation function::

Lots Fixed lot for opening a position. 
DynamicLot Dynamic lot, Auto lot for the position to be opened. 
Enable dynamic lot calculation as a percentage of free margin and other factors. 
Calculation of our autolot.
LotBalancePcnt Percentage for autolot
RiskRate RiskRate - the rate of your currency against the dollar. 
By default, RiskRate = 0 means that the EA will try to find the correct rate in the Market Watch. 
In order for the autolot to work adequately with all currency pairs, you need to enable "Show all currency pairs" in the Market Watch.
MaxLot The maximum lot that the advisor can open when calculating the autolot and martingale for the first main position 
Martin  Standard lot multiplication of the last closed position at a loss.
If  Martin = 1,  then martingale is not enabled. 
If  Martin = 0,  then the EA will not be able to open the next position 
If  Martin = 2,  then the first lot = 0.1, the second lot = 0.2, and so on, 0.4 - 0.8 - 1.6
If  Martin = 0.5,  then the first lot = 1, the second lot = 0.5, and so on, 0.25 - 0.125

Need a code? 

Function of DynamicLot:

 

double GetSizeLot (double ll = 1) // The function returns the value of lots, 
  { 
   string Autor = "The author of the function for the template: www.expforex.com"; 
   string lotcalc; 
   double pr; 
   string Valdepo = AccountCurrency (); 
// if MM is enabled, then the lot value, 
   double Lot2, MinLots, MaxLots; 
   int lotdig; 
   if (MarketInfo (Symbol (), MODE_LOTSTEP) == 0.01) lotdig = 2; else lotdig = 1; 
   if (Valdepo == "USD") 
     { 
      if (StringSubstr (Symbol (), 0,3) == "USD") Lot2 = NormalizeDouble (AccountFreeMargin () * LotBalancePcnt * 
         AccountLeverage () / 100 / MarketInfo (Symbol (), MODE_LOTSIZE), lotdig);
      else if(StringSubstr(Symbol(),3,3)=="USD")Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*
         AccountLeverage()/Ask/100/MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
      else
        {
         pr=MarketInfo(StringSubstr(Symbol(),0,3)+"USD",MODE_ASK);
         if(pr!=0)Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*AccountLeverage()/pr/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
         else Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*AccountLeverage()/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
        }
     }
   if(Valdepo=="EUR")
     {
      if(StringSubstr(Symbol(),0,3)=="EUR")Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*
         AccountLeverage()/100/MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
      else
        {
         pr=MarketInfo("EUR"+StringSubstr(Symbol(),0,3),MODE_BID);
         if(pr!=0)Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*AccountLeverage()*pr/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
         else Lot2=NormalizeDouble(AccountFreeMargin()*LotBalancePcnt*AccountLeverage()/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
        }
     }

   if(Valdepo=="RUR" || Valdepo=="RUB")
     {
      if(StringSubstr(Symbol(),0,3)=="USD")Lot2=NormalizeDouble(AccountFreeMargin()/40*
         LotBalancePcnt*AccountLeverage()/100/MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
      else if(StringSubstr(Symbol(),3,3)=="USD")Lot2=NormalizeDouble(AccountFreeMargin()/40*
         LotBalancePcnt*AccountLeverage()/Ask/100/MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
      else
        {
         pr=MarketInfo(StringSubstr(Symbol(),0,3)+"USD",MODE_ASK);
         if(pr!=0)Lot2=NormalizeDouble(AccountFreeMargin()/40*LotBalancePcnt*AccountLeverage()/pr/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
         else Lot2=NormalizeDouble(AccountFreeMargin()/40*LotBalancePcnt*AccountLeverage()/100/
            MarketInfo(Symbol(),MODE_LOTSIZE),lotdig);
        }
     }

   MinLots=MarketInfo(Symbol(),MODE_MINLOT);
   MaxLots=MaxLot;
   lotcalc=" Autolot="+Lot2;
   if(!DynamicLot)Lot2=Lots;

   if(Lot2 < MinLots) Lot2 = MinLots;
   if(Lot2 > MaxLots) Lot2 = MaxLots;
   lotcalc=lotcalc+" MinLots="+MinLots+" LOT="+NormalizeDouble(Lot2,lotdig);
   Print(lotcalc);
   return(NormalizeDouble(Lot2,lotdig));
  }

 

Function for calculating autolot by stop loss :

If you want to add an autolot stop loss function to your Expert Advisor, you can download our code:

StopLosssd = stop loss in points

 

External variables:

extern double Lots = 0.1; // Fixed lot 
extern double LotBalancePcnt = 20; //% of the deposit if LotBalancePcnt == 0 lot is used
 

Function:

 

double GetSizeLotStopLoss (double StopLosssd = 1) // The function returns the value of lots, 
 { 
 string Autor = "The author of the function for the template: www.expforex.com"; 
 string Valdepo = AccountCurrency (); 
// if MM is enabled, then the lot value, 
 double MinLots; 
 int lotdig; 
 if (MarketInfo (Symbol (), MODE_LOTSTEP) == 0.01) lotdig = 2; else lotdig = 1; 
 double Free = AccountFreeMargin (); 
 double LotVal = MarketInfo (Symbol (), MODE_TICKVALUE); // cost of 1 pip for 1 lot 
 double Min_Lot = MarketInfo (Symbol (), MODE_MINLOT); 
 double Max_Lot = MarketInfo (Symbol (), MODE_MAXLOT); 
 double Step = MarketInfo (Symbol (), MODE_LOTSTEP); 
 double Lot = MathFloor ((Free * LotBalancePcnt/100)/(StopLosssd*LotVal)/Step)*Step;
 MinLots=MarketInfo(Symbol(),MODE_MINLOT);

 if(Lot<MinLots) Lot=MinLots;

 return(NormalizeDouble(Lot,lotdig));
 }

Ссылки по материалу:

translateРусская инструкция

Secrets of my Autolot DynamicLot Autolot_1
Здесь можно скачать Secrets of my Autolot DynamicLot Autolot
Купить Secrets of my Autolot DynamicLot Autolot можно здесь - Прочитать о Secrets of my Autolot DynamicLot Autolot можно здесь - Обсуждение Secrets of my Autolot DynamicLot Autolot - стейты, отзывы, комментарии - Отзывы о Secrets of my Autolot DynamicLot Autolot - Настройки к Secrets of my Autolot DynamicLot Autolot - Мониторинг Secrets of my Autolot DynamicLot Autolot - Download Secrets of my Autolot DynamicLot Autolot - Buy Secrets of my Autolot DynamicLot Autolot - Read about Secrets of my Autolot DynamicLot Autolot - Discusion of Secrets of my Autolot DynamicLot Autolot - Comments of Secrets of my Autolot DynamicLot Autolot - Settings Secrets of my Autolot DynamicLot Autolot - Monitoring Secrets of my Autolot DynamicLot Autolot - Secrets of my Autolot DynamicLot Autolot скачать бесплатно - Secrets of my Autolot DynamicLot Autolot ключ - Secrets of my Autolot DynamicLot Autolot открытый код - Secrets of my Autolot DynamicLot Autolot скачать
-
Expforex Expforex Идеи для Форекс https://www.expforex.com/1NEWDESIGN/NEWLOGO/LOGONEW.png expforex@meta.ua Украина expforex2
Читать Secrets of my Autolot DynamicLot Autolot
0 $ Есть в наличии

Within the framework of this article, I will try to tell you about my methods of calculating the lot from the% Free Margin, on different currency pairs and different types of deposit

English instructions and articles FinanceApplication Windows 27.10.2020
5 1