If it works for you - fine. I am glad. But my view is that any indicator should be universal as much as possible, and not good for some specific situation only. You do it once but do it properly, so that if you need to change something or situation changes in terms of your positions it works correctly.
Anyway, you are welcome.
It won't work, you create the Object and then try to create it again on the next tick, this will fail . . . so if the first Order is a Buy and the second a Sell the text will not update from Buy to Sell.
As I said before there are A LOT of mistakes in the code. I was hoping the asker will work on it himself and understand the coding a bit more. That seems not to be his intention. And unfortunately I have no time to write the code for him. I just gave him something to start working, not a finished product.
RaptorUK: It won't work, you create the Object and then try to create it again on the next tick, this will fail . . . so if the first Order is a Buy and the second a Sell the text will not update from Buy to Sell.
It works, but just show the last order. I don't know how to change it for current order!
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
If it works for you - fine. I am glad. But my view is that any indicator should be universal as much as possible, and not good for some specific situation only. You do it once but do it properly, so that if you need to change something or situation changes in terms of your positions it works correctly.
Anyway, you are welcome.
It won't work, you create the Object and then try to create it again on the next tick, this will fail . . . so if the first Order is a Buy and the second a Sell the text will not update from Buy to Sell.
It works, but just show the last order. I don't know how to change it for current order!
I don;t know if it is good practice or not, but I create the labels in init() and ObjectSetText just with a "."
I haven't figured out how to place a label with totally empty text yet. If I try it comes up with the text"Label"
Of course that is fine as long as you know how many labels you will need.
I guess that it shouldn't be too difficult to delete excess labels and add new labels when required in the main body.
This is the code that I use in init() to create the labels
Oh. and in deinit()
It works, but just show the last order. I don't know how to change it for current order!
{ int counted_bars=IndicatorCounted(); int pos; string OrderTip = "OT"; string ottt; color LabelColor3; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() ) { if(OrderType()==OP_BUY) pos++; if(OrderType()==OP_SELL) pos++; } } if (OrderType()==OP_BUY) { ottt="Buy"; LabelColor3 = DodgerBlue; } if (OrderType()==OP_SELL){ ottt="Sell"; LabelColor3 = Red; } else ottt=""; ObjectCreate(OrderTip, OBJ_LABEL, 0 , 0, 0, 0); ObjectSet(OrderTip, OBJPROP_CORNER, 1); ObjectSet(OrderTip, OBJPROP_XDISTANCE, 10); ObjectSet(OrderTip, OBJPROP_YDISTANCE, 15); ObjectSetText(OrderTip, "Order Type: "+ottt, 8, "Tahoma",LabelColor3); }I meant the whole code . . . but never mind . . . try these changes.
{ int counted_bars=IndicatorCounted(); int pos; string OrderTip = "OT"; string ottt = " "; color LabelColor3 = Black; for(int i=0;i<OrdersTotal();i++) { if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break; if(OrderSymbol()==Symbol() ) { if (OrderType() == OP_BUY) { ottt = "Buy"; LabelColor3 = DodgerBlue; } if (OrderType() == OP_SELL){ ottt = "Sell"; LabelColor3 = Red; } } } if (ObjectFind(OrderTip) < 0) ObjectCreate(OrderTip, OBJ_LABEL, 0 , 0, 0, 0); ObjectSet(OrderTip, OBJPROP_CORNER, 1); ObjectSet(OrderTip, OBJPROP_XDISTANCE, 10); ObjectSet(OrderTip, OBJPROP_YDISTANCE, 15); ObjectSetText(OrderTip, "Order Type: "+ottt, 8, "Tahoma",LabelColor3); }Please do not post queries that have nothing to do with this very old thread
I have reposted your query
https://forum.mql4.com/72256