Getting arrow color value?

 
Dear Guys,

A seemingly simple problem is bugging me. It's giving me a real headache now... I'm done for. Please help if you can...

You see, when I send a trade, I usually set a colored arrow for it, which has special meaning to my trade. Now, it would be very important for me to be able to get back the exact color value of the arrow of a specific trade for which I have only the ticket number, and trough that, maybe some basic info about the trade, like the comment, etc. I see lot of functions in the documentation that return things like: OrderOpenTime, OrderOpenPrice, etc. etc., but I don't see anything like OrderArrowColor()...?

I also understand that there's some basic relation between the name, comment, etc. of the actual "arrow object" that appears on the chart and the trade itself... So I was thinking like... Let's identify the arrow object (somehow!!), then, maybe(!!) use this as a starting out point to get the color of the object. But - although if I tried hard and long enough I could probably implement this brute-hack - it sounds much too messy and less reliable, and "too messy" and "less reliable" usually means not the right solution... :((

Does anybody have any other idea that could make this possible? Once again, the problem is as "simple" as getting the "color" value of the trade's arrow, probably as an "integer" or "color" datatype...

Thank you immensely if you can solve my headache by pointing me in the right direction on this one...

L.
 
hunsheridan:
Dear Guys,

A seemingly simple problem is bugging me. It's giving me a real headache now... I'm done for. Please help if you can...

You see, when I send a trade, I usually set a colored arrow for it, which has special meaning to my trade. Now, it would be very important for me to be able to get back the exact color value of the arrow of a specific trade for which I have only the ticket number, and trough that, maybe some basic info about the trade, like the comment, etc. I see lot of functions in the documentation that return things like: OrderOpenTime, OrderOpenPrice, etc. etc., but I don't see anything like OrderArrowColor()...?

I also understand that there's some basic relation between the name, comment, etc. of the actual "arrow object" that appears on the chart and the trade itself... So I was thinking like... Let's identify the arrow object (somehow!!), then, maybe(!!) use this as a starting out point to get the color of the object. But - although if I tried hard and long enough I could probably implement this brute-hack - it sounds much too messy and less reliable, and "too messy" and "less reliable" usually means not the right solution... :((

Does anybody have any other idea that could make this possible? Once again, the problem is as "simple" as getting the "color" value of the trade's arrow, probably as an "integer" or "color" datatype...

Thank you immensely if you can solve my headache by pointing me in the right direction on this one...

L.

Ehh.. please nevermind... I've given up on this stupid idea. I will store the color values in MySQL instead and read them out from there... It would have been nice to solve this tough but this is really pointless... :(

However, just for someone else's benefit, I believe the best solution would have been to identify the arrow object using it's name. It's a straightforward thing if we know that the arrow's name is always formatted in this way:

#31597374 buy 1.00 USDJPY at 92.519
Where the #31597374 is the trade's ticket obviously, then the "buy" is again the trade type, 1.00 is the lots, USDJPY is the pair and 92.519 is the price... So we do know all we need to know to construct a replica string which is exactly identical to the name of the arrow object using the trade data we're able to get using the trade functions... Now then, we can perhaps select the arrow object using something like:

void SomeFunction() {
// ---- Some program logic... BLAH
string CurrOrderType="buy"; // We set this to the type of the order being handled as appropriate...
// ---- We do some more logic... BLAH
// Now we select the object and the color will be stored inside this variable... Theoretically...
color TradeArrowColor=ObjectGet(StringConcatenate("#",OrderTicket(), " ", CurrOrderType, " ", OrderLots(), " ", Symbol(), " at ", OrderOpenPrice()), OBJPROP_COLOR);
// ---- We process the color... BLAH
}
Well this example may or may not work... But at least my headache is gone...

I will still go with MySQL... it's the only way to be sure IMHO... :(
 
hunsheridan:

Ehh.. please nevermind... I've given up on this stupid idea. I will store the color values in MySQL instead and read them out from there... It would have been nice to solve this tough but this is really pointless... :(

However, just for someone else's benefit, I believe the best solution would have been to identify the arrow object using it's name. It's a straightforward thing if we know that the arrow's name is always formatted in this way:

Where the #31597374 is the trade's ticket obviously, then the "buy" is again the trade type, 1.00 is the lots, USDJPY is the pair and 92.519 is the price... So we do know all we need to know to construct a replica string which is exactly identical to the name of the arrow object using the trade data we're able to get using the trade functions... Now then, we can perhaps select the arrow object using something like:

Well this example may or may not work... But at least my headache is gone...

I will still go with MySQL... it's the only way to be sure IMHO... :(

why not check OrderType() ? If you set different colors for different types of trades you have a direct relationship between OrderType() and arrow color.

 
robofx.org:

why not check OrderType() ? If you set different colors for different types of trades you have a direct relationship between OrderType() and arrow color.

Firstly, thank you for taking the time to answer. Good idea, but unfortunately, in my case there's a little more to it than that...

You see, I'm right now working on a sub-module of an EA, and this module assigns color hues between 0-255 to a trade based on a rather complicated probability calculation, implemented in Matlab. This calculation is "expensive" in terms of processing power (both IO and CPU), so I'd rather not have to repeat it over and over. The result has to be both visual (hence the color translation) and easily recallable (hence the need to store and load the data). Other requirement is that if the TS freezes or gets turned off, the probability data could be "reloaded" during init cycle, and this is only possible if the data can be translated over from an external source, either from a database, or directly from chart objects or trades... Since AFAIK the trade comment cannot be modified to this end, I'm stuck with either a database (more stable solution) or chart objects... So this is the reason why I was wondering about getting color codes back from the "arrows"...

I hope I made sense... But under most other circumstance, your recommendation would be fine. I appreciate.

 
why not just store it in the comment field? At the moment you are sending the order you must already know the arrow color, otherwise you couldn't include the color value in the OrderSend() call. Why not just include the same value also in the comment string when sending the order?
 
use a range of magic numbers
 
WHRoeder:
use a range of magic numbers

I second that. Comments are sometimes changed by the server (although officially only the last 6 characters are -> https://www.mql5.com/en/forum/101419).

 
gordon:

I second that. Comments are sometimes changed by the server (although officially only the last 6 characters are -> https://www.mql5.com/en/forum/101419).

As for the magic number and comment, good ones, and what you say is totally true, but still no good: What I forgot to tell is that these colors / values sometimes have to be changed periodically. You see as time goes on, probabilities get recalculated once per hour candle, and arrow colors are modified using OrderModify()... (AFAIK OrderModify cannot change Magic number nor Comment after the trade has been placed?)

I thought I could play with "Expiration" somehow, but even that can only be modified for pending orders...

Sorry... I know this is a bitch. You can see why I got headache at first. So far I have no solution besides the messy/inaccurate(?) ObjectGet() and the overkill MySQL... For the time being MySQL works, but for backtesting I had to implement a temporary array-based storage into the program, otherwise the tester segfaults on me after two seconds, as it does always when I use any MySQL... :) :(


L.
 
then i would stay with ObjectGet() to get the arrow color. I can't see anything messy or inaccurate with that approach. The Object name is deterministic and only a few lines of code are sufficient to make a function int getColorByTicket(int ticket).
Reason: