errors - miscellaneous questions

 

Hi,

I already know below error would like to say 'Object already exist', and I checked out all of my Label object names, and their names very different.
And just I would like to know where that problem come from?
(I just inform I use Label Create function for EA's)

LabelCreate: failed to create text label! Error code = 4200

Thanks in advance.

( English is not my native language )

 
Print the name as well as the error code
 
whroeder1:
Print the name as well as the error code

Oh! I can't understand your comment, sorry?

// second times edited

That's really annoying me. And I can't give my attention to my code.
So, I use one function in 2 places 1 - init special function and 2 - OnTick function, which one I use it for 'Spread sheet', so when I remove spread sheet label object that error warring disappear.

Please, help me if you can help me. 

 

You can find the error codes here: https://book.mql4.com/appendix/errors

Each object must have a unique name. It sounds like you are trying to create an object called "Spread sheet" twice. 

You can put this at the start of your EA:

#include <stdlib.mqh>

 And then call ErrorDesciption() in your code e.g.

int errorcode = GetLastError();
if(errorcode !=0 ) printf("Error %i: %s",errorcode,ErrorDescription(errorcode));


 

Error Codes - Appendixes - MQL4 Tutorial
Error Codes - Appendixes - MQL4 Tutorial
  • book.mql4.com
Error Codes - Appendixes - MQL4 Tutorial
 

honest_knave:

You can put this at the start of your EA:

#include <stdlib.mqh>

 And then call ErrorDesciption() in your code e.g.

int errorcode = GetLastError();
if(errorcode !=0 ) printf("Error %i: %s",errorcode,ErrorDescription(errorcode));

Thanks Honest, 

I just disabled 'Spread sheet' temporarily, because I haven't had enough time for it.
I followed your code, so I just replaced your code instead of below code, and I do not see any 'Warnings' yet, while 'market closed'...

if( !ObjectCreate( chart_ID, name, OBJ_LABEL, sub_window, 0, 0 ) )
{ Print(  __FUNCTION__, ": failed to create text label! Error code = ", GetLastError() ); return(false); }

I hope it will work for me.

 

Just bear in mind that your code will only give you the error number, not the error description.

You'll need to manually look up any codes you get in the link I posted above.

If you use stdlib.mqh you can print out the error description automatically. 

 
honest_knave:

If you use stdlib.mqh you can print out the error description automatically. 

Yeah! I already put it in 'Head'.
And I just tested it, it gives me below message.

EURUSD,M1: Error 0: no error

I think it's work.

Thanks! 

 

#4108 - Open

Below code closes all opening orders, but can't close Pending orders, and when I try to close I get this error: #4108 - ERR_INVALID_TICKET - Invalid ticket.

if(OrderSelect(ticketnumber,SELECT_BY_TICKET))
   {
    // order close code here...
   }

I need help please. 

Thanks in advance.

 
You don't close pending orders, you delete them

OrderDelete()
 

#4108 - Closed

Keith Watford:
You don't close pending orders, you delete them

OrderDelete()

Oh! I never mind it, I will try it soon.

Thanks for your comment.

 

#4051 - Open

Below part of code gives me Error #4051
Even I use below code method for my EA Trade Panel without any issues.

Thanks in advance.

void closebuy()
{
    Updates();

    for ( i = OrdersTotal() - 1; i >= 0; i-- )
    {
        if  ( ! OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;
        if  ( OrderSymbol() != Symbol() ) continue;
        if  ( OrderType() != OP_BUY ) continue;

        res = OrderClose( i, lots, OrderClosePrice(), 3, clrRed );
        if  ( ! res ) Print( " | Order Close Error #", GetLastError() );
        else          Print( " | Order Modified Successfully." );
    }
    //---
    return;
}
Reason: