Help with an exit code

Forums ProRealTime English forum ProOrder support Help with an exit code

Viewing 3 posts - 1 through 3 (of 3 total)
  • #103299

    Hi,

    I am new to this code language, in fact new to trading.

    I need help with a code for an exit strategy. I want my strategy to exit the trade either the first period it is profitable or at the latest five periods after entry. Can someone help my with the proper code for that?

    Also, I want trades to enter on the closing price of the bar rather than on the opening price of the next bar. Any help possible with that?

    Thanks/ Yfront

     

    #103302

    The last question is NO, strategies are only executed when a candle closes and, if any order is placed at market, it will be at the current price. Usually the closing price of a candle is the opening price of the next candle, but in case of market closures there can be gaps (if you place an order at market on the closing of Friday, it will be entered at the price when the new week opens).

    The only workaround is tu use the Multi Time Frame (MTF) support so that, say you are using a Daily candle for your setup, you can resort to the 1-minute TF to place an order at the closing of the candle 1 minute before the daily (or whatever else) candle closes. The only drawback is that the lowest TF is the one that sets the pace and the one you need to have on your chart, thus greatly reducing the data history available for your backtests. A Daily chart allows you to have several years of data history, while 1-minute chart just a bit over 3 months with 100K bars (twice as much with 200K bars). Luckily this will greatly be improved when the new v11 will be supported by IG (rumors report next fall as most likely), since it will offer 1M (million) bars of data history (and more if used in time chunks).

    As to your first question, this is the code (not tested):

     

     

    #103305

    Welcome to the forums yfront. I have moved your topic to the ProOrder forum as it is automated strategy related and not a general discussion topic which is where you posted it. Please try to post in the most relevant forum with future topics.

    Note: You might want to change TRADEPRICE to POSITIONPRICE in Roberto’s code if you have accumulating positions in your strategy.

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

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