Hi, i please need a code/ formula which resizes the lot size based on Account Risk % calculated by including the STOPLOSS, and taking in consideration that my account is in EUR.
What i have is this:
extern double RISK=1; //1% RISK
LOT = NormalizeDouble(AccountEquity()*RISK/10000,2);
But this one doesnt consider the stoploss
So i found this one on google search
lot=NormalizeDouble(AccountBalance( )*MaximumRisk/StopLoss/(MarketInfo(Symbol(), MODE_TICKVALUE)),2);
And this one
lot = Risk * AccountEquity() / MarketInfo(Symbol(), MODE_TICKVALUE) / Stop;
But none of this works, please help me fix them, or give me a better one, thanks!
double Risk=(RiskPercent*AccountEquity())/100;//this means if your balance 1000$ & RiskPercent=10% >> you going to risk 100$
double lot=Risk/((StopLoss+Spread)*MarketInfo(Symbol(),MODE_TICKVALUE)*Q);//Make Sure to Define Your StopLoss & Q=10 in 5 digits or Q=1 in 4 Digits
Sorry its not good
Ok i see your point, so here is my logic and calculation how i calculate the RISK %
Which in MQL4 code looks like this:
extern double MYSTOPLOSS = 50; // CUSTOM SL SIZE IN PIPS AFTER THE STOPLEVEL
extern double RISK =2; // 2% ACCOUNT RISK
double LOT =(AccountEquity()*RISK)/(100*(MarketInfo(Symbol(),MODE_STOPLEVEL)+MYSTOPLOSS)* Point *100000 );
A simple 1 liner, nothing complicated, now please help me insert that DELTA stuff that you have been talking about, i know the formula is not complete so please help me.And please note that my account is in EURO so in most cases its the basic currency.
Yes i did, but i dont understand how you fit that into my equation, you said you need this:
/ MarketInfo(pair, MODE_TICKSIZE)
Try this link: https://www.mql5.com/en/forum/148224.
Perhaps looking at it from a different angle might help.
WTF guys, shouldnt that be TICKVALUE * TICKSIZE instead of TICKVALUE /TICKSIZE ? I think there is a big mistake there
Just made a quick indicator which shows separate values, i guess the TICKVALUE * TICKSIZE is the appropriate one...
And note the demo account is in EUR so that is the base currency, while i did the same test with a USD account and there the POINT was equivalent to TICKVALUE * TICKSIZE because it measures the quote currency value.
If i have understand the question right this will do the job for you.
for( i=0; i<=ot; i++ ) for( z=0; z<=10; z++ )
if( long_orders_array_ATF[i][z] > 0 )
for (zz=0; zz<=10; zz++)
if (OrderTicket()==long_orders_array_ATF[i][z]) zz=ot+2;
long_potencial_loss = (OrderLots() * (OrderOpenPrice() - OrderStopLoss()))*100000;
long_sum_potencial_loss = long_sum_potencial_loss + long_potencial_loss;
lot_size = ((((free-long_sum_potencial_loss) * percent_depo)/100.0)/pips)/100000 ; }