OmniTrader Forum OmniTrader Forum
forums calendars search
today this week
 
register logon control panel Forum Rules
You are currently browsing as a guest.
You should logon to access more features
A Self-Moderated Community - ALL MEMBERS, PLEASE READ!
Vote for Members who contribute the most to your trading, and help us moderate content within the Forums.


  Current location        Thread information  
OmniTrader Archives
OmniTrader 2021 Technical Support
July 4 celebration
Last Activity 11/21/2022 10:19 AM
7 replies, 1360 viewings

Jump to page : 1
Now viewing page 1 [25 messages per page]
 
back reply
Printer friendly version

^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : July 4 celebration
Posted : 7/3/2021 5:27 PM
Post #48193

I posted this to the OT Pro forum, but I was not able to attach files...
So, here it is again...

I have been working on a few indicators based on using Linear Regression "best fit" lines.

I have 4 indicators -
indLRLPlot - plots a Linear Regression Line (LRL) in the price pane
indLRLPercent - returns the % delta between the final Close and the LRL
indLRLSlope - returns the slope of the LRL in % per bar
indLRLVariance - returns the variance between the max excursion and the LRL over the period of the LRL

I am using these indicators with OmniScan to find underlyings that meet specific conditions.
I also use the indicators as sortable columns in the Focus List
I am currently only using this for prospecting. I have not created any Systems or Strategies leveraging LRL indicators (yet).

So that's the executive summary. Now for a deeper dive. (Read on if interested...)

I want to be able to find underlyings that are rising smoothly.
I want to be able to find underlyings that are moving sideways with very high volatility.
I want to be able to find underlyings that have been in a 6 month downtrend, but are sharply up over the past month.
Etc.

To that end, I created the MyLRL library. It uses math and statistics to better empower OmniScan.

The core of MyLRL is the Linear Regression line (aka the "best fit" line) This is provided by OL, but is a little tricky to use.

indLRLPlot has two parameters, Periods and Offset. Periods is the length of the drawn LRL. Offset is the bars from the HRE where the LRL ends.
Using indLRLPlot results in a straight line drawn through price bars. The LRL is the best possible line based on Close prices.

indLRLVariance provides a measurement of the overall tendency to hug or wander away from the LRL.
Normally, Variance is based on the mean of the sample data. As such, the mean is a single number. A flat line...
indLRLVariance differs in that it uses the actual LRL values, bar by bar, as the mean. Think of it as a "de-trended variance".
Also, indLRLVariance includes a Sensitivity parameter. Normal Variance uses a square of the delta between the mean and each data point.
The Sensitivity parameter allows for specifying an exponent other than 2 for the calculation.
A larger exponent (Sensitivity ) "punishes" excursions from the mean to a greater extent.
Finally, normal Variance returns an absolute number. indLRLVariance normalizes the variance to a percentage based on the LRL's ending value.
This allows the indLRLVariance value to be easily compared between underlyings.

indLRLSlope returns the slope of the LRL, as a percent change per bar.
This is relative to the LRL itself. This tells me the daily % increase or decrease over the length of the LRL.
Since this is in %, I can easily compare the slope of different underlyings.

indLRLPercent tells me how far the Close of the final bar is from the LRL. I can easily determine if the "current" price is near or far away from the LRL.

That's a deeper dive into the four indicators. Now some notes on why and how I am using this stuff.

Due to the way charts are automatically scaled, it is very difficult to compare recent performance just by eyeballing the chart.
Using math and statistics, I can easily determine which underlyings are gaining the most, losing the most, going nowhere, etc.
I can also accurately determine which underlyings are experiencing the least volatility. Or the most volatility. Or anywhere inbetween.

And unlike ATR, RSI, MACD, and many other indicators, the trend of the underlying is central to calculating the indicators.

The Offset parameter is also very useful. I can model combinations of longer term trends with shorter term trends. (like multi-timeframe analysis...)

To support the Offset parameter, all the indicators carry forward their final LRL value through the HRE.,
So I can determine the slope of a LRL that ended 21 bars ago with a OmniScan running at the HRE.
Ditto for the Variance and Percent indicators.

The MyLRL indicators are not dis-similar to the KAMA, DAMA, and SAMA indicators. THe same logic can be used to determine "market state".
But I prefer to think of this as "market state" for the specific underlying.
I would not attempt to trade AMZN based on using the MyyLRL indicators on the SPY .

I plan to do some studies to determine the persistence of the LRL moving forward in time.
Will a 63 bar LRL predict the next 21 bars? Whith what probability?
Can I use MyLRL to filter strategies, as in "Adaptive TRading"?
Can I use the GA to tune LRL Period and Offset values?

But for now, I just want to find smooth underlyings that are easily beating the market.
TO that end, I use a OmniScan sort filter of indLRLSlope(63, 0) / indLRLVariance(63,0,2)
The numerator finds the strongest bull stocks over the past 63 bars.
The denominator punishes the underlyings if they have high volatility.
The resulst are (seemingly) great trend trading candidates...

