Trading the strategy profit curve

 

There are a billions ways to adapt your risk exposure while trading. Another approach is to base our trades triggers on recent performance of the strategy by using the strategy profit curve like any other technical indicator. ProBuilder language offers this possibility.

What is the strategy profit curve ?

The instruction ‘strategyprofit’ is present in the ProBuilder language. It returns the profit of the automated trading strategy you actually trade. Like any other variable it can be use to manage trading triggers with specific conditions based on it.

A perfect trading strategy would return a perfect profit curve, like this one :

strategy profit graph curve

Of course, it is irrelevant as it would reflect a strategy that always win or never cut a loss.

Using the strategy profit curve, built in ProRealTime, can almost achieve this possibility, not to make a strategy perfect, but the capability to make your profit curve look more straight than it could be without using this trick.

Let have a look of what is the strategy profit look like in ProBacktest, using the GRAPH instruction i introduced in a recent other blog article.

I’m using a simple golden cross long only strategy on S&P500 :

Adding the GRAPH instruction at the end of the code, to reflect the profit as a variable :

Return the stair steps of our profit over time :

equity curve trading graph

Use strategyprofit variable as a trigger

While our strategy may have a nice decent profit, its curve is not so straight and may create doubt in its reliability over time. We know that the strategy is profitable on long term, because we also have a clear view of the past by now, but we also know by now that market conditions may minimize its profitability sometimes.

Sometimes, our strategy profit is declining, we can avoid long runs of profit disappearance by triggering our entries with the strategyprofit curve.

This curve can act as any other technical indicators to make market entries decisions. A simple way to open trades or not is to add a classical moving average to the curve and using it as a trigger.

Passing strategyprofit values into a simple moving average :

give us a more clear view of the profit over time :

curving the strategy profit over time

We can see here that a crossover of the profit of the strategy crossing its average may be a good trigger to :

  1. stop using the strategy while the profit is under the average
  2. trading the strategy while the profit is still over the average profit over time

 

Equity curve trading

Here is the entire code of the strategy within the triggers :

and here is the strategy profit returns by ProBacktest :

equity curve trading with triggersSo, here is the deal : we have a better straight profit curve, but we may have also not trade for a long period and miss a lot of good trades while the strategy profit were under its average. There is nothing perfect, but the strategy well perform most of the times.

Here is a profit curve comparison :

equity-curve-comparaison

Because the average will never drop below the actual profit of the strategy, we need to trigger its activation when the average is equal to profit. This will lead to trade once and get back to non trade period if this trade is not a profitable one. In fact, this behaviour can be a strategy killer, it can results in slow profit drain if there are a lot of bad trades in the same row. This is the main con of this trading trick, but there are many more ways to deal with the strategyprofit curve, this article deal with the main idea behind it and i’m gonna talk again in future blog’s posts, i guess !

Many more ways to deal with the strategyprofit curve

Here are some ideas, that be can explored by this technique :

  • trades volumes sized adapted to the equity curve values (more volumes or less when you are below/above it)
  • use standard deviation of your strategy profit : when profit derivate more than 2% from its average, stop trading or adapt strategy
  • rebalancing strategy on other instrument
  • … your ideas !

I’ll appreciate discuss more about this with any one, please feel free to comment and share your ideas about it ! Thanks in advance.

 

