How to show order type (Sell/Buy) on chart?

 

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

 
Konnj:

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

Select the order, check it's OrderType(), place the relevant Object on the chart (label or text)
 

How can I Select the order, check it's OrderType() ?

Is this correct?


string OrderTypeP = DoubleToStr(OrderType(), 0);


 
Konnj:
How can I Select the order, check it's OrderType() ?

OrderSelect(), 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);
  }
 
Konnj:

I have already:

OK, so what is the problem ?

if(OrderType()==OP_BUY) string = "Buy";
 
Where should I use it? actually I have no idea right now! :(
 

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!

 
Konnj: But it doesn't shows the current charts type!
MT4 on;y has one chart type - time based.
 
Konnj:

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 . . .

 
What about Ticket chart type?