Libraries: Lot-SL propotion

 

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

 
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)?
 
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.
 

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.

 
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 ?

 
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...

 

 
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.

 
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. 

 

Thet is better?

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