En cours

OrderCloseBy error in MetaTrader

I'm writing MQL4 strategy, and I'm struggling with OrderCloseBy function. It returns Error 3.

I wrote some simple program, see below, and it works most of the times in demo account, but always returns error 3 on ordercloseby in strategytester.

What can be the issue?

#property copyright "Copyright 2012, MetaQuotes Software Corp."

#property link "[url removed, login to view]"

#include <[url removed, login to view]>

int StrategyID = 3002;

string StrategyName = "TestCloseBy";

int TotalCount=2;

int ticketBuy = -1;

int ticketSell = -1;

int iCount = 1;

int start()

{

double dLots = 1;

int OpenTicket = OrdersTotal();

if (OpenTicket==0 && iCount<=TotalCount)

{

ticketBuy = OrderSend(Symbol(),OP_BUY,dLots,Ask,3,0,0,StrategyName+": buy order", StrategyID,0,Green);

if(ticketBuy>0)

{

if(OrderSelect(ticketBuy,SELECT_BY_TICKET,MODE_TRADES))

Print(StrategyName+":Buy market order opened confirm : ",OrderOpenPrice(), " ticketBuy : ",ticketBuy, ", vs ticketBuy : ",OrderTicket());

}

else Print(StrategyName + ":Error opening market order : ",GetLastError());

ticketSell = OrderSend(Symbol(),OP_SELL,dLots,Bid,3,0,0,StrategyName+": sell order", StrategyID,0,Red);

if(ticketSell>0)

{

if(OrderSelect(ticketSell,SELECT_BY_TICKET,MODE_TRADES))

Print(StrategyName+":Sell market order opened confirm : ",OrderOpenPrice(), " ticketsell : ",ticketSell, ", vs ticketSell : ",OrderTicket());

}

else Print(StrategyName + ":Error opening market order : ",GetLastError());

}

else if (OpenTicket==2 && iCount<=TotalCount)

{

if (OrderCloseBy(ticketBuy, ticketSell, White) == true)

Print(StrategyName,":OrderCloseBy ",ticketBuy,", ",ticketSell);

else

Print(StrategyName,"Error closing order test:",ticketBuy," : ",ticketSell," with Error ",GetLastError());

iCount++;

}

return(0);

}

Compétences : Metatrader

Voir plus : ordercloseby, ordercloseby error, mql4 ordercloseby function, metatrader ordercloseby, true green, always property, mql4 ordercloseby, symbol of red, www market net, metaquotes, mqh, simple print function, pending order strategy, strategy sell software, software program symbol, mql4 string, metatrader string, metatrader program, pending order metatrader, red error, program strategy, mql4 buy market order, metatrader net order, mql4 strategy, buy symbol

Concernant l'employeur :
( 6 commentaires ) Nes Ziona, Israel

N° du projet : #2352178

Décerné à :

iadip

Hi mate, I have 4+ years in MT4 expert advisor and indicators programming. I'm ready to help and I GUARANTEE my work. Regards, Irwin.

30 $ USD en 0 jours
(134 Commentaires)
6.7

4 freelance ont fait une offre moyenne de 30 $ pour ce travail

trunix

Hi there, i can help you :)

30 $ USD en 0 jours
(11 Commentaires)
4.6
Birju19

Hello, I can help you. Please check PMB.

30 $ USD en 1 jour
(8 Commentaires)
3.3
ChinaEricHe

I can do this job. Below is some of the feedbacks from my customers at [url removed, login to view] infarm: Each job gives me more confidence in EricHe. Doesn't give up the job until it Plus

30 $ USD en 0 jours
(2 Commentaires)
2.5