# Parallel trend lines

To add comments, please log in or register
191
2014.02.27 11:45

Hi

Is there any formula for finding whether two trend lines are parallel? I am finding the slope of first trend line and matching with the other, but it is not accurate.

Any other guidelines please.

Thanks.

richo.

Moderator
9640
2014.02.27 12:12
richo:

Hi

Is there any formula for finding whether two trend lines are parallel? I am finding the slope of first trend line and matching with the other, but it is not accurate.

Any other guidelines please.

Thanks.

richo.

I would think that it is quite rare to find 2 trendlines truly parallel unless they have been drawn that way on purpose.

Find the TL that spans the shortest length of time, find the difference in price between the start and the end,

Check that the other trendline moves bythr same amount pricewise in the same timespan. Then they are parallel. But I think that you would have to allow a bit of margin.

191
2014.02.27 12:25
GumRai:

I would think that it is quite rare to find 2 trendlines truly parallel unless they have been drawn that way on purpose.

Find the TL that spans the shortest length of time, find the difference in price between the start and the end,

Check that the other trendline moves bythr same amount pricewise in the same timespan. Then they are parallel. But I think that you would have to allow a bit of margin.

Hi GumRai

Thanks. I am working on it, as you said we have to allow deviation plus or minus some points.

14751
2014.02.27 16:42
richo: Is there any formula for finding whether two trend lines are parallel? I am finding the slope of first trend line and matching with the other, but it is not accurate.
Not "accurate" because you can't compare doubles for equality The == operand. - MQL4 forum
```double slope1 = ...,
slope2 = ...,
epsilon = MathMax( MathAbs(slope1), MathAbs(slope2) ) * 0.001;
bool   parallel = MathAbs(slope1 - slope2) < epsilon;```
191
2014.03.01 14:09

Thanks a Lot.

25
2014.03.01 18:42

I think is bettter ...

follow:

//+------------------------------------------------------------------+

//| right comparison of 2 doubles |

//+------------------------------------------------------------------+

//--- normalize difference between expression1 : expression2 : expression..n

double true_diff = (expression1==expression2)?0:(expression1-expression 2)/(expression2-expression1);

I wrong ?!

....

Thanks !

Moderator
31159
2014.03.01 19:55
ebilt10:

I think is bettter ...

follow:

//+------------------------------------------------------------------+

//| right comparison of 2 doubles |

//+------------------------------------------------------------------+

//--- normalize difference between expression1 : expression2 : expression..n

double true_diff = (expression1==expression2)?0:(expression1-expression 2)/(expression2-expression1);

I wrong ?!

....

Thanks !

Hello,

Please use the SRC button when you post code. Thank you.

To add comments, please log in or register