Scripts: Get min margin in to csv

 

Get min margin in to csv:

The script MinMargins.mq5 is designed to help traders quickly calculate and document the minimum amount of money required to open a position with the smallest lot size for all symbols available in the Market Watch. This data is saved to a CSV file for easy review and analysis.

Author: Kudakwashe Mafutah

 
Can you convert this script to an indicator? An indicator will be convenient than a script.
 
Thank you , It is something I found helpful . Possibly and issue with the JPY combinations? . Would be nice to capture the swap also
 
Wrong formula
 
FourSeasons #:
Can you convert this script to an indicator? An indicator will be convenient than a script.

Okay for now i make it show as comments while i wait for correct formula 

 
amrali #:
Wrong formula

please share appropriate formula and will be happy to update. both indicator and script

 
linfo2 #:
Thank you , It is something I found helpful . Possibly and issue with the JPY combinations? . Would be nice to capture the swap also

pleasae check with JPY i tried usally i dont trade JPY but I will try and try get the best fomular 

 
Kudakwashe Mafutah #:

please share appropriate formula and will be happy to update. both indicator and script

Formula for script and Expert Advisor:

      string symbolName = SymbolName(i, false);

      // Get the minimum margin for the symbol
      double minLotSize = SymbolInfoDouble(symbolName, SYMBOL_VOLUME_MIN);
      double price = SymbolInfoDouble(symbolName, SYMBOL_ASK);

      double margin = -1;
      bool res = OrderCalcMargin(ORDER_TYPE_BUY, symbolName, minLotSize, price, margin);

For indicators:

Becuase the OrderCalcMargin() function is prohibited in indicators, So you can use this OrderCalcMarginCustom() function, in the attachment.

      double margin = -1;
      bool res = OrderCalcMarginCustom(ORDER_TYPE_BUY, symbolName, minLotSize, price, margin);
Files: