How To Open Position Based On TrendLine

To add comments, please log in or register
Jo_NewbieFx
74
Jo_NewbieFx  

Dear all,
If we draw a trend line, and then want to open a position when the market price crosses the line, is it posible?

If it's possible, is there someone can help how big picture of the algorithm. Thank you very much.

Simon Gniadkowski
17274
Simon Gniadkowski  
Jo_NewbieFx:

Dear all,
If we draw a trend line, and then want to open a position when the market price crosses the line, is it posible?

If it's possible, is there someone can help how big picture of the algorithm. Thank you very much.

If you are checking to see if the TL is crossed on the current bar you need to know the price of the TL for the time of the current bar, you can either calculate this by doing a simple linear regression . . . or use this function:  ObjectGetValueByShift()
Jo_NewbieFx
74
Jo_NewbieFx  
RaptorUK:
If you are checking to see if the TL is crossed on the current bar you need to know the price of the TL for the time of the current bar, you can either calculate this by doing a simple linear regression . . . or use this function:  ObjectGetValueByShift()


Thank You RaptorUK.

I will try it. 

William Roeder
22460
William Roeder  
Jo_NewbieFx:


If we draw a trend line, and then want to open a position when the market price crosses the line, is it posible?

If it's possible, is there someone can help how big picture of the algorithm. Thank you very much.

  1. Loop through all objects and find the trend line name the user created, or have the EA create a named trendline that the user moved.
  2. Get value by shift and compare to price, or get shift by value and verify that the shift is inside the trendline start to end.
Jo_NewbieFx
74
Jo_NewbieFx  
WHRoeder:
  1. Loop through all objects and find the trend line name the user created, or have the EA create a named trendline that the user moved.
  2. Get value by shift and compare to price, or get shift by value and verify that the shift is inside the trendline start to end.

Thank you Mr. WHRoeder and Mr RaptorUK for your attention

I have another question
To draw the best Trend line based on Price Bar in a period, is there a standard function for do it ?

If there is no standard function for doing  it, is it possible to calculate the gradient line first, and then draw the best line using ObjectCreate_OBJ_TRENDBYANGLE ?

Or, is there another method that is often used to solve problems like this ?

Is there someone who can help me ?

Thank you very much.
 

phi nuts
2092
phi nuts  
Jo_NewbieFx:

Dear all,
If we draw a trend line, and then want to open a position when the market price crosses the line, is it posible?

If it's possible, is there someone can help how big picture of the algorithm. Thank you very much.

There's plenty in code base for example here https://www.mql5.com/en/code you have to modify it or look for another one in code base though.
Simon Gniadkowski
17274
Simon Gniadkowski  
Jo_NewbieFx:

Thank you Mr. WHRoeder and Mr RaptorUK for your attention

I have another question
To draw the best Trend line based on Price Bar in a period, is there a standard function for do it ?

If there is no standard function for doing  it, is it possible to calculate the gradient line first, and then draw the best line using ObjectCreate_OBJ_TRENDBYANGLE ?

You have to decide for yourself where your Trend Line should go . . .  ask 10 people and you will probably get at least 5 different opinions.  Angles have no meaning in MT4,  one dimension is price the other is time,  they are not equivalent.  Just determine where your Trend Line should be and draw it using an Trend Line object.
To add comments, please log in or register