Parallel trend lines

191

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.

Thanks.

richo.

Moderator
10566

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.

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

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.

15573

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

Thanks a Lot.

25

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
32401

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.