Entering Trade with Minimum Margin Level

To add comments, please log in or register
Olufemi Odunuga
46
Olufemi Odunuga  

I am trying to include margin Level as one of the conditions used for entry a trade in MT4. i created an external parameter MinAllowedMarginlevel where users could input the desired value. i do not want the EA to open trade except if this condition is met. When I tested the EA on back tester, it didn't open any trade. However, when i removed the condition, EA works correctly. Please help check the attached code if there is anything i have done wrong. 

extern double MinAllowedMarginLevel = 650;//  Minimum allowed margin level to open trade (650%)
double AccountMarginLevel;

int start() {
AccountMarginLevel = AccountEquity()/AccountMargin()* 100.0;

/////////////////////////////////////////////////////////////////////////////
//Condition to open trade

if (TradeNow && total < 1 && AccountMarginLevel > MinAllowedMarginLevel) {
// open trade provided other conditions are met

Thanks 

whroeder1
17943
whroeder1  
Use the debugger or print out your variables, including _LastError and find out why.
Olufemi Odunuga
46
Olufemi Odunuga  
whroeder1:
Use the debugger or print out your variables, including _LastError and find out why.


Thanks whroeder1,

I just wanted to know if there is anything wrong with the code .

 This is the error i got:


2018.06.10 19:23:41.181 TestGenerator: unmatched data error (volume limit 479 at 2017.10.12 23:00 exceeded)

2018.06.10 19:24:01.049 EURUSD,M30: 1 tick events (17954 bars, 39909227 bar states) processed in 0:00:00.485 (total time 0:00:49.594)
2018.06.10 19:24:01.049 2016.11.22 08:30:00  Testing pass stopped due to a critical error in the EA

To add comments, please log in or register