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 Mon May 20, 2024 8:28 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Auto Lot Size script/code
PostPosted: Wed Sep 03, 2014 3:49 pm 
Offline

Joined: Thu Aug 23, 2012 2:00 pm
Posts: 49
Hi guys...

Can anyone give me a script or hard code that will work with a Molanis MQL+ box that will automatically calculate the Lot Size based on my Free Margin, Risk % and Stop Loss (pips)....
ie.

extern double Risk = 0.01;
extern double SL = 20;
int start()
{
double lots = AccountFreeMargin()*Risk/SL/(MarketInfo(Symbol(), MODE_TICKVALUE));
lots = lots/10.0;

return(0);
}

Any help or guidance will be appreciated...

Thanx
PS: I've never used the MQL+ boxes before... :lol: can you believe it?


Top
 Profile  
 
 Post subject: Re: Auto Lot Size script/code
PostPosted: Thu Sep 04, 2014 8:14 pm 
Offline

Joined: Tue Dec 22, 2009 12:22 am
Posts: 1761
Unfortunately just putting the lot size logic in the mql icon is not enough. You need to add the trading condition and order execution as well which is too complex. Your best bet is to use a pro version and modify the lot size function.
When using the sl in the calculation you end up with lot sizes that are non standard and you need to round to bigger lot sizes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 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