This same technique can be used to find the top stocks in smooth bearish trends.
Or sideways on low volatility. Or sideways with extreme volatility.
Whatever the case, I have option strategies for each style of market...

I hope others can use this to increase their trade expectancy.

Happy Trading!

And Happy 4th of July.
USA - The best nation on earth.
The slayer of slavery.
The country many are willing to risk life and limb to immigrate to.
THe country where ALL races and creeds are free to succeed.
The "Shining Light On THe Hill"...
God Bless America!



Attached file : MyLRL(63,0) - OS sort using LRL indicators.png (53KB - 360 downloads)
Attached file : MyLRL(63,0) - indicator columns.png (53KB - 353 downloads)
Attached file : MyLRL(126.0) - 6 month with no offset.png (53KB - 262 downloads)
Attached file : MyLRL(63,21) - 21 bar offset.png (53KB - 300 downloads)
Attached file : indLRLPercent.txt (0KB - 277 downloads)
Attached file : indLRLSlope.txt (0KB - 280 downloads)
Attached file : indLRLVariance.txt (1KB - 280 downloads)
Attached file : tplLRLine.otd (144KB - 261 downloads)

^ Top
Perry

New User

Posts: 3

Joined: 6/30/2018
Location: Newnan, GA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/7/2021 10:02 PM
Post #48210 - In reply to #48193

Outstanding effort. This is an incredibly well written description and extremely well thought out as far as how you have put this together. I did have a problem downloading most of your attachments. I can't say I've implemented it yet but I really like what you've written.
Thank you for your efforts,
Perry
^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/8/2021 10:41 AM
Post #48214 - In reply to #48193

Thanks!

I didn't thnk anyone cared...

I could not upload to the OT Pro forum, so I uploaded the indicators here. I can't speak as to why there would be issues downloading...

I am planning on adding variance lines around the "best fit" line, adding a LRL based RSI, and documenting OmniScan formulas for various market conditions.


^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/11/2021 5:52 PM
Post #48221 - In reply to #48193

So today I wrote an RSI() that takes into account the Linear Regression "best fit" line.

Think of it as a "detrended RSI".

Traditional RSI compares the close of the previous N bars.
The HHV and the LLV of the N bar closes determines the total range.
The RSI value for any particular close is the % that specifies where the close lies between the LLV and the HHV.

HHV(C, 14) and LLV(C, 14) determines the range.
RSI = (C - LLV(C(, 14) / (HHV(C, 14) - LLV(C, 14), or something like that.
(I am writing this off the top of my head...)

Bottom line, there is no consideration for the trend of the underlying.

indLRLRSI considers the trend, as determined by the "best fit" line. Each close is measured relative to the LRL. The traditional RSI is then used to compute RSI based on "detrended" closes.

How does this effect RSI? Get out your squintty glasses and look at the attached png.

At the cross hair, the underlying has made a pullback in a srong bull trend.
THe normal RSI shows the pullback was to 61.80. Traditionaly, this would not register as an RTM candidate.
But LRLRSI shows the pullback as 38.57. This is a far more significant pullback.

Anyone using Hima Reddy's "Four Zone RSI System" would recognize the latter as a "Green Zone Domination" pullback in a bullish market.

I remember Jeff talking about how hard it was to get into RTM pullbacks during 2017 due to the strong bullish bias. Stocks would not pullback far enought to trigger the RTM strategies.

I also recall seeeing many charts where RSI pegs in the overbought or oversold area for long periods of time as the trend rips.
This is because RSI is not detrended. The strong trend overwelms the nuance of short term cycles found by RSI.
Since even weak, pullback bars are higher than bars from 14 bars ago, (nearly 3 weeks ago), RSI computes a relatively high value.

Detrending to eliminate the longer term trend allows RSI to reveal the nuanced, short term trend fluctuations.

A word about the LRLRSI indicator. Because it only uses data in common with the LRL best fit line, LRLRSI only computes on a small part of a long term chart.
Further, the RSI algorithm requires N bars to warm up.
So the indicator plot shows 0 up to the start of the LRL. At that point the LRLRSI jumps to 100 as the RSI warms up.
After the n bar warmup, LRLRSI starts displaying detreneded RSI values.
I could write code to hide some of this (and to add overbought/oversold level lines), but I do not intend to visually inspect the LRLRSI indicator.

I am using the LRL indicators for OmniScan prospecting. So as long as the LRLRSI is known at the HRE, I am happy.

I have only given cursory thought to using the LRL indicators in PortSim. As written, they will not work on a historical basis.

Anyway, I hope this is interesting and perhaps useful.




Attached file : LRL RSI comparison.png (56KB - 271 downloads)
Attached file : indLRLRSI.txt (1KB - 298 downloads)

^ Top
Perry

New User

Posts: 3

Joined: 6/30/2018
Location: Newnan, GA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/11/2021 9:30 PM
Post #48222 - In reply to #48193

I too am amazed that no one else has any comments. what you are doing is very useful and well done. keep up the good work
Thanks for all of your efforts
Perry
^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/11/2021 11:11 PM
Post #48223 - In reply to #48193

Thanks!


^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/19/2021 5:16 PM
Post #48225 - In reply to #48193

This weekend I ran some tests on the predictiveness of the 63 bar Linear Regression Slope.

I tested 1, 3, 5, 10, and 21 bar exits to see if using the LRS could improve the Hit Rate (HR) over random entries.

I started by entering every trade OT allowed without any filtering by the LRS. I used the SP500 and NAS100 as my universe of stocks.
My backtest period was 1/1/15 through 12/31/15. My forward test period was 1/1/16 to present.

Once determining the market bias for the BT and FT periods, I then used Strategy Wizard to test various ranges of min and max LRS readings.
LonSignal's were triggered for each bar that met the range requirements. The results of the NBar exits were recorded by SW.

Once I ran all the desired experiments for 1, 3, 5, 10, and 21 bar exits, I pulled all the data into Excel.
I calculated the top Hit Rate as well as the average of the top 5 LRS range parameters for each N-bar term.
I calculated the improvement (or lack thereof) of the best and average numbers.

I am attaching a png of the summary sheet, as well as the workbook.

The executive summary is that using the Linear Regression Slope to filter trades improved the Hit Rate in every case tested.
THe largest improvement was 18.39% while the smallest improvement was 2.96%.

Notes
1) These results are based on one sequence of trades for each run of Strategy Wizard. Samples of 1 must be viewed with a suspicious eye.
To be more thorough, the indMonteCarlo.txt OL code (previously posted to the OTPro forum) should be used as a filter, and multiple SW runs taken to establish a more convincing result.
This would help eliminate biases caused by trade sequenceing.

2) I am only looking at the viability of LRS as a filter. No entry or exit logic systems or tradeplans have been employed to enhance performance. Hence I am only focused on Hit Rate.

3) I plan on testing 126 bar and 21 bar LRSlopes to determine if longer or shorter trends are more predictive for short term trades.

