Is it possible to append the pair symbol in trade comments for ease or sorting by pair later? - page 2

 
gordon:

You can append whatever u want. If you append non-string types then they will be type-casted into string (see here -> https://docs.mql4.com/basis/types/casting). You can use the addition operations (+) to concatenate strings or alternatively use StringConcatenate(). You should be aware that comment length is "31 characters + zero terminator. Server can rewrite 6 last characters. ie safety length is 25" (https://www.mql5.com/en/forum/101419), but I have seen cases where more than 6 characters are overwritten...

Note 7bit's comment... What is the point of adding all this info in the order's comment?



Many thanks for these replies. I can easily reduce the number of characters to well under 31 (and thanks for letting me know there is a limit) as I won't actually need to log the EA name - just the version/revision will be great. Appending this information will be very valuable. I will be able to see at a glance what these "key" settings are and save me pressing F7, scrolling down and having to write the information down on a separate piece of paper during forward testing and ultimately trading. It would be great to see these two variable settings in trade comments as they are used as a measure defining the individual chart pairs characteristics (trending, choppy/sideways - and the amplitude) and is fundamental to my EA trade management. No two pairs share the same settings so when I get this done I can dispense with the scraps of paper and multiple versions where only the settings differ. MT4 is a great program.

To answer Zbit's query, I have a spreadsheet which I update frequently to I evaluate performance. Well worth it as profit factor is now very high - I rapidly learn which pairs don't work and why. Doing this comments thing is easier to extract the data for analysis (LEFT, MID and RIGHT string functions). Up until now I have had to use version / revision numbers to indicate variable settings - a crude tool.


I am so appreciative of all your help and feedback. Thank you again
 
I have read the posted links to learn how to do what I seek using the references but am confused and have no idea about how to achieve what I want to do :-(


In my variables section I have:-

extern string L_Set = "Settings for Long Trade";
extern int SetA_Long = 25
extern int SetB_Long = 13
extern string S_Set = "Settings for Short Trade";
extern int SetA_Short = -25
extern int SetB_Short = -10

This is the line for OP_SELL

ticket = OrderSend(Symbol(), OP_SELL, SellLots, Bid, Slippage, 0, 0, Symbol() + " 6r1_Sell", SellOrderId, 0, Red);

the above line will show in trade comments as (say) " EURUSD 6r1 Sell" (16 chars incl space)

I am asking how can I append (in this excample) the values -25, a space and -10 so the trade comment will then be
" EURUSD -25 -10 6r1 Sell" a maximum total of 24 characters (22 if it is long) - I can alter the "6r1" to "r1"

Is the answer something like this?

ticket = OrderSend(Symbol(), OP_SELL, SellLots, Bid, Slippage, 0, 0, Symbol() + SetA_Short() + SetB_Short() + " 6r1_Sell", SellOrderId, 0, Red); ??

I tried the above but got error messages saying SetA_Short' - function is not defined

So I'm wondering what I did wrong. I'm feeling bad asking but I do learn from barriers like this cropping up and I am so thankful there are people out there that know the answer and are happy to help newbies like me here.

 
NewtonLeo:
[...]
ticket = OrderSend(Symbol(), OP_SELL, SellLots, Bid, Slippage, 0, 0, Symbol() + SetA_Short() + SetB_Short() + " 6r1_Sell", SellOrderId, 0, Red); ??

I tried the above but got error messages saying SetA_Short' - function is not defined [...]

The '()' is only for functions, but SetA_Short and SetB_Short are variables:

ticket = OrderSend(Symbol(), OP_SELL, SellLots, Bid, Slippage, 0, 0, Symbol() + " " + SetA_Short + " " + SetB_Short + " 6r1_Sell", SellOrderId, 0, Red);

 
Wonderful! Thank you so much. Gordon, you are a good man. I wish you well for your patience and help.