More accurate equity curve with overnight fees deducted

Forums ProRealTime English forum ProOrder support More accurate equity curve with overnight fees deducted

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

    I thought I would share this bit of code. You can add it to the bottom of any strategy that trades on an index and it will calculate a equity curve that takes into account any overnight fees so that our analysis of a strategies actual profit is a little more accurate,

    There are some limitations as the Libor rate used in the calculation of overnight fees changes and we can only use a fixed value – but we have to work with the cards that we are dealt.

    Everything is explained in the code but you will need to change some of the values depending on the time frame of the chart being used.  It does not work on time frames slower than weekly.

    Hopefully someone will find it useful.

    Here is an example of it used on a weekly strategy. It can be seen that the standard equity curve is showing a strategy balance of £65499 and the adjusted for fees curve is showing £60174 balance so over the years we have paid £5325 in overnight fees (had the Libor rate and brokers fees and spread stayed level).

    Screenshot_9

    Please note that I have not tested it on intraday strategies very much as I don’t really trade them any more. If you find a problem please point it out.

    #76968

    I’m surprised that not even GraHal has been along and hoovered this up for the Snippet Library?

    1 user thanked author for this post.
    #77018

    I had some time to test out the above code and realised that it is full of errors and a total pile of poop! Ignore the above code and try this new one that should work properly:

     

    1 user thanked author for this post.
    #90573

    Hi Vonasi,

    just a quick question. For line 17 above – should it be (as below) to factor in pip value/pip size?

    Thanks for the code to copy/play with.

    Cheers

    Finning.

    #90575

    Very possibly but my understanding of the use of PIPVALUE and PIPSIZE is very limited so I am probably not the best person to answer this question. I spread bet with IG and have never found the need to use either instruction in any of my strategies and they have always worked just fine. I know that Roberto uses it a lot so maybe he can be more helpful on this subject.

    #90576

    Hi Vonasi,

    no worries I’ll keep this in mind to check if I migrate to different instruments.

    Cheers,

     

    Finning

    #90579

    No, Countofposition is the number of shares traded and has nothing to do with Pip calculations.

    CLOSE might be used sometimes for this kind of conversion, not in this case, though.

    Moreover you used twice the conversion, which would yield erroneous results.

    PIPVALUE (or PIPSIZE) must be used to convert a number of pips to price by multiplying it by that number, while converting a price into pips requires division.

     

    1 user thanked author for this post.
    #90655

    Hi Roberto,

    I was looking at the same instrument with different contract values (e.g. – and index with $1 or $25 per point), and I wasn’t sure if it was accounted for in the initial formula above.

    I was trying to define pipsize = 1.0 pip/point (an index) and pipvalue = $1.0 per pip/point (a mini contract).

    Just thought you needed a total trade value to apply the fee % to.

    Was looking at this for indexes – https://www.ig.com/au/help-and-support/cfds/fees-and-charges/why-is-overnight-funding-charged-and-how-is-it-calculated-

    And I thought that the Trade size was (number of pips x pip size x value of pips) x (close) x (interest rates/365).

    Cheers,

    Finning

     

    #90663

    Sorry for some confusion on my side, PIPSIZE and POINTSIZE are equivalent and refer to the size of 1 pip (usually 1/10000th for FX pairs), while PIPVALUE and POINTVALUE should be equivalent and refer to the value of each pip, but as you can see from my pic (Dax, h1) this is not always true, so it seems that POINTVALUE is the recommended keyword to use.

    So there was no double multiplication.

    Still CLOSE has to be divided by PipSize to get the correct number of pips, then you correctly multiply that by PointValue and CountOfPosition to get the total value p/Pip of your positions (contracts or shares). The correct formula you posted should read:

    (close / pipsize)                                                 = converts price into Pips

    (Pips * pointvalue)                                          = value of 1 position

    (Value of 1 position * CountofPosition)  = value of all positions

     

    1 user thanked author for this post.
    #90665

    Thank you Roberto – I was nearly there.

    That will be a big help when I’m switching between instruments.

    Cheers,

    Brett

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