4) I also plan on testing ShortSignal's in similar fashion.

Hope this is useful...



Attached file : LRSSlope Summary Sheet.png (48KB - 267 downloads)
Attached file : LRSlope 63 bar.xlsx (183KB - 296 downloads)

^ Top
kmcintyre

Legend
100100100100
Posts: 410

Joined: 8/30/2007
Location: Valley Center, CA

User Profile
 
Subject : RE: July 4 celebration
Posted : 7/25/2021 2:16 PM
Post #48226 - In reply to #48193

This week I used Strategy Wizard to determine the predictiveness of 126 and 32 bar Linear Regression "best fit" lines.

I tested the same 1, 3, 5, 10, and 21 bar exits against all stocks in the SP500 and NAS100. The backtest was from 1/1/2015 to 12/31/2015. The foreward test was from 1/1/2016 to present.

These tests complimented the 63 bar tests I performed last week.

I was a bit surprised by the results.

The 32 bar "best fit" line was significantly more predictive when compared to either the 63 or 126 bar lines.

See the attached "LRS Summary.xlsx" for the comparison. (See LRS 32 bar.xlsx and LRS 32 bar .xlsx for detailed PortSim results.)

But here's the quick takeaway.

Using a 32 bar Linear Regression "best fit " line improved the Hit Rate for all trades, regardless of duration.
10 bar trades improved between 10.71% to 23.50%, depending on if I used the top 5 settings or the best settings.
21 bar trades improved between 12.62% to 20.03%

The BT HT for 10 bar trades increased from 47.93% to 71.43% (best case)
The FT HT for 10 bar trades increased from 55.53% to 68.93% (best case)

The BT HT for 20 bar trades increased from 46.64% to 66.67% (best case)
The FT HT for 20 bar trades increased from 57.03% to 70.56% (best case)

Based on these results, I am confident that the Linear Regression "best fit" line has predictive qualities.

What's next?
1) Perform similar tests on negative slopes using short trades to verify predictiveness to the downside.
2) Try shorter term "best fit" lines to target 5 to 10 bar trades. (Just a little bit shorter term...)
3) Incorporate aLinear Regression Variance filter to determine is lower variance improves predictiveness.

Hope this is of interest...

Attached file : LRS Summary.xlsx (11KB - 252 downloads)
Attached file : LRSlope 32 bar.xlsx (199KB - 246 downloads)
Attached file : LRSlope 126 bar.xlsx (174KB - 259 downloads)

Jump to page : 1
Now viewing page 1 [25 messages per page]
back reply

Legend    Action      Notification  
Administrator
Forum Moderator
Registered User
Unregistered User
E-Mail this thread to a friend
Toggle e-mail notification


Nirvana Systems
For any problems or issues please contact our Webmaster at webmaster@nirvsys.com.