Questions from Beginners MQL4 MT4 MetaTrader 4 - page 256
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
On my old laptop with i3 processor I still have WinXP 32 bit, not supported by MT5. Recently I have increased the memory up to 6 Gb, I would like to install a 64 bit OS running MT4 and MT5. Which is preferable - Win7 or Win8.1
I prefer the 7. The office has an 8, a 10 and a 7. Terminals on 7 are more stable. For unknown reasons, testers in 7 are faster on weak computers. 8ka is not very transitional at all. It eats the most resources. 10 requires more resources for itself.
My old laptop with i3 processor still had WinXP 32 bit installed, not supported by MT5. Recently I have increased the memory up to 6 Gb, I would like to install 64 Bit OS that would support MT4 and MT5. Which is preferable - Win7 or Win8.1 ?
Go to your laptop manufacturer's website and see which maximum OS the official drivers are for and that will be your preferred OS. If the drivers are for Win 8.1 you can try Win 10. If the drivers end up in Win 7 then there is not much choice.
Good afternoon, can you please help.
I need to add a take profit to this EA and display parameters to change when the EA runs.
there are two warnings return value of 'OrderClose' should be checked also please correct
extern double Lots = 0.1;
extern double MaximumRisk = 0.3;
extern double DecreaseFactor = 100;
double st1,st2;
//+------------------------------------------------------------------+
//| Calculate open positions |
//+------------------------------------------------------------------+
int CalculateCurrentOrders(string symbol)
{
int buys=0,sells=0;
//----
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) buys++;
if(OrderType()==OP_SELL) sells++;
}
}
//---- return orders volume
if(buys>0) return(buys);
else return(-sells);
}
//+------------------------------------------------------------------+
//| 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
//---- select lot size
lot=NormalizeDouble(AccountFreeMargin()*MaximumRisk/1000.0,3);
//---- 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)==false) { 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.1) lot=0.1;
return(lot);
}
//+------------------------------------------------------------------+
//| Check for open order conditions |
//+------------------------------------------------------------------+
void CheckForOpen()
{
int res;
if(Volume[0]>1) return;
//---- buy -----------------------
if ((iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_MAIN,0)>iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_SIGNAL,0))
if ((Open[0]<Open[1])&&(Close[0]<Close[1])
//
{
res=OrderSend(Symbol(),OP_BUY,LotsOptimized(),Ask,3,15,0,",0,0,Blue);
return;
}
//---- sell ------------------------
if ((iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_MAIN,0)<iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_SIGNAL,0))
if((Open[0]>Open[1])&&(Close[0]>Close[1]))
{
res=OrderSend(Symbol(),OP_SELL,LotsOptimized(),Bid,3,15,0,",0,0,Red);
return;
}
}
//------------Закрытие позиций----------------------------------------
void CheckForClose2()
{
if(OrderType()==OP_BUY) OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
If(OrderType()==OP_SELL) OrderClose(OrderTicket(),OrderLots(),Ask,3,Blue);
//CheckForOpen();
}
//
//+------------------------------------------------------------------+
//| Check for close order conditions |
//+------------------------------------------------------------------+
void CheckForClose1()
{
if(Volume[0]>1) return;
//check for loss
if ((AccountProfit()<0)&&(MathAbs(AccountProfit())>=(AccountMargin()*MaximumRisk)))
{
CheckForClose2();
Print("loss", AccountProfit());
}/**/
//---- check order type
if(OrderType()==OP_BUY)
{
if ((iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_MAIN,0)<iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_SIGNAL,0))
if ((Open[0]>Open[1])&&(Close[0]>Close[1]))
CheckForClose2();
}
if(OrderType()==OP_SELL)
{
if ((iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_MAIN,0)>iStochastic(NULL,0,15,26,10,MODE_SMA,0,MODE_SIGNAL,0))
if ((Open[0]<Open[1])&&(Close[0]<Close[1]))
CheckForClose2();
}
}
//+------------------------------------------------------------------+
//| Start function |
//+------------------------------------------------------------------+
void start()
{
//---- calculate open orders by current symbol
if(CalculateCurrentOrders(Symbol())==0) CheckForOpen();
else CheckForClose1();
//---
}
//+-----------------------------------------------+
I have added the calculation of SL and TP, but it would be nice to add their checking. You can read how to do this in the articlehttps://www.mql5.com/ru/articles/2555#invalid_SL_TP_for_position.
Your warning is not critical. The result of OrderClose is just ignored, hence the warning. You can, for example, make the CheckForClose2 function return the result of OrderClose. Or you can leave it as it is.
Another thing that I noticed was that the names of the functions CheckForClose2,CheckForOpen, etc. were strange .And you have them performing trade operations.
Hello all. Can someone help me to edit the EA. I have to remove the order opening function so the EA will not open orders by itself but only work with manually opened orders. Many thanks in advance.
Remove the order opening function and set magic to 0. The robot will pick up manually opened orders and follow them. If we want the robot to follow only individual orders, and not all of them in a row, then make the entry into Buy and Sell, for example, by pressing the appropriate button which the robot should create and process in OnChartEvent event CHARTEVENT_OBJECT_CLICK of each of them. Magic in this case must be greater than 0 in order to work only with its own orders.
https://www.mql5.com/ru/forum/131859/page9#434297
isTradeTimeString()
isTradeTimeInt()
Hello.
Such a glitch... I'm testing one! Expert on 3 computers. On 2 of them work accurately, while on one of them I always get some kind of bug in calculations - in general it fails to correctly calculate stop loss or false triggering.
Hardware is not new, but not old.
Has anyone encountered anything like this?
Hardware is not new, but not old.
Has anyone had problems with this?
All three are connected to the same broker/dealer server? (I mean, is it the same story?) If not, that's the first place to look.