I need help! I am trying to translate my MT4 code into MT5, and need some clues. I looked for a suitable replacement for OrderClose() but I'm just going round in circles! Could anyone help me replace the functions used in the code sample with the MT5 equivalent? Thanks everyone...
Here is a piece of the EA,
// Init function -----------------------------------------------------------------------------------------------------------------------------------------------------
int init()
{
UsePoint = PipPoint(Symbol());
UseSlippage = GetSlippage(Symbol(),Slippage);
}
// Some Code Within The Start Function ------------------------------------------------------------------------------------------------------------------------
// Some Functions used in the EA --------------------------------------------------------------------------------------------------------------------------------
double PipPoint(string Currency)
{
int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Hi to the Forum,
I need help! I am trying to translate my MT4 code into MT5, and need some clues. I looked for a suitable replacement for OrderClose() but I'm just going round in circles! Could anyone help me replace the functions used in the code sample with the MT5 equivalent? Thanks everyone...
Here is a piece of the EA,
// Init function -----------------------------------------------------------------------------------------------------------------------------------------------------
int init()
{
UsePoint = PipPoint(Symbol());
UseSlippage = GetSlippage(Symbol(),Slippage);
}
// Some Code Within The Start Function ------------------------------------------------------------------------------------------------------------------------
if(BuyTicket1 >0)
{
OrderSelect(BuyTicket1,SELECT_BY_TICKET);
double OpenPrice1 = OrderOpenPrice();
if(Bid >= FastMA || Bid <= OpenPrice1-(StopLoss*UsePoint))
{
double CloseLots = OrderLots();
double ClosePrice = Bid;
bool Closed1 = OrderClose(BuyTicket1,CloseLots,ClosePrice,Slippage,Red);
if( Closed1 == true ) BuyTicket1 = 0;
}
}
// Some Functions used in the EA --------------------------------------------------------------------------------------------------------------------------------
double PipPoint(string Currency)
{
int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits == 2 || CalcDigits == 3) double CalcPoint = 0.01;
else if(CalcDigits == 4 || CalcDigits == 5) CalcPoint = 0.0001;
return(CalcPoint);
}
// Get Slippage Function
int GetSlippage(string Currency, int SlippagePips)
{
int CalcDigits = MarketInfo(Currency,MODE_DIGITS);
if(CalcDigits == 2 || CalcDigits == 4) double CalcSlippage = SlippagePips;
else if(CalcDigits == 3 || CalcDigits == 5) CalcSlippage = SlippagePips * 10;
return(CalcSlippage);
}