Download MetaTrader 5
To add comments, please log in or register
How to choose the most appropriate signal and subscribe to it in no time
Konnj
97
Konnj 2013.07.30 12:43 

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

Simon Gniadkowski
Moderator
17976
Simon Gniadkowski 2013.07.30 12:54  
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)
Konnj
97
Konnj 2013.07.30 12:59  

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

Is this correct?


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


Simon Gniadkowski
Moderator
17976
Simon Gniadkowski 2013.07.30 13:04  
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

Konnj
97
Konnj 2013.07.30 13:38  

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);
  }
Simon Gniadkowski
Moderator
17976
Simon Gniadkowski 2013.07.30 14:35  
Konnj:

I have already:

OK, so what is the problem ?

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

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!

whroeder1
13993
whroeder1 2013.07.30 15:51  
Konnj: But it doesn't shows the current charts type!
MT4 on;y has one chart type - time based.
Simon Gniadkowski
Moderator
17976
Simon Gniadkowski 2013.07.30 16:09  
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 . . .

Konnj
97
Konnj 2013.07.30 16:10  
What about Ticket chart type?
/ /123
To add comments, please log in or register