Here is what i use on my ea
Quote:
extern bool UseMM = True;
extern bool Micro = True;
extern double Lots = 0.01;
extern double Risk = 0.1;
extern double MinLots = 0.01;
extern double MaxLots = 100.0;
//+------------------------------------------------------------------+
//| calculate optimal lot size |
//+------------------------------------------------------------------+
double LotsOptimized()
{
//----
double lot = Lots;
int orders = HistoryTotal(); // history orders total
int losses = 0; // number of losses orders without a break
if(UseMM){
if(!Micro){
lot = NormalizeDouble((Risk*AccountFreeMargin())/1000,1);
if(lot>MaxLots){lot=MaxLots;}
else if(lot<MinLots){lot=MinLots;}
}
else{
lot = NormalizeDouble((Risk*AccountFreeMargin())/1000,2);
if(lot>MaxLots){lot=MaxLots;}
else if(lot<MinLots){lot=MinLots;}
}
return(lot);
}
else{
return(Lots);
}
}
|
here is some of others best of MM
Quote:
extern double Lots = 0.01;
extern double DecreaseFactor = 0.3;
extern int Leverage = 200;
double LotsOptimized()
{
double lot=Lots;
int orders=HistoryTotal(); // history orders total
int losses=0; // number of losses orders without a break
//---- select lot size
lot=NormalizeDouble(Risk*AccountFreeMargin()* AccountLeverage()/100000.0,1);
//---- calcuulate number of losses orders without a break
if(DecreaseFactor>0)
{
for(int i=orders-1;i>=0;i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==fals e)
{ Print("Error in history!"); break; }
if(OrderSymbol()!=Symbol() || OrderType()>OP_SELL) continue;
//----
if(OrderProfit()>0) break;
if(OrderProfit()<0) losses++;
}
if(losses>1) lot=NormalizeDouble(lot+lot*losses*DecreaseFactor, 1);
}
//---- return lot size
if(lot<0.01) lot=0.01;
return(lot);
}
|
Can someone suggest to me how to combine both coding into one ...?
your help, hope me win on my eas...
1st order open sell/buy loss,
then
2nd open order sell/buy increase double (2x) from previous lots...to cover loss from 1st order... hope it may win...
main things is i want to recover every losses i made by increasing the lot after each losses...
thank you...
regards,
MANSTIR