Ok merci nick, je vais essayer ça.
Voila pour le moment ce que j'ai fait:
Code : Tout sélectionner
double LotSize()
{
double lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000;
if(AccountIsMicro==false) //normal account
{
if (lotMM < 0.1) lotMM = Lots;
if (lotMM > 1000) lotMM = 1000;
}
else //micro account
{
if (lotMM < 0.01) lotMM = Lots;
if (lotMM > 1000) lotMM = 1000;
}
if (OrderSelect (1, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0)
{if (OrderSelect (2, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() < 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000 * 1.5;
if (OrderProfit() > 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000 * 1.5 * 1.5;}
if (OrderSelect (2, SELECT_BY_POS, MODE_HISTORY)==false) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000 * 1.5;
if (OrderSelect (3, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000 * 1.5*1.5*1.5;
if (OrderProfit() < 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000 * 1.5*1.5;}
if (OrderSelect (4, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0)
{if (OrderSelect (3, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0)
{if (OrderSelect (2, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0)
{if (OrderSelect (1, SELECT_BY_POS, MODE_HISTORY)==true)
{if (OrderProfit() > 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000;}}}}}}}
if (OrderProfit() < 0) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000;
if (OrderSelect (1, SELECT_BY_POS, MODE_HISTORY)==false) lotMM = MathCeil(AccountFreeMargin() * Risk) / 1000000;
}}
return (lotMM);
}
C'est très long et je suppose qu'il existe 1000 façon de le simplifier et de le raccourcir.
En plus pour le moment ça marche mal.