Calculate the distance between two parallel lines including ! - page 3

 
Sergey Kolemanov:

You are counting the distance between High and Low , and he has lines

You're talking about parallel lines. And in parallel lines the vertical distance is always the same on any bar. In his example the distance between the lines is(High[10]-Low[10]). You don't need to calculate time for this at all.

You can check it and it will have the same result all the time.

You can find a more general formula here

But since the denominator is very close to 1 even on the minute chart, it can be simplified to:

double R=(Price2-Price1);

It's already said by @Renat Akhtyamov in this post

 
Sergey Kolemanov:
Depending on the angle, the distance will vary... So what is the difference between the lines ? )
 
Itum:
Depending on the angle, the distance will vary... So what is the difference between the lines ? )
Depending on the angle, all the distances will change by multiples, as you have a right-angled triangle. So it doesn't really matter where you measure. Measure what you think is the simplest distance.
 
Renat Akhtyamov:
Depending on the angle, all the distances will change by multiples, as you have a right-angled triangle. So it doesn't matter where you measure at all. Measure what you think is the simplest distance.

Please show me an example.

 ObjectCreate("Line1",OBJ_TRENDBYANGLE,0,Time[0],High[10],Time[10],Low[10]);
   ObjectSetInteger(0,"Line1",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,"Line1",OBJPROP_COLOR,Red);
   ObjectSetInteger(0,"Line1",OBJPROP_WIDTH,2);
   
   ObjectCreate("Line2",OBJ_TRENDBYANGLE,0,Time[10],High[100],Time[20],Low[10]);
   ObjectSetInteger(0,"Line2",OBJPROP_STYLE,STYLE_SOLID);
   ObjectSetInteger(0,"Line2",OBJPROP_COLOR,Lime);
   ObjectSetInteger(0,"Line2",OBJPROP_WIDTH,2);

   ObjectSetDouble(0,"Line1",OBJPROP_ANGLE,260); // 85 
   ObjectSetDouble(0,"Line2",OBJPROP_ANGLE,260); // 85
/*   
   ObjectCreate("Value",OBJ_TREND,0,Time[0],High[10],Time[10],High[10]);
   ObjectSetInteger(0,"Value",OBJPROP_RAY,false);
   ObjectSetInteger(0,"Value",OBJPROP_COLOR,Gold);
   ObjectSetInteger(0,"Value",OBJPROP_WIDTH,3);
   */

// Предлагали сделать так и не помогает !

   double V = (ObjectGetDouble(0, "Line1", OBJPROP_PRICE, 0)-ObjectGetDouble(0, "Line2", OBJPROP_PRICE, 0))/((datetime)ObjectGetInteger(0, "Line1", OBJPROP_TIME, 0)-(datetime)ObjectGetInteger(0, "Line2", OBJPROP_TIME, 0));
   double R = (ObjectGetDouble(0, "Line1", OBJPROP_PRICE, 0)-ObjectGetDouble(0, "Line2", OBJPROP_PRICE, 0))/sqrt(1+V*V) ; 
   
   
   Comment("Разница: R=",R, " | ");

// Предлагали сделать и так и также не помогает !
   
   datetime t1 = (datetime)ObjectGetInteger(0, "Line1", OBJPROP_TIME, 0);
   datetime t2 = (datetime)ObjectGetInteger(0, "Line2", OBJPROP_TIME, 0);
   double p1 = 0;
   double p2 = 0;
   
   if(t1 > t2)
   {
      p1 = ObjectGetValueByTime(0, "Line1", t2);
      p2 = ObjectGetDouble(0, "Line2", OBJPROP_PRICE, 0);
   }
   if(t1 < t2)
   {
      p1 = ObjectGetDouble(0, "Line1", OBJPROP_PRICE, 0);
      p2 = ObjectGetValueByTime(0, "Line2", t1);;
   }
   if(t1 == t2)
   {
      p1 = ObjectGetDouble(0, "Line1", OBJPROP_PRICE, 0);
      p2 = ObjectGetDouble(0, "Line2", OBJPROP_PRICE, 0);
   }
   
   Comment("Разница: " + DoubleToString(MathAbs(p1 - p2) / _Point, 0));
 
Itum:
Depending on the angle and will change the distance ... What is the difference between the lines ? )

You need to find the distance between two parallel lines, and it does not matter how big it is, as long as the value does not change when you change the scale?

Did I get it right? If so, please give me the code that checks the value and it doesn't work with you, because with me it works and the value doesn't change.

 
Itum:

Please show me an example.

double Расстояние=ObjectGetValueByShift("Line1",0)-ObjectGetValueByShift("Line2",0);
That is, if Line1 is at the top and Line2 is at the bottom
 
Renat Akhtyamov:
That is, if Line1 is at the top and Line2 is at the bottom
yes
 
Itum:
yes

Try my line instead of the ones you have below it, if that suits you

// Предлагали сделать так и не помогает !

This will be the length of the blue line:


 

Renat Akhtyamov:

double Расстояние=ObjectGetValueByShift("Line1",0)-ObjectGetValueByShift("Line2",0);

Hmmm... You know, it doesn't help either ) ... You tried running my code from above... It's not the results you want.

Maybe I'm not explaining it right.

 
Renat Akhtyamov:

Try my line instead of the ones you have below it, if it suits you

This will be the length of the blue line:


That's right ... I need the length. the red line. Imagine if these two parallel lines were vertical, what would the blue line show ? (at different angles, will be different length)

If you draw two parallel lines 10 cm apart on a white sheet(Fig.7), this sheet can be twisted any way you like at any angle and there will still be the same 10 cm(Fig.6).