Welcome to mql4.com forum,
Your broker can change the comment. So the best thing to do is probably to ask them.
Hi at all, i'm experimenting a very strange problem, i re-used some code from my old EA but the comment inserted in the OrderSend doesn't appear in Terminal even if the field Comment is selected.
The strage thing is that, the same instruction in another EA works.
Below the two statements:
1.VERSION = "V 4.3DH_NMT_TT_EURUSD_test";
OrderSend( Symbol(), cmd, ORDER_SIZE, NormalizeDouble( order_open_price, Digits ), CLOSE_SLIPPAGE, 0, 0, MAGIC + "-FFEA " + VERSION, MAGIC, 0, arrow_col );
2.
VERSION = "4.44DH_NMT_TT_EURUSD_M5";
OrderSend( Symbol(), cmd, ORDER_SIZE, Ask, CLOSE_SLIPPAGE, 0, 0, MAGIC + "-FFEA " + VERSION, MAGIC, 0, arrow_col );
The first work the second not. To be clear, the orders are opened, only the comment in the second case don't be show.
please help, this thing is making me crazy !!
Hi alexflibero
I've done some testing using StringLen() and in my opinion, the reason why it's working in another EA might be a shorter Magic number.
My testing shows that if the length of the comment is more than 31 characters, for some mysterious reason, MT4 or my server, will discard the entire comment, not just
the last part of it and no error will be given. It may be a bug or it may be the server, can't tell for sure.
What you can do is to make sure that the comment isn't too long so it gets dropped by the mt4 or server, whichever does that. I tested it off line and my money is on a bug in mt4 for now.
Here are some checks you can place before the OrderSend() :
string orderComment = MAGIC+"-FFEA "+VERSION; int orderCommentLenght=StringLen(orderComment); if(orderCommentLenght >31) orderComment=StringSubstr(orderComment,0,31); orderCommentLenght=StringLen(orderComment); ticket=OrderSend(Symbol(),OP_BUY,1,Ask,3,0,0,orderComment,MAGIC,0,Red);
This will cut off the extra characters (from 31 to the end of the string)
so you get some part of the comment with your order.
Hope it helps.
Enjoy
PS. The broker will still cut the last characters of the comment to add [sl] if stopped out or [tp] if take profit reached.
But this happen only one EA, all the others work fine.
Hi alexflibero
I've done some testing using StringLen() and in my opinion, the reason why it's working in another EA might be a shorter Magic number.
My testing shows that if the length of the comment is more than 31 characters, for some mysterious reason, MT4 or my server, will discard the entire comment, not just
the last part of it and no error will be given. It may be a bug or it may be the server, can't tell for sure.
What you can do is to make sure that the comment isn't too long so it gets dropped by the mt4 or server, whichever does that. I tested it off line and my money is on a bug in mt4 for now.
Here are some checks you can place before the OrderSend() :
This will cut off the extra characters (from 31 to the end of the string)
so you get some part of the comment with your order.
Hope it helps.
Enjoy
PS. The broker will still cut the last characters of the comment to add [sl] if stopped out or [tp] if take profit reached.
Many many thanks thrdel: i'll check the lenght of the comment but, the strange thing is that it's the same for all the EA and the oldest work fine.
Many many thanks thrdel: i'll check the lenght of the comment but, the strange thing is that it's the same for all the EA and the oldest work fine.
The length of the comment depends on the magic number you use, if it is shorter or longer may determine if the comment is or isn't included in the order.
You can just copy / paste the code right after your definition of VERSION
VERSION = "V 4.3DH_NMT_TT_EURUSD_test"; //--- string orderComment = MAGIC+"-FFEA "+VERSION; int orderCommentLenght=StringLen(orderComment); if(orderCommentLenght >31) orderComment=StringSubstr(orderComment,0,31); orderCommentLenght=StringLen(orderComment); //--- OrderSend( Symbol(), cmd, ORDER_SIZE, NormalizeDouble( order_open_price, Digits ), CLOSE_SLIPPAGE, 0, 0, MAGIC + "-FFEA " + VERSION, MAGIC, 0, arrow_col );
and it will check the length and re-size if required. There may be a different length depending on the version of mt4 and then you need to adjust the " 31 " value with a smaller one, I don't know for sure.
It is also possible that, as suggested, some brokers will drop the comment completely . Again, I don't know. I just replicate your issue and found that on my mt4 comment is dropped if longer than 31 char.
Hope it helps.
Enjoy
Wow! It works now. You have right.
Many thanks
Wow! It works now. You have right.
Many thanks
You're welcome.
Have fun
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi at all, i'm experimenting a very strange problem, i re-used some code from my old EA but the comment inserted in the OrderSend doesn't appear in Terminal even if the field Comment is selected.
The strage thing is that, the same instruction in another EA works.
Below the two statements:
1.VERSION = "V 4.3DH_NMT_TT_EURUSD_test";
OrderSend( Symbol(), cmd, ORDER_SIZE, NormalizeDouble( order_open_price, Digits ), CLOSE_SLIPPAGE, 0, 0, MAGIC + "-FFEA " + VERSION, MAGIC, 0, arrow_col );
2.
VERSION = "4.44DH_NMT_TT_EURUSD_M5";
OrderSend( Symbol(), cmd, ORDER_SIZE, Ask, CLOSE_SLIPPAGE, 0, 0, MAGIC + "-FFEA " + VERSION, MAGIC, 0, arrow_col );
The first work the second not. To be clear, the orders are opened, only the comment in the second case don't be show.
please help, this thing is making me crazy !!