'attrTicketChild' - function not defined; Check profit (money) doesn't work as intended
-
A new error that appears only in one of my EA's:
[
]Check profit (money) will take profit at random quantities.
-
Found out the money TP calculation works, but it won't take commisions into account.
-
Hi there
I got the same error attrTicketChild.
I fixed changing these 2 lines:
|| (ClosePartialMode == 1 /*&& e_attrTicket() == attrTicketParent(e_attrTicket()) /&& e_attrTicket() == attrTicketChild(e_attrTicket())) // fully closed
|| (ClosePartialMode == 2 /&& e_attrTicket() == attrTicketParent(e_attrTicket()) */&& e_attrTicket() != attrTicketChild(e_attrTicket())) // partially closedto these 2:
|| (ClosePartialMode == 1 && e_attrTicket() == attrTicketParent(e_attrTicket()) && e_attrTicket() == attrTicketChild(e_attrTicket())) // fully closed
|| (ClosePartialMode == 2 && e_attrTicket() == attrTicketParent(e_attrTicket()) && e_attrTicket() != attrTicketChild(e_attrTicket())) // partially closedAnd adding the function between attrTicket() and attrTicketParent()
int attrTicketChild(int ticket)
{
int pos, total, retval=0;if (!OrderSelect(ticket,SELECT_BY_TICKET)) {retval=ticket;}
/*
//-- check if trade is added to volume ----------------------------
if (retval==0) {
int p_pos=StringFind(attrComment(), "[p=");
if (p_pos >= 0) {
string ptag=StringSubstr(attrComment(),p_pos);
ptag=StringSubstr(ptag,0,StringFind(ptag,"]")+1);
retval=StrToInteger(StringSubstr(ptag,3,-1));
}
}
*/
double OP = 0;
datetime OT = 0;
string S = "";
int M = 0;
int T = 0;
double L = 0;
int D = 0;//-- check if trade is partially closed (in trades) ---------------
if (retval==0) {
OP = OrderOpenPrice();
OT = OrderOpenTime();
S = OrderSymbol();
M = OrderMagicNumber();
T = OrderType();
L = OrderLots();
D = (int)MarketInfo(S,MODE_DIGITS);total=OrdersTotal();
for (pos=total-1; pos>=0; pos--) {
if (OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
{
if (OrderOpenTime()<OT) {
break;
}
if (
OrderTicket()!=ticket
&& (OrderSymbol()==S)
&& (OrderMagicNumber()==M)
&& (OrderType()==T)
&& (NormalizeDouble(OrderOpenPrice(),D)==NormalizeDouble(OP,D))
&& (OrderOpenTime()==OT)
)
{
retval=OrderTicket();
break;
}
}
}
}
//-- still nothing found - search in history trades now -----------
if (retval==0) {
total=OrdersHistoryTotal();
for (pos=total-1; pos>=0; pos--) {
if (OrderSelect(pos,SELECT_BY_POS,MODE_HISTORY))
{
if (OrderOpenTime()<OT) {
break;
}
if (
OrderTicket()!=ticket
&& (OrderSymbol()==S)
&& (OrderMagicNumber()==M)
&& (OrderType()==T)
&& (NormalizeDouble(OrderOpenPrice(),D)==NormalizeDouble(OP,D))
&& (OrderOpenTime()==OT)
)
{
retval=OrderTicket();
break;
}
}
}
}if (retval<ticket) {retval=0;}
if (!OrderSelect(ticket,SELECT_BY_TICKET)) {return ticket;}
if (retval>0) {
return(retval);
}
else {
return(ticket);
}
}After that, you can compile with no problems.
Hope that helpsThanks
-
@azazelio Thanks for your reply

Error stopped appearing after removing "On_Trade events".
-
Hello,
The same issue It's happening to me as well...
-
I'm having this issue today as well!!!
@fxDreema why are we continually having these sort of issues?