Share this

  1. Stef • 01/13/2016 #

    Hi Nicolas,
    What version of the software are you using/in which version(s) of the software is this supposed to work?
    In my case, the moving average is not calculated/displayed correctly. It is just displayed on top of the strategyprofit line.
    I am using PRT through IG Markets.
    Regards
    Stef

    • Nicolas • 01/13/2016 #

      Hello Stef, when I wrote this article there were no possibility to do it correctly with IG datas. My own tests were made with Prorealtime Software 10.2.  I know there are some differences between the kernel versions, even if they got the same version number though.. Also if you do not have a lot of trades, the moving average will be almost flat, so you have to adapt the MA period to the trades quantity already closed. Let me know if I can be of any assistance further more.

    • Matt • 01/13/2016 #

      Hi Stef, The moving average plots based on the number of bars in the time period, rather than the number of trades you have taken in that time.So for example, if your algo takes 1 trade per day on a 5min chart, then anything less than 288 SMA is going to look like PRT is just plotting on top of your strategy profit line.I haven’t coded this in to know whether it works for exiting strategies yet, but I use it to manually compare (and know when to switch off) algos.For the sake of comparing apples with oranges, I use 5,760 SMA on 5min charts, 1,920 SMA on 15min charts, 120 SMA on 4hr charts… these examples all basically the previous 20 trading days average of my strategy profit line.Let me know if this works for an auto exit! I’m very interested… in the meantime its a good visual to see how your strategy profit is doing.

  2. auvergnat • 01/13/2016 #

    Bonsoir Nicolas
    Existe un moyen de coder un reset quotidien de la variable strategycurve afin qu’elle soit à 0 lors de chaque nouvelle journée de trading (j ai un flatafter.. chaque fin de journée) ?
    Merci par avance
    Tof

    • Nicolas • 01/13/2016 #

      Oui c’est possible en faisant ceci:
      if intradaybarindex = 0 then
      equitycurve = 0
      endif
       

  3. Cosmic1 • 01/13/2016 #

    Hi Nicolas, I was looking forward to testing and using this feature but have found the same thing using IG/PRT and also the other way round by using the affiliated link through PRT that gives 200k of data. Hopefully they will fix this soon.

  4. Madrosat • 01/13/2016 #

    Bonjour Nicolas
    En essayant d’appliquer  ” trading the strategy profit curve”  sur une de mes stratégies
    le graph ne retourne pas la moyenne mais uniquement la courbe profit;
    J’ai donc recopié ton code et réessayé avec ton code intégral pareil pas d’apparition de la moyenne en rouge??
    Cependant quand ça va bien fonctionner ça me parait être intéressant
    ce qui serait également très intéressant c’est qu’on puisse utiliser le procreener pour
    détecter  des phases pertinentes d’entrée ou de sortie.
    Cela sera t il possible???
    Bonne journée
    Madrosat
     

  5. Wisko • 01/13/2016 #

    Hey guys,
    with the help of PRT programmers i solved the problem occuring on IG accounts.
    Instead of
    GRAPH strategyprofit as \"strategy profit\"
    you have to use the following code
    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\"

     
    With this code i was able to use the strategy profit curve for trading decisions on an IG account. Unfortunately the use of an EMA was’t helpfull to increase performance.
    Maybe you have a better idea to use it.

    • Nicolas • 01/13/2016 #

      Great! Thank you very much for posting it here for everyone.

  6. Wisko • 01/13/2016 #

    No Problem. Hope, someone can work out, how to use it. The EMA 1000 on my profit curve led to a clear reduction of profit

    • Nicolas • 01/13/2016 #

      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 :

      you miss a lot of good trades, your strategy is “broken”..
      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.
      Keep on searching about this!

  7. MikeGC • 01/13/2016 #

    Great idea @Nicolas!  We are privileged to have the benefit of your creativity available to us – many thanks. 
    I agree that to many excellent strategies suffer from large draw downs, any anything that can reduce this turns a good strategy into an excellent one.  I am currently testing your trailing stop loss code with a number of strategies and find it very successful in this regard.
    Best regards to all traders who struggle – it is the best way to learn!  As Google’s directive to their researchers goes….. “Fail early, fail often but fail forward”.
    Mike

  8. Bel • 01/13/2016 #

    Couldn’t get this idea to work on 10.3 IG PRT, the GRAPH strategyprofit appears ok, but when i put GRAPH Average[X](strategyprofit) no moving average appears in my window. Any solutions?

    • Nicolas • 01/13/2016 #

      There must be sufficient data to compute the average (X period used).

  9. Bel • 01/13/2016 #

    Copy that , thanks;)

  10. oakenstream • 01/13/2016 #

    Nice, we love you

  11. rmhandel • 01/13/2016 #

    this is an awesome tool and a great idea for it . thanks for that

avatar
Register or

Top