Experts: Lot sizing risk based and also converting the currency of the account

 

Lot sizing risk based and also converting the currency of the account:

Hi, so I just made a little code here that will help out a lot of coders that hate doing this (I count myself in it haha). It's made to calculate the lot size of a position based on the risk input and the account size+currency.

Author: Noe Combes Bardoll

 
ive dragged it onto a chart, and see nothing
 
topguntrader:
ive dragged it onto a chart, and see nothing
Its printing it in the experts section
 

Hi!

I like the sound of your script, so I thought I'd give it a go.

I've downloaded the file, compiled it & added it into the relevant 'scripts' folder on my MT4 account. When I attempt to add it to a chart, I get "'lot_sizing' is not script and cannot be executed". What am I doing wrong?

Thanks

 
66paulyg:

Hi!

I like the sound of your script, so I thought I'd give it a go.

I've downloaded the file, compiled it & added it into the relevant 'scripts' folder on my MT4 account. When I attempt to add it to a chart, I get "'lot_sizing' is not script and cannot be executed". What am I doing wrong?

Thanks

Sorry, I made it as a EA type before, I just modified the code, so try again download it and put it to the Scripts folder and run it again (Make sure its version 1.1)
 

Hi,

It is nice to know that I'm not the only one trying to do just that.

If you don't mind

void OnStart(){
   Alert(Lots(SL_pips,perc_to_loose)," Lot size for ",Symbol()," with ",SL_pips," SL pips and ",perc_to_loose,"% Risk ");
   
   Print("Lot size : ",Lots(30,perc_to_loose/100));
   Print("[SL] in pips : ",SL_pips);

When you call the function Lots(), it will always calculate for 30 pips.

Have you try TICKVALUE? I did and it cuts my code considerably. Mind-blown.

MarketInfo() Identifiers - Appendixes - MQL4 Tutorial
MarketInfo() Identifiers - Appendixes - MQL4 Tutorial
  • book.mql4.com
Query identifiers used in the MarketInfo() function can have the following values: Constant Value Description Order freeze level in points. If the execution price lies within...
 
torboxz:

Hi,

It is nice to know that I'm not the only one trying to do just that.

If you don't mind

When you call the function Lots(), it will always calculate for 30 pips.

Have you try TICKVALUE? I did and it cuts my code considerably. Mind-blown.

Just modify the '30' to 'SL_pips', Thats a little oversight that I missed.

void OnStart(){
   Alert(Lots(SL_pips,perc_to_loose)," Lot size for ",Symbol()," with ",SL_pips," SL pips and ",perc_to_loose,"% Risk ");
   
   Print("Lot size : ",Lots(SL_pips,perc_to_loose/100));
   Print("[SL] in pips : ",SL_pips);
But in the Alert it still shows the input from the user, so if you modify the pips to let's say 50, it will give you another result
Reason: