No Money!!!

 

Hello. I have this EA that selects the position size dynamically. Problem is, the EA has no margin calculation. 

I have searched all over the internet, even on the forum, but cannot seem to find a comprehensive answer. Some without answers at all!!!

Please, try to answer this question as comprehensively as possible, not just for me, but for anyone else that might get here.

Say I have an account in USD with $500 capital and 1:500 leverage. If I need to open a position of 0.8 lots. How do I calculate in my EA if that volume can be traded without receiving the "no money error"?

How to I detect the no money error and print it on my log before calling ExpertRemove

A sample code will work just fine for me.

Please?

 
Nelson Wanyama:

Hello. I have this EA that selects the position size dynamically. Problem is, the EA has no margin calculation. 

I have searched all over the internet, even on the forum, but cannot seem to find a comprehensive answer. Some without answers at all!!!

Please, try to answer this question as comprehensively as possible, not just for me, but for anyone else that might get here.

Say I have an account in USD with $500 capital and 1:500 leverage. If I need to open a position of 0.8 lots. How do I calculate in my EA if that volume can be traded without receiving the "no money error"?

How to I detect the no money error and print it on my log before calling ExpertRemove

A sample code will work just fine for me.

Please?

OrderCalcMargin


 
Amir Yacoby:
OrderCalcMargin


Whuoaah! That was brief. Let me try it out.