How to code EA to print margin utilized for symbol

 

Hi

I need help with coding in EA to 'print margin utilized for symbol' 

If I have EAs running on 3 different currency charts, the EA on each of those charts should only print the margin utilized by that chart symbol. 

Taking on new orders for that symbol would have EA on its chart to recalculate and print the new utilized margin.

Thank you

 
Amkaz2525:

Hi

I need help with coding in EA to 'print margin utilized for symbol' 

If I have EAs running on 3 different currency charts, the EA on each of those charts should only print the margin utilized by that chart symbol. 

Taking on new orders for that symbol would have EA on its chart to recalculate and print the new utilized margin.

Thank you

You can do this: let's say three positions open BUY 1.0 EURUSD, BUY 3.0 AUDUSD and SELL 1.0 USDJPY.

Once in three seconds you need to bypass all positions and for each symbol remember the used margin.

This option is suitable?

 

Thank you Vladimir,

I am looking at such a dashboard information display.


p("Equity / Balance: " + DoubleToString(AccountEquity(), 2) + " / " + DoubleToString(AccountBalance(), 2));

p("Margin / Free margin: " + DoubleToString(AccountMargin(), 2) + " / " + DoubleToString(AccountFreeMargin(),2));


Currently the Margin figure is showing a collective Account Margin (total Margin) for all different currency pairs on order. So, I see the same Margin status on EAs dashboard when I switch to any other currency pair.

How could this be coded to only show the margin of the respective currency?

Meaning, if I view EURUSD it should show the margin of only all EURUSD orders in trade. And if I switch over to GBPUSD, it will show only margin for GBPUSD trades.

Rgds

AMK

 
Amkaz2525 :

Thank you Vladimir,

I am looking at such a dashboard information display.


p("Equity / Balance: " + DoubleToString(AccountEquity(), 2) + " / " + DoubleToString(AccountBalance(), 2));

p("Margin / Free margin: " + DoubleToString(AccountMargin(), 2) + " / " + DoubleToString(AccountFreeMargin(),2));


Currently the Margin figure is showing a collective Account Margin (total Margin) for all different currency pairs on order. So, I see the same Margin status on EAs dashboard when I switch to any other currency pair.

How could this be coded to only show the margin of the respective currency?

Meaning, if I view EURUSD it should show the margin of only all EURUSD orders in trade. And if I switch over to GBPUSD, it will show only margin for GBPUSD trades.

Rgds

AMK

Please see the free product in the Market ***- column "Net Margin". If this column suits you - then I'll tell you how it is written.

 

Thank you Vladimir,


I had a look at it. Yes, this would be the Margin figure (Net margin) that needs to be reflected. I am still on MT4 with this EA for codes.

Appreciate your kind assistance.

 
Amkaz2525 :

Thank you Vladimir,


I had a look at it. Yes, this would be the Margin figure (Net margin) that needs to be reflected. I am still on MT4 with this EA for codes.

Appreciate your kind assistance.

I did not quite understand: Do you need MQL5 code or MQL4 code?

 
MQL4 my friend
 
Amkaz2525 :
MQL4 my friend

Unfortunately you took my time: You asked a question on the MQL5 forum, you asked the question in the MAIN SECTION MQL5 - so I answered you in MQL5.


All questions on MQL4 are discussed in a special section: MQL4 and MetaTrader 4 .

 

Yup..I realized much later after starting this topic that it was in MQL5. Sorry

Reason: