Buy low/high of previous candle not next candle

Forums ProRealTime English forum ProOrder support Buy low/high of previous candle not next candle

Viewing 7 posts - 1 through 7 (of 7 total)
  • #220678

    Hi All, I am new to coding and I searched a lot on the forum to find my solution but i can’t find it.

    Please see the attachments

    What I want to achieve is to program an automatic order so when i have a double bottom of the two previous candles or a double top of the two previous candles that an buy or sell order is excecuted immediately at the low or high from the previous candle and not on the next candle.

    is this possible? If so can someone please assist me with the code?

    Thanx in advance!

    #220689

    What do you mean by EXACTLY?

    Strategies are ALWAYS executed at the closing of the current candle, then the order is executed immediately and you will see an arrow on the next candle as it’s impossible to enter at a prior time (as you will not be able to do manually).

    You could resort to MTF (Multiple Time Frames) support, to use a lower TF, but this won’t help you much in this case, unless you want to consider a DOUBLE BOTTOM when that price level is hit without waiting for it to be confirmed at the closing.

     

    #220699

    Thank you for your fast response.

    I want to enter at the dots, that is what i mean with exactly.

    At that bar I want to look for the low or high form the previous bar and enter the trade. What I have seen is that the order is executed at the next bar, but that is not what I want.

    I hope this clarifies my question better.

    #220711

    You should post the chart with both the setup candle and the entry level highlighted.

    Anyway, you can use pending orders (either STOP or LIMIT, depending on the current price level):

    pending orders are EXECUTED when a bar closes and expire each bar. In case the entry price is hit, they are triggered. They must be placed again and again if needed.

    Additional care for any required distance should be taken.

     

     

    #220717

    Hi there edktrading – I will try to rephrase Roberto’s response;

    What you want is simply not possible.

    Your code is called at the end of each bar. This is thus at the points in time of your blue and green balls respectively. Thus, your code is called when the bar with those balls is formed. These will also be the bars in which you detect the double bottom or double top. And what happens next is : your code detected the double bottom/top, decided to buy on that signal and … had to wait for 15 minutes (TimeFrame of the chart is e.g. 15 minutes) in order to hand the order to the broker.

     

     

    you will see an arrow on the next candle as it’s impossible to enter at a prior time (as you will not be able to do manually).

    This is not entirely explaining what is possible and what is not possible;
    Manually : If I see a double top emerging, then I know before the last bar closes (that is the bar prior to the balls) that this is so. I can place a Market order right before the bar ends or else I can place the order quickly when the new bar started. In both case this will do what edktrading wants to accomplish. If I want, I can of course place a pending (Limit or Stop) order just the same – it’s about the idea of “immediately” placing an order.
    Automatically : This can never work because the situation (double bottom/top) can only be detected in that bar of the ball and next has to wait for handing the order to the broker only when that bar ends. This part is exactly how Roberto poses it.

     

    pending orders are EXECUTED when a bar closes

    This could be confusing, because pending orders are given to the broker or are least are handed to the higher level system when the bar closes. If anything is “executed” it is the forming of position at the Exchange. But this could be vague to all of us, so why the “executed” in capitals I don’t understand (read : I probably miss the point).
    The moral of course is that a pending order too, is given to the (virtual) broker system, again at the end of the bar (and yes, it cancels itself at the end of the next bar, unless the order has been filled underway (we might call this Excuted ? – so vague and confusing).

     

    You could resort to MTF (Multiple Time Frames) support, to use a lower TF, but this won’t help you much in this case, unless you want to consider a DOUBLE BOTTOM when that price level is hit without waiting for it to be confirmed at the closing.

    Apologies for all the “rephrasing”, but I don’t see why this would not work; The confirmation of the closing occurs at the higher level TimeFrame (like 15 minutes) and the buy could occur at the lower level (like 1 minute). You are still 1 minute later than you’d achieve manually, but it is better than 15 minutes late.
    N.b.: Resort to 1 second for the lower level is also possible, but not advisable due to relatively long Backtesting times plus way shorter Backtest periods.

    #220758

    Thank you for making it clearer PeterSt.

    Executed was just a way to tell being placed from triggered.

     

    #220829

    Thank you both for your extensive explanation, it gave me some new insights.

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

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