mm not working

 

need help please

i have tried to add mm to my ea and also to increase the lots as it trade

but it does not do that can some one help me please

extern bool MM=true; //money management
extern double Risk=10; //risk in percentage
extern double Lots=0.06;
extern double Slippage = 3;

//In bars. How many bars to wait before entering a new position.
extern int RandomEntryPeriod = 100;
extern int StopLoss = 60;
extern int TakeProfit = 250;

extern int MaxPositions = 5;

the i use this to check the platform

double Poin=0;
// double MML=0;

int init()
{
//Checking for unconvetional Point digits number
if (Point == 0.00001) Poin = 0.0001; //5 digits
else if (Point == 0.001) Poin = 0.01; //3 digits
else Poin = Point; //Normal
Magic = Period()+1339005;
return(0);

}

this is my mm

// expert money management
if(MM){if(Risk<0.1||Risk>100){Comment("Invalid Risk Value.");return(0);}
else{Poin=MathFloor((AccountFreeMargin()*AccountLeverage()*Risk*Point*100)/(Ask*MarketInfo(Symbol(),MODE_LOTSIZE)*MarketInfo(Symbol(),MODE_MINLOT)))*MarketInfo(Symbol(),MODE_MINLOT);}}
if(MM==false){Poin=Lots;}


to place a trade

int result = OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,Ask-StopLoss*Poin,Ask+TakeProfit*Poin,"gimic",Magic,0,clOpenBuy);

if (result == -1)

int result = OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Bid+StopLoss*Poin,Bid-TakeProfit*Poin,"gimic",Magic,0,clOpenSell);
if (result == -1)
 

Please use this to post code . . . it makes it easier to read.

 
Why are you using Leverage in your calculation ? leverage governs you margin requirement, why are you using to calculate your position size . . . perhaps you can explain the thinking behind your position size calculation ?
 

all i tried to do is to work out the account balance and then place a trade % according to it

i am new to codeing

 

do you have a standard script that you use for your EA or is it different for each EA

 
delcor:

all i tried to do is to work out the account balance and then place a trade % according to it

i am new to codeing

Before you code anything you need to know what you are coding . . . . what are you trying to code ? can you write your equation in words ?
 

what i need to work out is how much i want to risk

so risk =%

if i want to risk 5% of my account. i want the EA to work out how much i can trade. if balance increase so must the size increase

 
delcor:

what i need to work out is how much i want to risk

so risk =%

if i want to risk 5% of my account. i want the EA to work out how much i can trade. if balance increase so must the size increase

Do you know where your stop loss is ?
 
yes
 
it is set at 60
 
delcor:
if i want to risk 5% of my account.
Contract Size - MQL4 forum