Help Wanted ! Declaring anchor points in ObjectCreate

 

Hi,

I hope you can help, I have an indicator that I am working on and want to draw a trendline however I am having trouble in where I should declare the anchor points.

Any suggestions would be appreciated..... 

Files:
 
mickeyferrari: I am having trouble
      double Line=ObjectCreate("current_chart_id",OBJ_TREND,0,time1,Price1,time2,price2,0,0);
      :
         TrendLine[i]=Line;
  1. "having trouble " is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
  2. What does ObjectCreate() return?
  3. Why are you trying to create a trendline and have a line buffer?
  4. Once you create an object, you can't create it again; it's not going to move.
 
Great thanks but where would I declare the anchor points?
 
OK I remove the buffer but how would I code it to draw a line from the top of the price bars that close outside the bollinger when i+1 is higher than i
 

I do want the line to be static though is there a way of coding a trend line using the buffer method I use in the program allready?

 

A line - with one and (ray) or with two ends - has to have two points - neither only one point nor a buffer with thousands of points!

A point here is defined by a time and a price look at this example:

bool drawLine(string n, datetime t1, double p1, datetime t2, double p2, color clr=clrDimGray, string dscr="", bool ray=false, double stl=STYLE_SOLID, double wdt=1) {
    if(ObjectFind(n) >= 0) ObjectDelete(n);
    if (!ObjectCreate(n,OBJ_TREND,0,t1,p1, t2, p2) )  return(false);
    bool ok =  ObjectSet(n,OBJPROP_COLOR,clr);
    ok = ok && ObjectSet(n,OBJPROP_STYLE,stl);
    ok = ok && ObjectSet(n, OBJPROP_RAY, ray);
    ok = ok && ObjectSet(n,OBJPROP_WIDTH,wdt);
    ok = ok && ObjectSetText(n,dscr,10);
    return(ok);
}
 
gooly:

A line - with one and (ray) or with two ends - has to have two points - neither only one point nor a buffer with thousands of points!

A point here is defined by a time and a price look at this example:

thanks gooly. May I ask you to clarify where I would place this in the code body (see attached top) and where would I declare the t2 and p2 inputs for these functions?

regards........... 

 

??

It is a function. Place it where ever you want but NOT within another function.

Then in e.g. in OnCalculate() you call this function.

 
Before or after the for loop?
 
Well it depends on your strategy - start experimenting to find out what you want and what you need!
 
thanks gooly will give it a go.............