I don't understand exactly the value of PositionPerf

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #54232 quote
    Pere
    Participant
    Veteran

    I am trying to automate a system with ProOrder where it has to do an action if the profit of the trade reaches a value.

    I tried with positionperf and I know that the value of it is given in % of the ratio gain/loss, but I cannot find how it exactly calculates the profit of the trade.

    Let me explain the values I found on different backtests:

    Starting capital: 3000 €

    After strategy worked some candles, I get a total capital of 7097 €, that means a benefit of 4097 €.

    However, PositionPerf gives a value in this point of 0,02783 and I suppose it means 2,783%. Ratio gain/loss should be 4097/3000=1,3656, factor of capitals should be 2,3656 (=1+1,3656).

    Ratio total capital/gain would be 7097/4097=1,7322

    But nothing to do with 0,02783.

    Other values with the same starting capital:

    3738 € -> 0,01772

    3223€ -> 0,00215

    6385 € -> 0,02726

    5767 € -> 0,01332

    4843 € -> 0,02810

    Could somebody explain me the way to calculate PositionPerf, so that I can define correctly the rules of ProOrder?

    Thanks in advance.

    #54234 quote
    JC_Bywan
    Moderator
    Master

    Hi, positionperf gives the performance of the last position, or the previous N-th position if used like this: positionperf(N). You seem to be considering the total of all your positions when you make your comparisons with starting capital, but you need to look at capital just before entering the considered position and performance of the position just after exiting it.

    https://www.prorealcode.com/documentation/positionperf/

    #54235 quote
    Pere
    Participant
    Veteran

    Yes, you are right, but I suppose I’m doing well. I only am referring to the present position, so I wrote PositionPerf which means the same than PositionPerf(0). And the values I gave are all in the same position, so that the starting capital is always the same: 3000 €. Only the gain varies on each candle. I also wrote the instruction GRAPH positionperf in order to see in every moment the value of positionperf. And I also read the definition of the link you gave, but there is no explanation or example on how the calculation is made.  

    #54238 quote
    JC_Bywan
    Moderator
    Master

    ok, gain 4097 from starting 3000, I didn’t think it was the same position all along, I assumed you had several positions opened and closed in between, my bad assumption then. And I need more coffee, haven’t used positionperf for ages as it’s not in my current codes and I’m talking without seeing screen captures of your tests, but wouldn’t it be comparison of levels of the instrument traded rather than comparison of capital levels? (as in, regardless of how much you had to start with, if for example ibex goes up 5% between your long entry and your exit, modified by leverage used, that’s the perf of the position)

    #54239 quote
    Nicolas
    Keymaster
    Master
    PositionPerf returns the performance in price percentage from the open price of the last N order to actual Close, not in money.
    JC_Bywan thanked this post
    #54241 quote
    Pere
    Participant
    Veteran

    Yes, I would also need more coffee today to understand the calculations :-)).

    And yes, the calculations are only to see how much is the gain in the present position in order to increase, for example, the number of buy orders (cumulated).

    #54242 quote
    Pere
    Participant
    Veteran

    I know, @Nicolas, but if you see my first post, I am unable to see how it is calculated, even in %.

    Perhaps you could give me an example to see it.

     

    #54248 quote
    Nicolas
    Keymaster
    Master
    Example of how POSITIONPERF is calculated:
    myMACD = MACD[12,26,9](close)
    long = myMACD crosses over 0
    exit = myMACD crosses under 0
    
    //first order
    IF NOT LongOnMarket AND long THEN
    BUY 1 CONTRACTS AT MARKET
    ENDIF
    
    If LongOnMarket AND exit THEN
    SELL AT MARKET
    ENDIF
    
    graph positionperf coloured(100,236,45)
    graph (close/positionprice)-1
    When ON MARKET , the green line (POSITIONPERF) is the same as the black line which is calculated with (Close/PositionPrice)-1
    JC_Bywan and robertogozzi thanked this post
    #54287 quote
    Pere
    Participant
    Veteran

    Thank you Nicolas.

    But this is only an example of graphing the PositionPerf curve, which I already did. 

    It is not an example of how PositionPerf calculates the profit/loss of the present trade.

    I need to understand how it mathematically calculates the values of this curve regarding the initial capital and/or gain of the trade.

     

    #54290 quote
    Nicolas
    Keymaster
    Master

    You haven’t looked carefully at my code, the PositionPerf is calculated the same way as the second GRAPH instruction I added at line 15:

    graph (close/positionprice)-1

     

    #54319 quote
    Pere
    Participant
    Veteran

    Thanks for your explanations, Nicolas.

    I solved my problem using and graphing the value “floatingprofit” you give in the definition of positionprice, because this is exactly what I need to know to take my decisions.

    Thank you again!

    #82529 quote
    simeong
    Participant
    Average
    Hi, Just a quick question. So positionperf(0) wil tell you profit/loss of the order that is currently open and positionperf(1) will tell you the profit/loss of the last order to close I just wanted to confirm that this is correct ? Kind Regards,
    #82537 quote
    Nicolas
    Keymaster
    Master
    That’s right, it gives the current running positions performance in percentage.
    graph positionperf(0)
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.

I don't understand exactly the value of PositionPerf


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Pere @petrus Participant
Summary

This topic contains 12 replies,
has 4 voices, and was last updated by Nicolas
7 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 11/28/2017
Status: Active
Attachments: 1 files
Logo Logo
Loading...