Selling after X days

Forums ProRealTime English forum ProOrder support Selling after X days

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

    Hello,

    My objective is to set a stop loss which equals the buying price – 1,5*Average Daily Range and a profit target which equals the buying price + 3*Average Daily Range.

    I’m considering an Average Daily Range of 7 trading days.

    1 candle = 1 trading day

    I also want to sell at stop if the opening price equals the closing price, or if nothing happened after 20 days.

    This is my code

    I don’t know if the above code will do exactly what I expect. Also, I don’t know how to code “If nothing happens, sell at limit after 20 days”.

    Can anybody help with this one? Thanks!

    Frank

     

     

     

    #130192

    Have you read through all the instruction documentation that can be found here?

    https://www.prorealcode.com/prorealtime-documentation/

    STOP and LIMIT orders are pending orders that you place on the market at each bar to do something at an inferior price or at a better price so you are using them all wrong.

    If you calculate your take profit and stop loss levels then you can simply do this:

    Obviously the sl and tp values will be updated at every new bar so if you want them fixed then set them at the time of entering the market and include them with in a IF NOT ONMARKET condition.

    Selling after 20 days is easy. Selling if close equals open is also easy but I can’t imagine this happens very often on a daily chart.

     

    1 user thanked author for this post.
    #130201

    Hi Vonasi,

    Thank you very much for the link to the online documentation, I only had the PDF version, this is very handy.

    I’m still in doubt with one part of the code. I confirm that I do want to keep the stop loss and the take profit fixed, but it’s still not clear to me how to do it, when you say “set them at the time of entering the market and include them with in a IF NOT ONMARKET condition”, How am I supposed to change the code to make that happen?

    Many thanks in advance.

    Frank

     

     

     

    #130214

     

    1 user thanked author for this post.
    #130241

    Thank you very much! I stll have one more question (I’m learning…). I’ve tried to incorporate the “not onmarket” condition in the buy conditions rather than in a separate one, and I’m getting different results. I don’t understand why, and which of the 2 cases would be more appropriate for my objective:

    Could you please shed a light on this one? I’m surely missing something here.

     

     

     

     

     

     

    Frank

     

    #130268

    All conditions are checked at the close of a bar. So if you are on market at the close of that bar then that condition is true even if you place an order to close a trade. That stops an entry on the next bar or stops the orders cancelling each other out.

    Use DEFPARAM CUMULATEORDERS = FALSE at the top of your first code shown in your last post and that will only ever have one position open at a time but not miss alternate bars due to the ONMARKET condition.

    1 user thanked author for this post.
    #130271

    Many thanks!

    Frank

     

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