- This topic has 2 replies, 2 voices, and was last updated 10 months ago by .
- You must be logged in to reply to this topic.
I’m looking to backtest and scan for breakouts from a sideways range, something like this.
In its simplest form, a pattern where:
The previous (say) 20 bars were in a fairly narrow range (say) 20% between the highest high and lowest low, and
The last bar high exceeds any of the prior 20 days, and
The last bar range is substantially higher than any range of the prior 20 days.
For the last bar high, I have:
// High > the Highest High of the last 20 days.
However, I'm having trouble figuring out how to define the consolidation range.
Thanks Ian. To calculate the highest range of the previous 20 days you would need to get the highest high and lowest low, and calculate the range as a % of the highest high.
This will calculate when that range is less than 20% (which is quite wide over a short period) and the last high broke out 2% higher than the 20 day high:
H20 = HIGHESTHIGH(BARS=20);
L20 = LOWESTLOW(BARS=20);
//Hi - Low Range;
R20 = H20 - L20;
//Range as a % of high > 20%;
(R20/H20 < 0.2) and //and High > 2% higher;
HIGH() > (H20*1.02)
Thank you Darren!
I’ve used your script in the Scanning Manager with a sample workbook and it looks like it is identifying the breakout correctly.
Next step is to test it in the Backtester with some different variables. (Yes, the 20% is quite wide, but different values will be used in backtesting.)
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
|cookielawinfo-checbox-analytics||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".|
|cookielawinfo-checbox-functional||11 months||The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".|
|cookielawinfo-checbox-others||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.|
|cookielawinfo-checkbox-necessary||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".|
|cookielawinfo-checkbox-performance||11 months||This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".|
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.