How can I Select the order, check it's OrderType() ?
Do you want someone to write the code for you ? go here: MetaQuotes official MT4 and MT5 coding services
I have already:
int CalculateCurrentOrders() { int pos=0; 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++; } } return(pos); }
I have already:
OK, so what is the problem ?
if(OrderType()==OP_BUY) string = "Buy";
I made this code:
{ string OrderTyp = "OT"; if (OrderType()==OP_BUY) string ot="Buy"; else ot="Sell"; ObjectCreate(OrderTyp, OBJ_LABEL, 0 , 0, 0, 0); ObjectSet(OrderTyp, OBJPROP_CORNER, 1); ObjectSet(OrderTyp, OBJPROP_XDISTANCE, 10); ObjectSet(OrderTyp, OBJPROP_YDISTANCE, 15); ObjectSetText(OrderTyp, "Order Type: "+ot, 8, "Tahoma", CommentColor); }
But it doesn't shows the current charts type!
I made this code:
But it doesn't shows the current charts type!
Did you select the correct Order first ? show your code where you select the correct Order. Before you create an Object, check if it exists first . . . haven't I said that twice already ?
Also . . . Object DeleteAll() is lazy, don't use it . . . one day you will put your indicator onto a chart with other Objects already on the chart that you want to keep . . . then when you change timeframe of remove the Indicator all the Objects you wanted to keep will be gone . . .
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I want to show open position's type on chart.
For example if current chart's position is short, then show "Sell" text on chart. (Just for open positions not pending)
Regards