Download MetaTrader 5
To add comments, please log in or register
Sell products via the Market and track your sales statistics
Lime
640
Lime 2016.02.19 14:50 

Hi Coders,

I would like to know the position of the Bid price relative to the TRIANGLE object. Whether is it inside a TRIANGLE or not?

Do you have a simple idea for it?

Thank you in advance.

Relative

whroeder1
13641
whroeder1 2016.02.19 20:18  
Relative: Bid price relative to the TRIANGLE object. Whether is it inside a TRIANGLE or not?
  1. Get the three prices from the triangle. ObjectGet - MQL4 Documentation
  2. Find the highest and lowest.
  3. Compare them to Bid.
Was that so hard?
Lime
640
Lime 2016.02.19 20:50  
WHRoeder:
Relative: Bid price relative to the TRIANGLE object. Whether is it inside a TRIANGLE or not?
  1. Get the three prices from the triangle. ObjectGet - MQL4 Documentation
  2. Find the highest and lowest.
  3. Compare them to Bid.
Was that so hard?

I can't interpret your 1-3 points. The triangle is not a simple line. For example it can be located in the so far past too. I have to work with the price and with the time too (x, y coordinates).

Anyway, I linked a solution earlier. I just realised, somebody deleted.
Lime
640
Lime 2016.02.19 20:55  

Solution:

Given three corner points of a triangle, and one more point P. Write a function to check whether P lies within the triangle or not. For example, consider the following program, the function should return true for P(10, 15) and false for P'(30, 15)

Triangle

Let the coordinates of three corners be (x1, y1), (x2, y2) and (x3, y3). And coordinates of the given point P be (x, y)

1) Calculate area of the given triangle, i.e., area of the triangle ABC in the above diagram. Area A = [ x1(y2 – y3) + x2(y3 – y1) + x3(y1-y2)]/2
2) Calculate area of the triangle PAB. We can use the same formula for this. Let this area be A1.
3) Calculate area of the triangle PBC. Let this area be A2.
4) Calculate area of the triangle PAC. Let this area be A3.
5) If P lies inside the triangle, then A1 + A2 + A3 must be equal to A.

Keith Watford
Moderator
7982
Keith Watford 2016.02.19 21:21  

WHRoeder gave the only solution possible.

Bid price only has 1 coordinate, so cannot be used as the coordinates for the corner of a triangle

Lime
640
Lime 2016.02.19 21:49  
GumRai:

Bid price only has 1 coordinate, so cannot be used as the coordinates for the corner of a triangle

The time (or number of bars) is the X coordinate.
Keith Watford
Moderator
7982
Keith Watford 2016.02.19 22:31  
Relative:
The time (or number of bars) is the X coordinate.

Oh, I see.

Normally when you refer to Bid price it is the current price which is shown as an horizontal line across the chart.

On historical bars you would usually refer to Open, High, Low and/or Close.

Lime
640
Lime 2016.02.19 22:37  
GumRai:

Normally when you refer to Bid price it is the current price which is shown as an horizontal line across the chart.

On historical bars you would usually refer to Open, High, Low and/or Close.

X coordinate: Bars-shift (0 is the last bar, then 1, 2, 3...)

Y coordinate: Price (any price)

Acutla bid price coordinates can be for example: X:0, Y:1.12345

/
To add comments, please log in or register