Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

MQL4 Script to read the Margin and Spread for a Currency Pair
#1

Before you open a trade, you need to have the amount greater than the margin required for trading that currency pair. Below is  the MQL4 script that you can use to easily check the margin required for that currency pair and the spread for that currency pair:

Code:
//+------------------------------------------------------------------+
//|                                                       Margin.mq4 |
//|                                                     Ahmad Hassam |
//|                                       https://www.doubledoji.com |
//+------------------------------------------------------------------+
#property copyright "Ahmad Hassam"
#property link      "https://www.doubledoji.com"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   Print("Symbol=",Symbol());
   
   
   Print("Spread value in points=",MarketInfo(Symbol(),MODE_SPREAD));
   
   
   Print("Free margin required to open 1 lot for buying=",MarketInfo(Symbol(),MODE_MARGINREQUIRED));
   
  }
//+------------------------------------------------------------------+
As you can see above this is a simple MQL4 script that uses an inbuilt MQL4 function that checks the spread and another function that checks the margin required.

Subscribe My YouTube Channel:
https://www.youtube.com/channel/UCUE7VPo...F_BCoxFXIw

Join Our Million Dollar Trading Challenge:
https://www.doubledoji.com/million-dolla...challenge/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)