price on slopy trend line at current bar.

 

Hi

How can the price on a slopy trend line be found at the current bar time? 

The lines starts few bars before current bar and extends to the future by few bars after the current bar, the code in mql5. I tried few ways but could not get it, Any suggestins?

Given is 

      //mName is the name of the trend line.
      mT1 = ObjectGetInteger(0, mName, OBJPROP_TIME, 0);        //Time of first point
      mT2 = ObjectGetInteger(0, mName, OBJPROP_TIME, 1);        // of second point

      mP1 = ObjectGetDouble(0, mName, OBJPROP_PRICE, 0);        //Price of first point
      mP2 = ObjectGetDouble(0, mName, OBJPROP_PRICE, 1);        // of second point

Thank you

 
samjesse:

I tried few ways but could not get it, Any suggestins?

How can the price on a slopy trend line be found at the current bar time? 

  1. Do or do not, there is no "tried." Post your code, if you want "suggestins." I suggest you put a spell checker on your browser.
  2. You could compute it (look at the equation of a line.) Or, you could read the manual.
              Line (geometry) - Wikipedia
              Object Functions / ObjectGetValueByTime - Reference on algorithmic/automated trading language for MetaTrader 5
 

How can the number of bars for any given _Period be calculated between two times when the end time is bigger than the the time of the current bar?

ushort barsBetween  = Bars(_Symbol, _Period, mT1, mT2);

ignores mT2 value and instead gives the number of bars between mT1 and the current bar. How can the equation of the line be calculated when one given can not be calculated?


I tried to find the line slop but the line 

mSlop = ObjectGetDouble(0, mName, OBJPROP_ANGLE);

gave 0, any suggestions?


Thank you

 
  1. You still need that spell checker. It is not "slopy," it is not "slop," the word is slope.

  2. samjesse: How can the number of bars for any given _Period be calculated between two times when the end time is bigger than the the time of the current bar?
    Can't be done without assuming that there will be no missing bars. What if there are no ticks during a specific candle period? There can be minutes between ticks during the Asian session, think M1 chart. Larger charts, think weekend, market holiday (country and broker specific.) requires knowledge of when your broker stops and starts (not necessary the same as the market.)
              "Free-of-Holes" Charts - MQL4 Articles
              No candle if open = close ? - MQL4 and MetaTrader 4 - MQL4 programming forum

  3. samjesse: I tried to find the line slop but the line gave 0, any suggestions?
    That call only works for trendByAngle. The slope of a line is change in price divided by change in time. Show us your code, and state the problem.