Download MetaTrader 5
To add comments, please log in or register
Do you know that MQL5 can create custom graphical tools?
richo
191
richo 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.

Keith Watford
Moderator
7958
Keith Watford 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.

richo
191
richo 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.

whroeder1
13627
whroeder1 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;
richo
191
richo 2014.03.01 14:09  

Thanks a Lot.

BILT nicolae
25
BILT nicolae 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 !

Alain Verleyen
Moderator
28627
Alain Verleyen 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