How can I code a line (x1,y1,x2,y2)?
Forums › ProRealTime English forum › ProOrder support › How can I code a line (x1,y1,x2,y2)?
- This topic has 14 replies, 5 voices, and was last updated 5 years ago by ligand.
-
-
11/27/2018 at 7:44 PM #85857
Sorry if this is redundant. I don’t succeed to code a line y=mx+n, defined by 4 known parameters x1,y1,x2,y2. My aim ist to code for example a buy order if close crosses under a certain line (which can be described mathematically with y=((y2-y1)/(x2-x1))x + y1-((y2-y1)x1/(x2-x1))).
11/27/2018 at 7:45 PM #8585811/27/2018 at 8:35 PM #85860Please don’t double post.
If you have not received an answer then patience is better than having two topics on the same subject. If you have waited a long time for an answer then maybe it is because no one knows the answer! Sometimes a little polite reminder on the original thread can bump it back to the top and maybe get your answer. Double posting leads to confusion and wasted time for those trying to help.
11/27/2018 at 8:35 PM #85861@ligand … you know you can draw a line on a Chart and set an alert and / or trade if price crosses under / over this line?
I know this is not what you mean, but thought I’d mention it in case you may be able to use the above easy method re prices crossing lines to prove whether your y=mx+c coded strategy is worth pursuing?
11/27/2018 at 8:59 PM #85863Anyway can’t you do something similar (to y=mx+c) by considering …
Price increase > a and < b over c bars represents gradient d Price Line?
Price increase > e and < f over c bars represents gradient g Price Line?
Just an idea going round in my head! 🙂
11/27/2018 at 10:41 PM #85869ProOrder only deals with prices, so you must refence a line (S/R) only by the price it sits on. Line coordinates are used only to draw lines on charts, but cannot be refenced from code.
1 user thanked author for this post.
11/28/2018 at 10:48 AM #8589612/01/2018 at 9:57 PM #86165Thanks for the answers and sorry vronasi – I didn’t know wether I should start an extra question. I won’t do this again.
If you look at the countertrendlines in the chart below you can see the general idea of the system (for example for a bull market):
1. Momentum(EMA20-EMA50)>0 on a higher time frame, so the bull is still developing
2. Define the line between highest(5) and highest(10)
3. Buy if close crosses over this line
4. trailing stop 1.5 x length of the crossing bar.
But if I understand you ok, it is not possible to code for such countertrendlines?
12/01/2018 at 10:01 PM #86167I forgot one criterium:
5. the countertrendline is not to cross the price ranges of any of the bars involved, just the highest points of for example 5 and 10 bars (optimal values have to be defined by backtesting, which is of course also true for the length of the trailing stop)
12/18/2018 at 2:46 PM #87360If someone is interested, I did it with a little trigonometry and this seems to work, at least as a screener:
breakout on crossing a countertrendline123456789101112131415161718192021y1=lowest[25](low)y2=lowest[10](low)For i=25 downto 0 doIF low[i]=y1 thenx1=barindex[i]breakendifnextFor i=10 downto 0 doIF low[i]=y2 thenx2=barindex[i]breakendifnext//Der Punkt auf der Aufwärtslinie wird bestimmt, der vom letzten barclose unterkreuzt werden muss, damit ein Verkaufssignal entstehtx3=barindex[1]y3=y2+((x3-x1)*(y2-y1)/(x2-x1))//Falls close[1] den Punkt y3 auf der Gegentrend-Aufwärtslinie unterkreuzt, gibt es das Verkaufssignalindicator4=close[1] crosses under y312/18/2018 at 2:48 PM #8736112/18/2018 at 3:07 PM #8736512/18/2018 at 5:39 PM #87386Exactly, I’m looking for the lowest value of the seven bars, which precede the third last bar (or in other words: the low of the tenth to third last bar). Itl’s obviously not possible to call it something like lowest[10-3](low). I tried to construct a loop but was unable to do so. 🙁
12/18/2018 at 5:59 PM #8739012/18/2018 at 8:14 PM #87400 -
AuthorPosts
Find exclusive trading pro-tools on