Average on equity

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #9562 quote
    Andrea Tironi
    Participant
    Junior

    Hi.

    There’s a way to have average on equity line inside a trading system code?

    Thanks.

    Andrea

    #9563 quote
    Nicolas
    Keymaster
    Master

    Of course, you can add any value arrays in AVERAGE function. Just compute your equity variable and average it on n periods.

    #9564 quote
    Andrea Tironi
    Participant
    Junior

    Thanks.

     

    How can i compute my equity variabile?

    #9567 quote
    Nicolas
    Keymaster
    Master
    myequity = (((close-positionprice)*pointvalue)*countofposition)/pipsize + strategyprofit
    
    avg = average[20](myequity)
    #9569 quote
    Andrea Tironi
    Participant
    Junior

    Thanks

    #14917 quote
    oiprcrt
    Participant
    Junior

    Hi

    Thank you for the code. What I have to do if I want that the strategy only trade if the equity curve is above the moving average (of the Equity curve)?  I tried it with this one but it doesn`t work:

    myequity = (((close-positionprice)*pointvalue)*countofposition)/pipsize + strategyprofit
    avg = average[20](myequity)
    
    IF NOT OnMarket AND l10 AND l20 AND (strategyprofit > avg) THEN
    BUY 1 CONTRACTS AT MARKET NEXTBAROPEN
    ENDIF
    #14932 quote
    oiprcrt
    Participant
    Junior

    I’m sorry, I forgot something important. It’s more complicated than I thought. I have inserted a picture to illustrate it.

    If the equity curve is above the MA, then the system trades (it`s online).  If the equity curve is below the MA then the system must be offline. The problem is, however, that the strategy have to make “fictitious order” (without really buying contracts) so you can get back in the system as soon as the strategy is again over the MA. Hope you understand what I mean.

    #16544 quote
    Daniel da Costa
    Participant
    Average

    Hi, did you work a way around this problem?

    #16551 quote
    Andrea Tironi
    Participant
    Junior

    No :(((

    #16558 quote
    Nicolas
    Keymaster
    Master

    I did not test the code Skubidu made, but from my own experience, trading the equity curve is a dead-end. I used to make a lot of tries and experimentation on this on other trading software languages, with fictitious orders but the result is almost always the same :

    1. you miss a lot of good trades, your strategy is “broken”..
    2. even if a fictitious trade made good gain for the equity curve to be above the average, the next trade could a looser and same thing happen again: you need to make new fictitious trade, etc.

    It results at the end that your strategy is not a looser one, but not a winner one. The equity curve of the overall strategy backtest is almost like a flat line.

    However, this is something very interesting for educational purpose, I may write something about it in the blog.

    #16881 quote
    Nicolas
    Keymaster
    Master

    For your information, Wisko have solved the problem of not displaying correctly the equity curve for the IG accounts users, you can have a look it here:

    http://www.prorealcode.com/blog/trading-strategy-profit-curve/#comment-2189

    Here is the full code he get from PRT to fix this issue:

    if not onmarket then
    mystrategyprofit=strategyprofit
    elsif longonmarket then
    mystrategyprofit=strategyprofit+(close-tradeprice)/pointsize*pointvalue*countoflongshares
    elsif shortonmarket then
    mystrategyprofit=strategyprofit+(tradeprice-close)/pointsize*pointvalue*countofshortshares
    endif
    
    equitycurve = exponentialaverage[a](mystrategyprofit)
    
    GRAPH mystrategyprofit as "strategy profit"
    GRAPH equitycurve coloured(255,0,0) as "profit curve"

    Hope it helps here too 🙂

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Average on equity


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 10 replies,
has 4 voices, and was last updated by Nicolas
9 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/19/2016
Status: Active
Attachments: No files
Logo Logo
Loading...