Watch how to download trading robots for free
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Scripts

FX Margin Calc - script for MetaTrader 4

TAT DAT NGUYEN
Published by:
Tat Dat Nguyen
Views:
1350
Rating:
votes: 15
Published:
2021.10.18 15:38
double get_FX_MarginCalc(string symbol)
{  //---
   string DepositCurrency = AccountInfoString(ACCOUNT_CURRENCY);
   string first    = StringSubstr(symbol,0,3); // the first symbol, for example,  EUR
   string second   = StringSubstr(symbol,3,3); // the second symbol, for example, USD
   double ccontract= SymbolInfoDouble(symbol,SYMBOL_TRADE_CONTRACT_SIZE);
   double bid      = SymbolInfoDouble(symbol,SYMBOL_BID); // Bid Price
   long leaverage  = AccountInfoInteger(ACCOUNT_LEVERAGE);

   if(first == DepositCurrency) return(ccontract/leaverage);      // USDxxx
   if(second == DepositCurrency) return(ccontract*bid/leaverage); // xxxUSD

// --- kiểm tra các loại tiền tệ chéo bình thường
// --- tìm kiếm chuyển đổi trực tiếp thông qua tiền gửi
   string cbase = DepositCurrency + first; // USDxxx
   if(SymbolInfoDouble(cbase,SYMBOL_BID) > 0) return(ccontract/SymbolInfoDouble(cbase,SYMBOL_BID)/leaverage);

//--- thử ngược lại
   cbase = first + DepositCurrency; // xxxUSD
   if(SymbolInfoDouble(cbase,SYMBOL_BID) > 0) return(ccontract*SymbolInfoDouble(cbase,SYMBOL_BID)/leaverage);

   return 0;
}
    CLOSE ALL BY ORDERTYPE CLOSE ALL BY ORDERTYPE

    Close All Order

    Chart Format Chart Format

    Định dạng chart

    TMA Moving Average TMA Moving Average

    Thuật toán đường trung bình trung tâm lượng giác

    Zigzag R Zigzag R

    An optimized version of the Zigzag indicator, which was included in the MT4 delivery of 2005 (and in MT3.83).