Help to calculate the slope of a line that is Perpendicular to a known line

 

I want to calculate the slope of a line that is Perpendicular to a known line:


Line A is Perpendicular to line B;

Slope of Line A: SlopeA = (Price1-Price2)/(bar2-bar1);

Because Line A is vertical to line B, So:

SlopeA*SlopeB = -1;

Therefore: SlopeB = - 1/SlopeA = - (bar2-bar1)/(Price1-Price2);

furthermore, the priceX on line B at bar X should be: price X = aknownpriceonlineB + SlopeB*barX

BUT, when I put this into my indicator, it will never work!


What's wrong here? Could anybody help please?


Thanks,


Jean

 
IMHO it is a monkey business. Each monitor performs another angle. So search for proportions between pips and time of bars.
 
MontS:

I want to calculate the slope of a line that is Perpendicular to a known line:


Line A is Perpendicular to line B;

Slope of Line A: SlopeA = (Price1-Price2)/(bar2-bar1);

Because Line A is vertical to line B, So:

SlopeA*SlopeB = -1;

Therefore: SlopeB = - 1/SlopeA = - (bar2-bar1)/(Price1-Price2);

furthermore, the priceX on line B at bar X should be: price X = aknownpriceonlineB + SlopeB*barX

BUT, when I put this into my indicator, it will never work!


What's wrong here? Could anybody help please?


Thanks,


Jean

i don't understand this: I want to calculate the slope of a line that is Perpendicular to a known line

 
c0d3:

i don't understand this: I want to calculate the slope of a line that is Perpendicular to a known line

slope of a perpendicular is 90 degrees?

 
slope of a perpendicular line is infinite not zero. this is the reason.
 
arshad12343:
slope of a perpendicular line is infinite not zero. this is the reason.

NO, What I meant is that two lines, one is perpendicular to the other, in another word, the angle between this two lines is 90 degree.

 
Roger:
IMHO it is a monkey business. Each monitor performs another angle. So search for proportions between pips and time of bars.

This is NOT for view on the screen, this is for calculation in an indicator.

 

consider use of very good search box at top right all site pages.

you will [if patient] end up with results containing some very enlightened comments related to this area.

enjoy

 
MontS wrote >>

I want to calculate the slope of a line that is Perpendicular to a known line:

Line A is Perpendicular to line B;

Slope of Line A: SlopeA = (Price1-Price2)/(bar2-bar1);

Because Line A is vertical to line B, So:

SlopeA*SlopeB = -1;

Therefore: SlopeB = - 1/SlopeA = - (bar2-bar1)/(Price1-Price2);

furthermore, the priceX on line B at bar X should be: price X = aknownpriceonlineB + SlopeB*barX

BUT, when I put this into my indicator, it will never work!

What's wrong here? Could anybody help please?

Thanks,

Jean

Jean,

I think your problem is in the calculation of the original slope. It should be SlopeA=(y1-y2)/(x1-x2) -----> SlopeA=(Price1-Price2)/(bar1-bar2). I presume that you are using the time of each bar to calculate?

So, the slope of the perpendicular line would be SlopeB = - (1/SlopeA) = - (bar1-bar2)/(Price1-Price2)

And thus, the equation for (Bar,Price) on the perpendicular line through the point (KnownBar,KnownPrice) is: y = m (x - a) + b ==> Price = SlopeB * (Bar - KnownBar) + KnownPrice

Hope this helps.

- Tovan

 
tovan:

Jean,

I think your problem is in the calculation of the original slope. It should be SlopeA=(y1-y2)/(x1-x2) -----> SlopeA=(Price1-Price2)/(bar1-bar2). I presume that you are using the time of each bar to calculate?

So, the slope of the perpendicular line would be SlopeB = - (1/SlopeA) = - (bar1-bar2)/(Price1-Price2)

And thus, the equation for (Bar,Price) on the perpendicular line through the point (KnownBar,KnownPrice) is: y = m (x - a) + b ==> Price = SlopeB * (Bar - KnownBar) + KnownPrice

Hope this helps.

- Tovan

Yes, thank you for given in detail.


Jean

 
tovan:

Jean,

I think your problem is in the calculation of the original slope. It should be SlopeA=(y1-y2)/(x1-x2) -----> SlopeA=(Price1-Price2)/(bar1-bar2). I presume that you are using the time of each bar to calculate?

So, the slope of the perpendicular line would be SlopeB = - (1/SlopeA) = - (bar1-bar2)/(Price1-Price2)

And thus, the equation for (Bar,Price) on the perpendicular line through the point (KnownBar,KnownPrice) is: y = m (x - a) + b ==> Price = SlopeB * (Bar - KnownBar) + KnownPrice

Hope this helps.

- Tovan

I figured out that in order for the condition SlopeB = - (1/SlopeA) become true, we need to put a conversion factor for the price. For the x-axis we use the number of bars, for the y-axis we use price, BUT, we have to define the unit of price, only when price/bar = 1, then we are in proportion, only in this condition we can calculate angle between two lines, so, the introduction of a conversion facotr is necessary, so, the operation should be: IF SlopeB = - (1/SlopeA) = - (bar1-bar2)/(Price1-Price2)*conversionfactor; THEN Price = SlopeB * (Bar - KnownBar) + KnownPrice will be TRUE, How to calculate or accomplish this?

HELP please!


Jean