Download MetaTrader 5

Help converting simple MT4 into MT5

To add comments, please log in or register
Register as a seller and start making profit!
Vos77
169
Vos77 2011.08.15 17:30 

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);

 

To add comments, please log in or register