Forum Replies Created
-
AuthorPosts
-
Stephen JamesMember
Try this at the very beginning of the code:-
SetBarsRequired(sbrAll,0);
It stabilizes plots. It’s is mentioned in the course somewhere, but you may not be up to that yet. Also, check the user guide for a full description.
Monte Carlo code also disrupts plots, but that comes later in the course.
Stephen JamesMemberYes, SetPositionSize(2,spsPercentOfEquity); will use a % of portfolio equity in the backtester.
However, that portfolio equity is not accessible on a bar by bar basis for this case so the calculations involving ‘a’ and ‘shares’ will not work. A good way to check those sorts of things is to write the value to the interpretation window to see what value they return. If you are not familiar with the interpretation window yet, it is not far away in the course.
Stephen JamesMemberThe equity() function returns single symbol equity, not portfolio equity. I’m not sure which you were intending.
Tracking portfolio equity for such calculations cannot be done in normal backtester mode so perhaps a derivative of price and/or volume may be a better option.
Stephen JamesMemberIn regard to the coding parts of your query,
The Position Shrinking option allows a partial position to be taken if there is not enough capital for a full position.
You would have to run separate tests for different % of risk and/or different position sizing methods
Stephen JamesMemberThe code is fine Oliver. Well done.
Stephen JamesMemberYou won’t be able to group the EMA’s but colour an style is a different matter
Code:SetChartOptions(0, chartShowArrows | chartShowDates);FastMAColor = ParamColor(“Fast Group MA Color”, colorGreen);
SlowMAColor = ParamColor(“Slow Group MA Color”, colorRed);Plot(EMA(C, 3), _DEFAULT_NAME(), FastMAColor, styleLine);
Plot(EMA(C, 5), _DEFAULT_NAME(), FastMAColor, styleLine);
Plot(EMA(C, 8), _DEFAULT_NAME(), FastMAColor, styleLine);
Plot(EMA(C, 10), _DEFAULT_NAME(), FastMAColor, styleLine);
Plot(EMA(C, 12), _DEFAULT_NAME(), FastMAColor, styleLine);
Plot(EMA(C, 15), _DEFAULT_NAME(), FastMAColor, styleLine);Plot(EMA(C, 30), _DEFAULT_NAME(), SlowMAColor, styleLine);
Plot(EMA(C, 35), _DEFAULT_NAME(), SlowMAColor, styleLine);
Plot(EMA(C, 40), _DEFAULT_NAME(), SlowMAColor, styleLine);
Plot(EMA(C, 45), _DEFAULT_NAME(), SlowMAColor, styleLine);
Plot(EMA(C, 50), _DEFAULT_NAME(), SlowMAColor, styleLine);
Plot(EMA(C, 60), _DEFAULT_NAME(), SlowMAColor, styleLine);Stephen JamesMemberIf you don’t do it for the Setup signals you’ll have those signals generating when there is a position on. The setup bar and trigger bar are not the same. Check the arrow plots with and without Exrem code to see the difference.
Stephen JamesMemberThe order of the plots can be controlled by the order you code them as you suggest. It can also be controlled by extending the Plot function. The entire function is
Plot( array, name, color/barcolor, style = styleLine, minvalue = {empty}, maxvalue = {empty}, XShift = 0, Zorder = 0, width = 1 )The Z order parameter controls the plot position relative to others. Search Plot in the User Guide for more information.
-
AuthorPosts