Defining exit strategy based on profit target

Forums ProRealTime English forum ProOrder support Defining exit strategy based on profit target

Viewing 6 posts - 1 through 6 (of 6 total)
  • #115904

    Hi guys,

    I’m trying to define the exit parameters of my strategy to be the following:

    Exit on the next open if we’ve achieved a close 0.3% higher than the trade bars’ close.

    I’m having trouble with this because a simple take profit won’t do. I’m trying to exit on the next bar once we’ve achieved that 0.3% profit target. Here’s my autogenerated code:

     

    I’ve trying looking in the documentation, but I’ve only been able to define the percent parameter, not the “exit on the next bar once we’ve achieved 0.3% profit” part.

    Let me know what you think,

    Aleks

    #115905

    fixed my syntax, apologies for the spam.

     

    #115911

    AleksLi – Welcome to the forums.

    Please always use the ‘Insert PRT Code’ button when posting code to make it more readable for others. I have tidied up your posts 🙂

    Glad you fixed your own problem however there is an issue in your code.

    You cannot use [-1 ] after CLOSE as it must be a positive integer value. CLOSE[1] is the previous bars close. If you want to compare current price to the price your trade opened at then you need to use TRADEPRICE or POSITIONPRICE. I usually use the latter to avoid any confusion as TRADEPRICE can also be the last price you sold at.

    Also it is simpler just to do the exit price calculation as part of the condition.

     

    1 user thanked author for this post.
    #115921

    Thank you very much for your reply Vonasi!

    One issue I have though- for some reason after inserting the positionprice variable, the backtest doesn’t generate any positions? I’ve tried removing selling rules altogether and it generated a buy signal.

    For reference, here’s my latest code:

    I’ve tried fiddling around with brackets, and that hasn’t helped. I’ve also used other rules to exit positions (like my first attempt) and that generated backtest results.

    #115922

    Sorry – I was coding without thinking too hard about it!

    The problem is that your c2 condition is true when you are not on the market because POSITIONPRICE  = 0 and so this cancels out any buy orders. The addition of an ONMARKET condition should solve the problem.

    Try this (not tested):

     

    #115929

    It worked! Thank you so much for taking the time to look into this. Much appreciated 🙂

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

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