Download MetaTrader 5
To add comments, please log in or register
Sign up for MQL5.community to post your Forum topic
Proximus
756
Proximus 2014.08.25 08:44 
void init()
{
.....
  IndicatorShortName("AH5");
.....
}
 if(OrdersTotal()>0) 
 {
 OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
 
ObjectCreate( ChartWindowFind(0,"AH5"),"LINE1",OBJ_HLINE,0,Time[0],OrderOpenPrice());
ObjectSet   ("LINE1", OBJPROP_PRICE1,OrderOpenPrice() );
ObjectSet   ("LINE1",OBJPROP_COLOR,Yellow);
ObjectSet   ("LINE1",OBJPROP_WIDTH,2);
 }


Hi i would like to draw a horizontal line on my indicator, right at the open price level of my 1 order (i only put 1 order at once).

For some reason it is not drawn, i suspect that the code cant find the separate window, so please help me correct my code fast :D

Keith Watford
Moderator
8007
Keith Watford 2014.08.25 09:25  

Instead of 

ObjectCreate( ChartWindowFind(0,"AH5"),"LINE1",OBJ_HLINE,0,Time[0],OrderOpenPrice());

 You may do better with

ObjectCreate( 0,"LINE1",OBJ_HLINE,ChartWindowFind(0,"AH5"),Time[0],OrderOpenPrice());

 But if AH5 is in a separate window you need to be sure that the OrderOpenPrice is within the minimum and maximum of the indicator window.

Why not just draw the line on the main chart? 

Proximus
756
Proximus 2014.08.25 09:34  
GumRai:

Instead of 

 You may do better with

 But if AH5 is in a separate window you need to be sure that the OrderOpenPrice is within the minimum and maximum of the indicator window.

Why not just draw the line on the main chart? 

 

 


Well, my indicator filters the price in a special way, and i wanted to see the open price on my indicator chart too, i will also add SL and TP levels just the same way.

Anyway it works, thanks much!

/
To add comments, please log in or register