How to Draw S/R Lines and Block?

 

How to draw a Support/Resistance line depending on just a Single Price?

Like drawing a single Horizontal line at price 1.3850.

And how to draw a block between two prices?

Like drawing a rectangular block between 1.3850 & 1.3860?

Regards

 
Arav007:

How to draw a Support/Resistance line depending on just a Single Price?

Like drawing a single Horizontal line at price 1.3850.

Either obj_trend if you want a start and end point.

Or obj_hline if you want a continuous line.

Arav007:

Like drawing a rectangular block between 1.3850 & 1.3860?

obj_rectangle
 
honest_knave:

Either obj_trend if you want a start and end point.

Or obj_hline if you want a continuous line.

obj_rectangle


Thanks for the Reply and links but I'm wanting to use those in an EA.

But these are Scripts which are too complicated for me to combine with the EA.

So if you could give the direct example by which I can draw such lines it'd be Best.

I found 'ObjecCreate()' function probably is used for this but I couldn't figure that out.

Thanks

 

Have a go at making something work from those links.

If your code doesn't work, post up your attempted code and we'll help out.

If you're unable/unwilling to attempt a go yourself, you may get on better here

 
honest_knave:

Have a go at making something work from those links.

If your code doesn't work, post up your attempted code and we'll help out.

If you're unable/unwilling to attempt a go yourself, you may get on better here


Ha Ha Ha. Nice to see you to follow the WHRoeder way.

And you probably didn't got my point. I didn't asked you to write a code for me.

I have told that if there is any simple example of how to Draw a S/R line then provide it thus I can follow it like there are functions with explanations for OrderSend() etc.

I always Search the Solution, Try by myself and if still unable to make things right or get things properly, I ask for Help here.

You can go through my older threads for the evidences.

Thanks for your Suggestion for going here.

 

There are plenty of examples in the links provided. For example from obj_rectangle:

//--- create a rectangle by the given coordinates
   if(!ObjectCreate(chart_ID,name,OBJ_RECTANGLE,sub_window,time1,price1,time2,price2))
     {
      Print(__FUNCTION__,
            ": failed to create a rectangle! Error code = ",GetLastError());
      return(false);
     }
//--- set rectangle color
   ObjectSetInteger(chart_ID,name,OBJPROP_COLOR,clr);
//--- set the style of rectangle lines
   ObjectSetInteger(chart_ID,name,OBJPROP_STYLE,style);
//--- set width of the rectangle lines
   ObjectSetInteger(chart_ID,name,OBJPROP_WIDTH,width);
//--- enable (true) or disable (false) the mode of filling the rectangle
   ObjectSetInteger(chart_ID,name,OBJPROP_FILL,fill);
//--- display in the foreground (false) or background (true)
   ObjectSetInteger(chart_ID,name,OBJPROP_BACK,back);
//--- enable (true) or disable (false) the mode of highlighting the rectangle for moving
//--- when creating a graphical object using ObjectCreate function, the object cannot be
//--- highlighted and moved by default. Inside this method, selection parameter
//--- is true by default making it possible to highlight and move the object
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTABLE,selection);
   ObjectSetInteger(chart_ID,name,OBJPROP_SELECTED,selection);
//--- hide (true) or display (false) graphical object name in the object list
   ObjectSetInteger(chart_ID,name,OBJPROP_HIDDEN,hidden);
//--- set the priority for receiving the event of a mouse click in the chart
   ObjectSetInteger(chart_ID,name,OBJPROP_ZORDER,z_order);

There is also documentation on all those items too:

ObjectCreate

ObjectSetInteger

Object Properties

So again, please make an attempt at drawing your objects. If it doesn't work, post up your attempt and others here will help you.

 
honest_knave:

There are plenty of examples in the links provided. For example from obj_rectangle:

There is also documentation on all those items too:

ObjectCreate

ObjectSetInteger

Object Properties

So again, please make an attempt at drawing your objects. If it doesn't work, post up your attempt and others here will help you.


Hello,

Thanks for the links.

I have gone through them though couldn't get a Straight Forward solution.

So I tried like this with all the knowledge I could gather, but it's showing Error:4200!

Why this is occurring?

{
//--- reset the error value
   ResetLastError();
   
string name="New_Rectangualr_object";
   long chart_ID=ChartID();
   
ObjectCreate(name,OBJ_RECTANGLE,0, Time[100], 1.68505, Time[1], 1.68405, 0, 0);
ObjectSet(name,OBJPROP_COLOR,Blue) ;
if(!ObjectCreate(name,OBJ_RECTANGLE,0, Time[100], 1.68505, Time[1], 1.68405, 0, 0))
     {
      Print("Error: failed to create a rectangle! Error code:",GetLastError());
      return(0);
     }  
   }

And I have questions:

1. I want to draw rectangle between say 1.68505 and 1.68405. So I'd have to initialize them as Price1 and Price2?

2. Not understanding the Time[] function. I tried everything from 0 to 100 inside the array but no result.

How these Time functions work? Is it necessary to assign them or I can have any default time value for all the rectangles?

Regards

 
   
ObjectCreate(name,OBJ_RECTANGLE,0, Time[100], 1.68505, Time[1], 1.68405, 0, 0);
ObjectSet(name,OBJPROP_COLOR,Blue) ;
if(!ObjectCreate(name,OBJ_RECTANGLE,0, Time[100], 1.68505, Time[1], 1.68405, 0, 0))
     {
      Print("Error: failed to create a rectangle! Error code:",GetLastError());
      return(0);
     }  

Is the object drawing OK?

if so, your if will return false as the object has already been created.

 
GumRai:

Is the object drawing OK?

if so, your if will return false as the object has already been created.


No, it's not OK, hence getting the Error.
 
Arav007:

No, it's not OK, hence getting the Error.

I suggest that you look in the Objects list and you will see it there. Maybe it has been drawn off screen
 
//--- reset the error value
   ResetLastError();

   string name="New_Rectangualr_object";
   //long chart_ID=ChartID();

   if(ObjectFind(name)==0)
     ObjectDelete(name);
   if(!ObjectCreate(name,OBJ_RECTANGLE,0,Time[100],1.68505,Time[1],1.68405,0,0))
     {
      Print("Error: failed to create a rectangle! Error code:",GetLastError());
      return(0);
     }
   ObjectSet(name,OBJPROP_COLOR,Blue);
Try this
Reason: