How to get time and price coordinate on a chart? - page 2

 

No I need to get into my code for auto trading.

Can I read that trendline into my code?

 
nyanmt4 #:

No I need to get into my code for auto trading.

Can I read that trendline into my code?

Yes , do you have a screenshot of that trendline ?

Or you want the trendline of the last 10 candles ?

 

No what I want is I need to determine the slope of the trendline.

Like in this discussion.

How to get the angle of a trendline and place a text object to it?
How to get the angle of a trendline and place a text object to it?
  • 2017.12.03
  • www.mql5.com
Hi coders, this indicator prints a text object as soon as a trendline is drawn...
 
nyanmt4 #:

No what I want is I need to determine the slope of the trendline.

Like in this discussion.

And the trendline name is "angle" on the chart ?

 

No from my program, I'll calculate slope of current price trend. Slope is steep, it is trending, so I'll consider to trade.

If slope is not steep, I won't enter trade.

 
nyanmt4 #:

No from my program, I'll calculate slope of current price trend. Slope is steep, it is trending, so I'll consider to trade.

If slope is not steep, I won't enter trade.

Im sorry i'm confused . 

Here is an example that get's the price and times of a trendline object , if you don't mean that let me know.

Put it on experts , put it on a chart , draw a trendline object and look at the experts log.

int OnInit()
  {

  return(INIT_SUCCEEDED);
  }

void OnTick()
  {

  }

void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam)
  {
  //if new object 
    if(id==CHARTEVENT_OBJECT_DRAG)
      {
      //and it is a trendline 
        if(ObjectGetInteger(ChartID(),sparam,OBJPROP_TYPE)==OBJ_TREND){
        //grab its prices 
          //the name is in sparam variable 
            double price1=0.0,price2=0.0;
            datetime time1=0.0,time2=0.0;
            price1=(double)ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,0);
            price2=(double)ObjectGetDouble(ChartID(),sparam,OBJPROP_PRICE,1);
            time1=(datetime)ObjectGetInteger(ChartID(),sparam,OBJPROP_TIME,0);
            time2=(datetime)ObjectGetInteger(ChartID(),sparam,OBJPROP_TIME,1);
            Print("1("+DoubleToString(price1,_Digits)+"),("+TimeToString(time1,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+")");
            Print("2("+DoubleToString(price2,_Digits)+"),("+TimeToString(time2,TIME_DATE|TIME_MINUTES|TIME_SECONDS)+")");
        }
      }
  }
 
  1. nyanmt4 #: No I am going to compute trend angle.
    Can't be done.
    1. There is no angle from 2 anchor points. An angle requires distance divided by distance; a unit-less number. A chart has price and time. What is the angle of going 30 miles in 45 minutes? Meaningless!

    2. You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the price scale, bar width, or window size, changes the apparent angle, the slope is constant. Angle is meaningless.

    3. You can create an angled line using one point and setting the angle (Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference.) The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle (and thus is meaningless.)

    4. If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
                How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 programming forum - Page 2

  2. Lorentzos Roussos #: What type of an object is the "angle"
    nyanmt4 #: angle is double
          time1 = (datetime)ObjectGetInteger(0, "angle", OBJPROP_TIME,1);
    
          price1 = ObjectGetDouble(0, "angle", OBJPROP_PRICE,1);

    If it is a double, there is no price and time, only a value, and trying to read from an object is nonsense. Now answer the question.

 
William Roeder #:
Can't be done.
  1. There is no angle from 2 anchor points. An angle requires distance divided by distance; a unit-less number. A chart has price and time. What is the angle of going 30 miles in 45 minutes? Meaningless!

  2. You can get the slope from a trendline: m=ΔPrice÷ΔTime. Changing the price scale, bar width, or window size, changes the apparent angle, the slope is constant. Angle is meaningless.

  3. You can create an angled line using one point and setting the angle (Object Properties - Objects Constants - Standard Constants, Enumerations and Structures - MQL4 Reference.) The line is drawn that angle in pixels. Changing the axes scales does NOT change the angle (and thus is meaningless.)

  4. If you insist, take the two price/time coordinates, convert them to pixel coordinates and then to apparent angle with arctan.
              How to get the angle of a trendline and place a text object to it? - Trend Indicators - MQL4 programming forum - Page 2

well in theory he/she could get how much atr prior point 1 each bar moves the price by ,with dropping the time calculation though and only going by bars distance from p1.

Then she/he could try and teach the ea what those figures mean since it would be moved out of the "what i see as a human" spectrum
Reason: