Hi Eugene, I need your help again.
I would like to split a position for the exits. Compiling runs will. But If I execute the strategy computing will not come to an end. I don't know the error. Here is the relevant part of the strategy:
CODE:
Please log in to see this code.
I am sure you will realize the problem. Thank you.
Best
Niels
Size:
Color:
Size:
Color:
Hi Eugene,
the endless loop problem is resolved. But with the strategy below there are two other problems emerged:
1. The strategy should exit 50 percent of the position when the close is above the entry price and sells the rest after certain days. If you look at the trade's list the strategy does something else. And I don't know how to fix it.
2. The MaxDD varies depending on the backtesting period whilst the date of MaxDD remains always the same. Maybe there is an synchronization problem.
Do you see an error in the code?
Thank you for help.
Here is the strategy:
CODE:
Please log in to see this code.
Size:
Color:
Niels,
QUOTE:
1. The strategy should exit 50 percent of the position when the close is above the entry price and sells the rest after certain days. If you look at the trade's list the strategy does something else. And I don't know how to fix it.
Fix
what? As there are no written rules, can you explain what
else is the strategy doing, for example?
P.S. Did you intend to buy every dip or is your code missing an "else"?
CODE:
Please log in to see this code.
Size:
Color:
Hi,
here is the rule: the strategy should buy stocks with an RSI below 50. If the price rises and the close is higher than the entry price, it should sell 50% of the stocks. The other 50% should be sold after 10 days. That's it!. The code above however sometimes doesn't sell 50% of the position after it is in profit. Sometimes the trade's list shows that the position is splited in three. I don't know what's going on there. Sufficient Explanation?
Best
Niels
Size:
Color:
I believe you can avoid using SplitPosition and make it simpler:
CODE:
Please log in to see this code.
Size:
Color:
Thank you for the code. Now the strategy does what it should do. The variation of the DD figures by changing the period is still to observe. For example, if you change the period 1.1.2008 until 31.12.2013 to 1.1.2008 until 31.12.2014 the DD at exact the same date rises. I don't know why. Thank you for help.
Best
Niels
Size:
Color:
I don't know either. Probably because I'm overlooking a) what instruments (bar scale, data provider, dataset, position sizing etc.) you're applying this code to, and since seeing is believing, b) a couple of attached screenshots illustrating what you're observing?
Size:
Color:
Attached two screenshots:
first one shows the test done with S&P100, 10 pct of equity, period 2008 until 2014. Second: same portfolio, same pct of equity but period from 2008 until 2013. As you can see DD is different. I synchronized Indicators.
CODE:
Please log in to see this code.
Size:
Color:
So what gives? There's been a bubble blowing in U.S. markets for half a decade. No wonder [for many a system] that the drawdown happened in the dawn of the backtest period (2009) soon after the market crash (2008). The market hasn't looked back since then so the max DD date doesn't change.
Size:
Color:
I don't know if I understand you in the right way. But the date is not the problem. It is the different values.
Size:
Color:
Why should the values be the same if it's a pretty different backtest? There's no contradiction with the identic dates (explained above). I'm not worried about it at all.
Size:
Color:
I don't see this big difference in the backtests. The only difference is in the time period. One backtest ends at 2013, the other at 2014. The MaxDD is for both at 09.03.2009. I am absolutly fine with identical dates, but I am not with the fact that it shows two different figures. From 2008 until 2013 the backtests are completely the same. Thus, also the trades must be same as well as the MaxDD and its date. My other strategies show exactly this behavior. I can not understand why this strategy follows a different logic.
Size:
Color:
To eliminate guesswork, consider using the Portfolio Inspector (or Trades tab) to find out where the difference is coming from.
Size:
Color: