-
Play videoPlease edit your post.
For large amounts of code, attach it.
- I want to basically use my entire capital in every trade.Can't be done; you can only use your entire margin. If you do that, one tick down: margin call; you've lost half of your account.
- You place the stop where it needs to be - where the reason for the trade is no longer valid. E.g. trading a support bounce the stop goes below the support.
- Account Balance * percent = RISK = |OrderOpenPrice - OrderStopLoss| * OrderLots * DeltaPerlot (Note OOP-OSL includes the SPREAD)
- Do NOT use TickValue by itself - DeltaPerlot
- You must normalize lots properly and check against min and max.
- You must also check FreeMargin to avoid stop out
Hi All
I have previously coded in mql5 however i am new to mql4. I want to basically use my entire capital in every trade. I need to calculate the highest lot size. Here is the function i use in mql5 :
if(OrderCalcMargin(ORDER_TYPE_BUY,"AUDJPY",1.0,SymbolInfoDouble("AUDJPY",SYMBOL_ASK),AUDJPY_required_margin)) // Calculate margin required on 1 lot
{
if(NormalizeDouble(AccountInfoDouble(ACCOUNT_FREEMARGIN)/AUDJPY_required_margin,2))
{
AUDJPY_trade_volume=NormalizeDouble((AccountInfoDouble(ACCOUNT_FREEMARGIN)/AUDJPY_required_margin)*0.99,2);
}
}
Cab someone help me with the mql4 equivalent?
//+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double RMLotSize() { //------------------------------------------------------------------------------------------------- double Risk_Percent=2.0;//Percentage of Account Balance to Risk double Acct_Equity=AccountInfoDouble(ACCOUNT_EQUITY); double Acct_RiskCapitol=Acct_Equity*(Risk_Percent*0.01); //------------------------------------------------------------------------------------------------- //lotsize based on risk capitol double LotSize=Acct_RiskCapitol*Pips; //------------------------------------------------------------------------------------------------- //if lotsize is more than is permitted change the lotsize to the maximum permitted if(LotSize>MarketInfo(Symbol(),MODE_MAXLOT)) {LotSize=MarketInfo(Symbol(),MODE_MAXLOT);} //------------------------------------------------------------------------------------------------- //if lotsize is less than is permitted change the lotsize to the minimum permitted if(LotSize<MarketInfo(Symbol(),MODE_MINLOT)) {LotSize=MarketInfo(Symbol(),MODE_MINLOT);} //------------------------------------------------------------------------------------------------- //if there is no orders available print Account Information and LotSize available if(OrdersTotal()==0) { Print("-------------------------------------------------------------------------------------------------"); Print("LotSize based on the Capitol available...",DoubleToStr(LotSize,2)); Print("Amount of Capitol to Risk...",DoubleToStr(Acct_RiskCapitol,2)); Print("-------------------------------------------------------------------------------------------------"); } return(LotSize); }
double maxlot=AccountFreeMargin()/MarketInfo(Symbol(),MODE_MARGINREQUIRED);
thanks but,... what is Pips and how does it calculated?
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi All
I have previously coded in mql5 however i am new to mql4. I want to basically use my entire capital in every trade. I need to calculate the highest lot size. Here is the function i use in mql5 :
if(OrderCalcMargin(ORDER_TYPE_BUY,"AUDJPY",1.0,SymbolInfoDouble("AUDJPY",SYMBOL_ASK),AUDJPY_required_margin)) // Calculate margin required on 1 lot
{
if(NormalizeDouble(AccountInfoDouble(ACCOUNT_FREEMARGIN)/AUDJPY_required_margin,2))
{
AUDJPY_trade_volume=NormalizeDouble((AccountInfoDouble(ACCOUNT_FREEMARGIN)/AUDJPY_required_margin)*0.99,2);
}
}
Cab someone help me with the mql4 equivalent?