Color of closed trade lines - can they be changed from red/blue to something else?

 

Seems like every other color of line can be changed, even the arrow color as part of OrderSend and OrderClose, but not the dotted line that joins the arrows after an EA has closed a trade.

Anyone know if both the color of the line can be changed and the line style?

 
Perhaps with the ObjectSet(). Check-Out the rest of the Object commands Here.
 
ubzen:
Perhaps with the ObjectSet(). Check-Out the rest of the Object commands Here.

Thanks. Not a bad suggestion, but can't see how you can do that for all closed-trade lines and arrows that appear on a chart, after an EA has closed a trade.

Listing the objects, they are all called "trendline", and named from the ticket and open - close values, e.g., #1749156 1.58321 -> 1.58346

Can't see how I can make a command, say in the EA, that changes the color or type of arrow for all trendlines on the chart.

Probably needs someone from MetaQuotes to tell us if its possible, or forget it.

 
davidb_012:

Thanks. Not a bad suggestion, but can't see how you can do that for all closed-trade lines and arrows that appear on a chart, after an EA has closed a trade.

Listing the objects, they are all called "trendline", and named from the ticket and open - close values, e.g., #1749156 1.58321 -> 1.58346

Can't see how I can make a command, say in the EA, that changes the color or type of arrow for all trendlines on the chart.

Probably needs someone from MetaQuotes to tell us if its possible, or forget it.

Loop through the objects, select the ones that are type trendline whose name starts with a # and change the colour . . . what is difficult ?
 
RaptorUK:
Loop through the objects, select the ones that are type trendline whose name starts with a # and change the colour . . . what is difficult ?

Slightly less obvious is what colour to change it to in terms of what type of trade it was. This script works and changes them all to White.

int start(){

   for( int n=ObjectsTotal()-1; n>=0; n-- ){
      string str= ObjectName(n);

      if( ObjectType(str) != OBJ_TREND )
         continue;

      if( StringGetChar(str,0) != '#' )
         continue;

      ObjectSet(str,OBJPROP_COLOR,White);
   }
   
   return(0);
}

If this script is further developed, one could read the ticket number, decide what sort of trade it was, and colour the line accordingly.

 
dabbler:

Slightly less obvious is what colour to change it to in terms of what type of trade it was. This script works and changes them all to White.

If this script is further developed, one could read the ticket number, decide what sort of trade it was, and colour the line accordingly.

Is it efficient to loop through all objects at the beginning of start()? Say if I only want to change the colour of the trendlines that have just closed, which should only be a few in each tick, I wonder if there is a smarter way? Thanks!
 
Keep track of the last order that you changed the colour of the line for . . . if there have been orders closed more recently than that one then you need to process their lines too . . .
 
RaptorUK:
Keep track of the last order that you changed the colour of the line for . . . if there have been orders closed more recently than that one then you need to process their lines too . . .

Thanks! Got it!!

 
RaptorUK:
Keep track of the last order that you changed the colour of the line for . . . if there have been orders closed more recently than that one then you need to process their lines too . . .

It doesn't quite work. This is what I get at deinit:

