Download MetaTrader 5

Libraries: Lot-SL propotion

To add comments, please log in or register
All activity at MQL5.community is clearly visible. Have a look at the Wall!
Automated-Trading
Admin
99081
Automated-Trading 2015.12.11 11:12 

Lot-SL propotion:

The function returns the lot size, which is calculated based on the stop loss size and the risk specified in the variable.

Author: Vasyl Nosal

Goldmember
11
Goldmember 2015.12.15 09:10  
Automated-Trading:

Lot-SL propotion:

Author: Vasyl Nosal

Hi, can you add an option for SL in points to be calculated as ADR(x) of y where x is number of intervals and y is a timeframe (D1, H4, H1 or M15)?
Siti Latifah
6445
Siti Latifah 2015.12.15 11:52  
Automated-Trading:

Lot-SL propotion:

Author: Vasyl Nosal

you can try this


https://www.mql5.com/en/code/13593

Auto MM
Auto MM
  • votes: 12
  • 2015.08.06
  • Siti Latifah
  • www.mql5.com
This script will help you calculate your lot to open position.
Alain Verleyen
Moderator
30640
Alain Verleyen 2016.03.10 19:16  

The function returns the lot size, which is calculated based on the stop loss size and the risk specified in the variable.

I don't know what this code is calculating but that's not the correct lot size. You should test your code before publishing it.

Alain Verleyen
Moderator
30640
Alain Verleyen 2016.03.10 19:24  
Siti Latifah:

you can try this


https://www.mql5.com/en/code/13593

By the way this one isn't better

Did you bother to test your code guys ?

Vasyl Nosal
18533
Vasyl Nosal 2016.03.11 00:32  
Alain Verleyen:

I don't know what this code is calculating but that's not the correct lot size. You should test your code before publishing it.

Where are arguments?

Becouse I have

 

 

Balance 1000 euro AUDCAD

 risk=10%

 SL=504 points 

 

resoult of function is 0.280375...

 

Alain Verleyen
Moderator
30640
Alain Verleyen 2016.03.11 17:32  
Vasyl Nosal:

Where are arguments?

Becouse I have

 

 

Balance 1000 euro AUDCAD

 risk=10%

 SL=504 points 

 

resoult of function is 0.280375...

 

Lucky. Try it on GOLD (XAGUSD) or other broker with different minimum lot size.

   double lose_on_stop_lose=SL_Vasyl*(MarketInfo(Symbol(),MODE_TICKVALUE)/100);
   double propotion=(balance/100*Lot_sl_risk)/lose_on_stop_lose;
   double Loto_=MarketInfo(Symbol(),MODE_MINLOT)*propotion;

It works only when minimum lot is 0.01. Minimum lot size has nothing to do with this calculation.

It works only when a point = a tick. It's not the case for a lot of symbols.

Vasyl Nosal
18533
Vasyl Nosal 2016.03.11 20:59  
Alain Verleyen:

Lucky. Try it on GOLD (XAGUSD) or other broker with different minimum lot size.

It works only when minimum lot is 0.01. Minimum lot size has nothing to do with this calculation.

It works only when a point = a tick. It's not the case for a lot of symbols.

I have 0.01 min lot in gold too.

Name broker where I can test. 

Vasyl Nosal
18533
Vasyl Nosal 2016.03.11 21:09  

Thet is better?

double lose_on_stop_lose=SL*(MarketInfo(Symbol(),MODE_TICKVALUE)/(1/MarketInfo(Symbol(),MODE_MINLOT))); 

To add comments, please log in or register