Backtesting: Percentage values in scale of equity curve?
Forums › ProRealTime English forum › ProOrder support › Backtesting: Percentage values in scale of equity curve?
- This topic has 7 replies, 3 voices, and was last updated 6 years ago by
Vonasi.
-
-
07/24/2019 at 11:52 AM #103328
When backtesting in PRT, is it possible to change the scale of the equity curve from total equity to percentage values? Either current equity as a percentage of initial equity, or current equity as the change in percentage of the initial equity.
I’m using PRT v10.3 – 1.8.0_43 in demo mode.
07/24/2019 at 1:24 PM #10334707/24/2019 at 1:51 PM #103349Thanks! I guess that’s one way to handle it. Right now I’m thinking of adding some money management code to the trading system so I can start the simulation with any amount of capital and use any percentage of the capital currently on the account at each entry. I’d like to see what happens if use almost 100% of the capital at each entry. Just for the fun of it. 🙂
If anyone knows any nice code snippets I can use for this, pls. share here. So far I’ve found this snippet:
https://www.prorealcode.com/blog/learning/money-management-prorealtime-code/
07/24/2019 at 1:59 PM #103350I can see at least 3 here … may not be exactly what you want, but worth a look?
1 user thanked author for this post.
07/24/2019 at 3:34 PM #10337707/24/2019 at 4:09 PM #103389Having tried out the idea it is a little more complicated than it first seems as you would need to run a virtual strategy in the indicator on the equity curve to simulate returns. Far easier is to just add this to the bottom of your strategy and then graph the percentages in their own window. It records the lowest % of start equity in the equity curve as well as the maximum % of start equity along with the running % of start equity.
Change startequity to match your starting capital value.
12345678startequity = 10000Perc = (strategyprofit / startequity) * 100maxperc = max(maxperc,perc)minperc = min(minperc,perc)graph Perc as "Gain/Loss % of Start Equity"graph maxperc as "Max % Gain/Loss of start equity"graph minperc as "Min % Gain/Loss of start equity"1 user thanked author for this post.
07/24/2019 at 6:24 PM #103419Thanks a lot! I tested to insert your code in the bottom of my strategy. Before that I had also tweaked my code so that I would use the max amount of available capital on the account for each buy. Seems like your code doesn’t change the graph until the sell. I’m not sure why though. I might have to sleep on it to figure out why the curves are different.
You can see the result in the first figure. What I’m trying to implement is something like you see in the second figure. The two bottom curves are the price development in the stock (actually an index) in percent as well as the MA(12) indicator. The top curve is the development of the account in percent, if I’m fully invested during uptrends and not invested during downtrends.
Simple MA(12) long strategy1234567891011121314151617181920212223242526272829303132// Definition of code parametersDEFPARAM CumulateOrders = False // Cumulating positions deactivatedInitCapital = 10000Equity = InitCapital + StrategyProfitNrOfShares = Round(Equity/close - 0.5) // Round down to integer below// Conditions to enter long positionsindicator1 = Average[12](close)c1 = (close > indicator1)IF c1 THENBUY NrOfShares SHARES AT MARKETENDIF// Conditions to exit long positionsindicator2 = Average[12](close)c2 = (close < indicator2)IF c2 THENSELL AT MARKETENDIF// Graph the Gain/Loss % of Start Equitystartequity = 10000Perc = (strategyprofit / startequity) * 100maxperc = max(maxperc,perc)minperc = min(minperc,perc)graph Perc as "Gain/Loss % of Start Equity"graph maxperc as "Max % Gain/Loss of start equity"graph minperc as "Min % Gain/Loss of start equity"07/24/2019 at 10:44 PM #103439STRATEGYPROFIT is only updated at the close of positions which is why you do not see a live update of the % while a position is open. To achieve this you will need to calculate the difference between CLOSE and POSITIONPRICE whenever you are on the market and add this to STRATEGYPROFIT to get a live value.
It seems that your topic is more ProOrder automatic trading related than platform related. It is not a % on an equity curve that you need but a % in a strategy. I will move the topic to the ProOrder forum for this reason.
Please try to post in the most relevant forum with future topics. 🙂
-
AuthorPosts
Find exclusive trading pro-tools on