molanis.com/forum - Tools for MetaTrader : The place to ask about the best expert advisor builder, expert advisor downloads, and expert advisor programming

AFTER YOU REGISTER SEND US AN EMAIL TO ACTIVATE YOUR ACCOUNT - Before posting:-1- Please read the user guide -2- Try the examples -3- Search in the forum
It is currently Fri May 17, 2024 11:38 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: EA Giving Margin Error when Margin is Adequate
PostPosted: Mon Jan 07, 2013 11:53 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Hi,

Am testing an EA in trading mode on demo MT4. Once condition is met instead of trade opening I get this message from Experts tab

2013.01.08 15:15:04 GBPUSD,M15: M-NOT ENOUGH MONEY TO TRADE. Free margin is insufficient to trade a lot size of 0. Current Free Margin=3182.45
2013.01.08 15:15:04 GBPUSD,M15: invalid lots amount for FreeMarginCheck function
2013.01.08 15:15:04 GBPUSD,M15: invalid lots amount for FreeMarginCheck function

The EA settings are as follows

UseMaximumPercentageRisk = true
MaximumPercentageatRisk = 1.0
UseRiskRatio = false
UseLotManagement = true
LotManagementType = 2

Balance and margin are fine. Please advise why EA won't open with adequate lot size.

Thank You


Top
 Profile  
 
 Post subject: Re: EA Giving Margin Error when Margin is Adequate
PostPosted: Tue Jan 08, 2013 8:39 pm 
Offline
Site Admin

Joined: Fri Oct 16, 2009 3:40 pm
Posts: 451
Maybe there is something wrong on your settings since it says
Quote:
... lot size of 0...

You need to set the lot size in the buy/sell icon

If you still have issues, post your .mol file to see the strategy settings


Top
 Profile  
 
 Post subject: Re: EA Giving Margin Error when Margin is Adequate
PostPosted: Wed Jan 09, 2013 1:23 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Quote:
Maybe there is something wrong on your settings since it says

Quote:
... lot size of 0...ys


I looked at code, and lead me to check settings. My S_SYMBOL_LS_0 and B_SYMBOL_LS_0 were set to 0.0. I've set it to 1. However if I'm using useMaximumPercentageatRisk=true, should this not work out the lot size to trade with over these two parameters :?:


Top
 Profile  
 
 Post subject: Re: EA Giving Margin Error when Margin is Adequate
PostPosted: Wed Jan 09, 2013 3:49 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
Ok setting to 1 removed the error. now this happens

2013.01.10 06:15:01 EURUSD,M15: Alert: M-ERROR: Could not open new position. Error=130 invalid stops. Order Info : Order Type=OP_SELL. Symbol=EURUSD. Lot Size=0.03. Price=1.3059. SL=1.3099. TP=1.3019

I've opened the trade manually with the TP and SL at price 1.30595 without any issues. why EA failed to open :?:

Also is it possible to load a comment when trade is opened by EA that user can tailor :?:


Top
 Profile  
 
 Post subject: Re: EA Giving Margin Error when Margin is Adequate
PostPosted: Wed Jan 09, 2013 10:11 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
If the stops have the adequate distance you may be using and ecn where the stops cannot be placed with the order. In the start icon you can set this up to send the order first and then the stops


Top
 Profile  
 
 Post subject: Re: EA Giving Margin Error when Margin is Adequate
PostPosted: Thu Jan 10, 2013 1:29 pm 
Offline

Joined: Mon Dec 26, 2011 5:41 am
Posts: 46
fixed now after making the change, and EA trading now. I at times get the odd message trading is not allowed. must be because of limits on trade total allowed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by Molanis © 2009