Backtest on Contract orders works, but not with full equity

Forums ProRealTime English forum ProOrder support Backtest on Contract orders works, but not with full equity

Viewing 10 posts - 1 through 10 (of 10 total)
  • #128610

    This might seem a simple question, though it has been bothering me for a while now.

    Sometimes, I cannot backtest a strategy for which I’m using full equity instead of a fixed amount of contracts.

    First of all, I define the equity and the capital like this:

     

    And to enter/exit positions I write the following:

     

    Backtesting with equity doesn’t seem to work when I write this, even though it has worked for me in the past.

    Since there is no error in the code of the strategy itself (because when I translate it into contracts it directly works), I figured the mistake must be either in the entries/exits snippet or perhaps a setting in the platform which is causing this.

    I’m pretty new to ProRealTime and really enjoy the software, I’d much appreciate your help.

    #128710

    alex12 – Welcome to the forums.

    There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.

    The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:

    Post your topic in the correct forum.

    ProRealTime Platform Support          only platform related issues.
    ProOrder                                                only strategy topics.
    ProBuilder                                              only indicator topics.
    ProScreener                                           only screener topics
    General Discussion                               any other topics.
    Welcome New Members                      for new forum members to introduce themselves.

    Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
    Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
    Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
    Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
    Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
    Always be polite and courteous to others.
    Have fun.

    I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂

    #128713

    Hi alex12,

    Might I suggest you replace your code with the below and change your buy/sell conditions to say “position” instead of “equity”

     

    #128721

    Thank you for your reply.

    I tried substituting my snippet with your code and used then included “position” into the entry conditions instead of equity.

    However, I am still getting a flat equity curve and no completed trades (same results I got when using the “equity” definition).

    So now my capital section is looking like this:

    And the conditions for entries and exits look like this:

    Is there still something that can be done?

    #128739

    In that case there is something else wrong with your code. If you share the complete code and settings (timeframe and product being traded) we might solve it.

    I’m not used to seeing “cash at market”, more common with “contract at market” but maybe it doesn’t matter.

    #128961

    Here is the code of the strategy:

    (This is the strategy with the “Conditions to close positions” removed since they are not necessary)

    By using your snippet or the one I used previously I get the same error. I’m doing this because my goal is to backtest with full equity which grows as profits grow, that is why I don’t want to use the “CONTRACTS” function.

    I’m backtesting it on the market BTCUSD, on the 1H chart, for a backtesting period of about one year.

    The equity curve I receive when trying this is flat, and no trades are completed. Maybe there is another way to perform a backtest for growing equity?

    #128978

    Works for me. But you cannot have “cash” in your conditions. Change it to “contract”. It will still take larger positions if your equity is increasing. I did the test on Bitcoin Cash $1.

    #129064

    Great! It seems to work now.

    However, is there a way to enter the position, not by the compounded number of contracts but with the cash equity which keeps adding its profits?

    Because using the number of contracts that keep adding might not be as precise as the direct equity plus the profits as cash.

    Perhaps it’s just because I don’t fully understand the logic behind the code snippet you gave me 🙂

    #129070

    Also, there seems to be no difference in the backtest between using “1 contract” and “position contract”.

    #129127

    You cannot use 100% of your capital since the broker requires a margin. The code will automatically take a larger position as long as your equity increases (previous trade is a winner). You can also adjust how big the starting position will be, for example using 50% of initial capital. See the attached image how the code takes a larger position.

    I would not recommend trading Bitcoin because of the extremly high spread. The only one who will win on that product is the broker.

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

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