int deinit()
{
   myPrint(0, "ObjectTotal="+ObjectsTotal());
   for(int i=0; i<ObjectsTotal(); i++){
      myPrint(0, i+" "+ObjectName(i));
   }

2012.05.03 23:59:22 Bar:1096 0 #1 1.31471 -> 1.31469

2012.05.03 23:59:22 Bar:1096 1 #1 sell 0.20 EURUSD at 1.31471

2012.05.03 23:59:22 Bar:1096 2 #1 sell 0.20 EURUSD at 1.31471 close by tester at 1.31469

2012.05.03 23:59:22 Bar:1096 3 #1 sl modified

2012.05.03 23:59:22 Bar:1096 4 #1 tp modified

2012.05.03 23:59:22 Bar:1096 5 #10 1.31601 -> 1.31689

2012.05.03 23:59:22 Bar:1096 6 #10 buy 0.20 EURUSD at 1.31601

2012.05.03 23:59:22 Bar:1096 7 #10 buy 0.20 EURUSD at 1.31601 close by tester at 1.31689

2012.05.03 23:59:22 Bar:1096 8 #10 sl modified

2012.05.03 23:59:22 Bar:1096 9 #10 tp modified

2012.05.03 23:59:22 Bar:1096 10 #11 1.31711 -> 1.31585

2012.05.03 23:59:22 Bar:1096 11 #11 buy 0.20 EURUSD at 1.31711

2012.05.03 23:59:22 Bar:1096 12 #11 buy 0.20 EURUSD at 1.31711 close by tester at 1.31585

2012.05.03 23:59:22 Bar:1096 13 #11 sl modified

2012.05.03 23:59:22 Bar:1096 14 #11 tp modified

2012.05.03 23:59:22 Bar:1096 15 #12 1.31593 -> 1.31467

2012.05.03 23:59:22 Bar:1096 16 #12 buy 0.20 EURUSD at 1.31593

2012.05.03 23:59:22 Bar:1096 17 #12 buy 0.20 EURUSD at 1.31593 close by tester at 1.31467

2012.05.03 23:59:22 Bar:1096 18 #12 sl modified

2012.05.03 23:59:22 Bar:1096 19 #12 tp modified

2012.05.03 23:59:22 Bar:1096 20 #13 1.31545 -> 1.31436

2012.05.03 23:59:22 Bar:1096 21 #13 buy 0.20 EURUSD at 1.31545

2012.05.03 23:59:22 Bar:1096 22 #13 buy 0.20 EURUSD at 1.31545 close at 1.31436

2012.05.03 23:59:22 Bar:1096 23 #13 sl modified

2012.05.03 23:59:22 Bar:1096 24 #13 tp modified

2012.05.03 23:59:22 Bar:1096 25 #14 1.31435 -> 1.31514

2012.05.03 23:59:22 Bar:1096 26 #14 sell 0.20 EURUSD at 1.31435

2012.05.03 23:59:22 Bar:1096 27 #14 sell 0.20 EURUSD at 1.31435 close at 1.31514

2012.05.03 23:59:22 Bar:1096 28 #14 sl modified

2012.05.03 23:59:22 Bar:1096 29 #14 tp modified

2012.05.03 23:59:22 Bar:1096 30 #15 buy 0.20 EURUSD at 1.31512

2012.05.03 23:59:22 Bar:1096 31 #15 sl modified

2012.05.03 23:59:22 Bar:1096 32 #15 tp modified

2012.05.03 23:59:22 Bar:1096 33 #2 1.31444 -> 1.31570

2012.05.03 23:59:22 Bar:1096 34 #2 sell 0.20 EURUSD at 1.31444

2012.05.03 23:59:22 Bar:1096 35 #2 sell 0.20 EURUSD at 1.31444 close by tester at 1.31570

2012.05.03 23:59:22 Bar:1096 36 #2 sl modified

2012.05.03 23:59:22 Bar:1096 37 #2 tp modified

2012.05.03 23:59:22 Bar:1096 38 #3 1.31564 -> 1.31438

2012.05.03 23:59:22 Bar:1096 39 #3 buy 0.20 EURUSD at 1.31564

2012.05.03 23:59:22 Bar:1096 40 #3 buy 0.20 EURUSD at 1.31564 close by tester at 1.31438

2012.05.03 23:59:22 Bar:1096 41 #3 sl modified

2012.05.03 23:59:22 Bar:1096 42 #3 tp modified

2012.05.03 23:59:22 Bar:1096 43 #4 1.31463 -> 1.31337

2012.05.03 23:59:22 Bar:1096 44 #4 buy 0.20 EURUSD at 1.31463

2012.05.03 23:59:22 Bar:1096 45 #4 buy 0.20 EURUSD at 1.31463 close by tester at 1.31337

2012.05.03 23:59:22 Bar:1096 46 #4 sl modified

2012.05.03 23:59:22 Bar:1096 47 #4 tp modified

2012.05.03 23:59:22 Bar:1096 48 #5 1.31360 -> 1.31349

The problem is that #10-#19 will pre-empt #2-#9 in the object list. So if I keep track from last changed colour line, I now always stopped after #9, as my indexing could be wrong starting from #10 ........

 
I can work if it I always compose the line colour from index 0 to ObjectsTotal(), but it is noticeably slower.
 
lingwuchung:

It doesn't quite work. This is what I get at deinit:


The problem is that #10-#19 will pre-empt #2-#9 in the object list. So if I keep track from last changed colour line, I now always stopped after #9, as my indexing could be wrong starting from #10 ........

I'm a little confused . . . you should be processing the Objects based on the OrderHistory not the Object list . . . I said "Keep track of the last order that you changed the colour of the line for " not the Object.