


The math. images show you x and yvalues in equidistance. The chart does not! If you e.g. take bar by bar you can use 0,1,2,3,... their difference is 1 (similar to the xvalues) but the prices aren't 1,2,3 at all and the differences are some points which means e.g. 0.0010. You have to adjust the scales before you can start to calculate! 

I became aware of that. I figured the functions ChartTimePriceToXY and ChartXYToTimePrice would solve that problem. First converting price and time for both points into X and Y and then convert it back again or simply having the EA being aware of time and price in terms of X and Y.

Hi,
I'm currently having troubles with replicating the equation used by ObjectGetValueByShift. I think I'm having trouble getting the algebra correctly. I've been using this site as a source; https://www.mathsisfun.com/algebra/lineequationpointslope.html , but I can't wrap my head around it.
I have the two points of YY (vertical/price: s1s2) and XX (horizontal/time: st1st2) for calculating the slope like this;
double dateS1=StrToDouble(Time[st1]);
double dateS2=StrToDouble(Time[st2]);
double CurrentT=StrToDouble(Time[0]);
double Slope=(s1s2)/(dateS1dateS2);
As you can imagine subtracting two almost equals returns an infinite number 8.1231241352e008 and I'm not sure if this is the problem.
Further I've tried several different approaches in finding where price would be on my slope at current time.
double s1B = BidTrendSlope*CurrentT;
double s1Current = TrendSlope*CurrentT+s1B;
and
double s1B = s1TrendSlope*dateS1;
double s1Current = TrendSlope*dateS1+s1B;
The reason I need to recreate this equation is due to the fact that graphical objects aren't supported when running optimization, so ObjectGetValueByShift doesn't work.
I'd greatly appreciate any help as I'm kind of new to this. I've only been coding for a couple of weeks and I have been struggling with this for a good 12 hours now...