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)?

Viewing 15 posts - 1 through 15 (of 15 total)
  • #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))).

    #85858

    Vronasi suggested that perhaps Nicolas or juanj know the answer.

    #85860

    Please 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.

    #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?

    #85863

    Anyway 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! 🙂

    #85869

    ProOrder 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.
    #85896

    If you can define the distance in price (Y) between 2 bar coordinates (X), then you can calculate the factor.

    #86165

    Thanks 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?

    #86167

    I 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)

    #87360

    If someone is interested, I did it with a little trigonometry and this seems to work, at least as a screener:

     

     

    #87361

    I’ve got just one short question:

    How can I find/code the lowest low of the last 10 bars, disregarding the last 2 ones?

    #87365

    disregarding the last 2 lowest low? so you want to pick the third one backward?

    #87386

    Exactly, 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. 🙁

    #87390

     

    1 user thanked author for this post.
    #87400

    Thanks a lot!

Viewing 15 posts - 1 through 15 (of 15 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login