When I do a backtest on the cross of a Hull Moving Average with a Simple Moving Average the system pinpoints them incorrectly.
No doubt some more experienced player here can enlighten me as to why that is and if there is some way of correcting it.
Thank you in anticipation and many thanks to all of you at Prorealcode for the fantastic resource you provide!
I have moved your topic to the ProOrder forum as it is a strategy question and not a platform issue (until proven that it is!) Please try to post in the correct forum with future posts in accordance with the forum rules.
You will need to provide evidence otherwise we are all just guessing. A screenshot pointing out the error and even the code would be useful.
Have you tried using GRAPH and GRAPHONPRICE to double check the values?
Yes, sorry about the lack of evidence!
Attached is a sample screenshot from a backtest showing the discrepancy between the actual crosses of an SMA and an HMA and how the system places the crosses. I’m also pasting in the code below. I’m not a coder, the code was generated by the auto code generator for dummies on the platform. Any amendments to the code that corrects things appreciated. Thank you!
// Definition of code parameters
DEFPARAM CumulateOrders = False // Cumulating positions deactivated
// Conditions to enter long positions
indicator1 = Average[20](close)
indicator2 = Average[125](close)
c1 = (indicator1 CROSSES OVER indicator2)
IF c1 THEN
BUY 1 PERPOINT AT MARKET
ENDIF
// Conditions to exit long positions
indicator3 = Average[20](close)
indicator4 = Average[125](close)
c2 = (indicator3 CROSSES UNDER indicator4)
IF c2 THEN
SELL AT MARKET
ENDIF
There are some simple rules that everyone using the forums is expected to follow. Your post has broken one or more of these rules.
The forum rules are as follows. I have highlighted in bold the rule/rules that you have not followed:
Post your topic in the correct forum.
ProRealTime Platform Support only platform related issues.
ProOrder only strategy topics.
ProBuilder only indicator topics.
ProScreener only screener topics
General Discussion any other topics.
Welcome New Members for new forum members to introduce themselves.
Only post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Do not double post. Ask your question only once and only in one forum. All double posts will be deleted anyway so posting the same question multiple times will just be wasting your own time and will not get you an answer any quicker. Double posting just creates confusion in the forums.
Be careful when quoting others in your posts. Only use the quote option when you need to highlight a particular bit of text that you are referring to or to highlight that you are replying to a particular member if there are several involved in a conversation. Do not include large amounts of code in your quotes. Just highlight the text you want to quote and then click on ‘Quote’.
Give your topic a meaningful title. Describe your question or your subject in your title. Do not use meaningless titles such as ‘Coding Help Needed’.
Do not include personal information such as email addresses or telephone numbers in your posts. If you would like to contact another forum member directly outside of the forums then contact the forums administrator via ‘Contact Us’ and they will pass your details on to the member that you wish to contact.
Always be polite and courteous to others.
Have fun.
I have edited your post where required. Please ensure that your future posts meet these few simple forum rules. 🙂
Please read the rules before posting again as moderators have better things to do than tidy up after nooby forum members all day long.
I’m guessing that you are using v10.3. When v11 was introduced the Hull MA was added to the strategy creation tool but it only works in v11. In v10.3 it defaults to a simple MA. Both MA’s in your code are SMA’s.
You will need to hard code in the calculations for a Hull MA if you want to use them in a v10.3 strategy.
This is the calculation for Hull average:
p = 100
inner = 2*weightedaverage[round(p/2)](close)-weightedaverage[p](close)
HullMA = weightedaverage[round(sqrt(p))](inner)
Thanks for your help.
Apologies for falling short.