Jump to content

Welcome to the new Traders Laboratory! Please bear with us as we finish the migration over the next few days. If you find any issues, want to leave feedback, get in touch with us, or offer suggestions please post to the Support forum here.

  • Welcome Guests

    Welcome. You are currently viewing the forum as a guest which does not give you access to all the great features at Traders Laboratory such as interacting with members, access to all forums, downloading attachments, and eligibility to win free giveaways. Registration is fast, simple and absolutely free. Create a FREE Traders Laboratory account here.

wsam29

Linear Regression Channel

Recommended Posts

I have no clue how to upload the indicator so I'll just post the coding.

 

[LegacyColorValue = true];

{Updated by DJ Reda on Sat 4/16/05

Added option to use either Standard Deviation or Standard Error of Estimate to plotchannel bands}

{ // Note: Setting a begin date that is earlier than the amount of length for the regression

will produce an extend to the left model that is date and time restricted

The End Date must not be in the future // }

 

inputs:

STD1_SEE2(2),

Length ( 50), { // Length of Linear Regression // }

Size(1),//Trend Line Thickness

BeginDate ( 0), { // Choose Zero to use full length // }

BeginTime ( 0), { // Choose Zero to use full time // }

EndDate ( 0), { // Choose Zero for Current Day // }

EndTime ( 0), { // Choose Zero for Current Time // }

NumDevsUp ( 2), { // Standard deviations for upper // }

NumDevsDn ( -2), { // Standard deviations for lower // }

LRColor ( Green), { // Color for Linear Regression Line // }

STDDevColor( Magenta), { // Color for Upper Boundary // }

SEEColor(Magenta) , { // Color for Lower Boundary // }

ExtRight ( false), { // Set to true to extend to right // }

ExtLeft ( false); { // Set to true to extend to left // }

 

variables:

FirstDate ( 0 ),

FirstTime ( 0 ),

UpperBand ( 0 ),

LowerBand ( 0 ),

UpperBand_1 ( 0 ),

LowerBand_1 ( 0 ),

LRV ( 0 ),

LRV_1 ( 0 ),

TL_LRV ( 0 ),

TL_UB ( 0 ),

TL_LB ( 0 ),

Flag ( 0 ),

SDev ( 0 );

 

 

if BeginDate = 0 then

FirstDate = date[ Length - 1 ]

else

FirstDate = BeginDate;

 

if BeginTime = 0 then

FirstTime = time[ Length - 1 ]

else

FirstTime = BeginTime;

 

 

{ ///////////////////////////////////////////////////////////////////// }

 

if Flag = 0 then

begin

if ( EndDate = CurrentDate or EndDate = 0 ) and LastBarOnChart then

begin

LRV = LinearRegValue( Close, Length, 0 );

LRV_1 = LinearRegValue( Close, Length, Length - 1 );

{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}

If STD1_SEE2 = 1 then

SDev = StandardDev( Close, Length, 1 );

If STD1_SEE2 = 2 then begin //use Standard Error of Estimate

Value1 = StdError(Close, Length);

SDEV = Value1;

end;

{++++++++End New Code++++++}

 

UpperBand = LRV + NumDevsUp * SDev;

LowerBand = LRV + NumDevsDn * SDev;

UpperBand_1 = LRV_1 + NumDevsUp * SDev;

LowerBand_1 = LRV_1 + NumDevsDn * SDev;

 

TL_LRV = TL_New( FirstDate, FirstTime, LRV_1, date, time, LRV );

TL_UB = TL_New( FirstDate, FirstTime, UpperBand_1, date, time, UpperBand );

TL_LB = TL_New( FirstDate, FirstTime, LowerBand_1, date, time, LowerBand );

 

Flag = 1 ;

end

else if date = EndDate and ( time = EndTime or EndTime = 0 ) then

begin

LRV = LinearRegValue( Close, Length, 0 );

LRV_1 = LinearRegValue( Close, Length, Length - 1 );

 

{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}

If STD1_SEE2 = 1 then

SDev = StandardDev( Close, Length, 1 );

If STD1_SEE2 = 2 then begin //use Standard Error of Estimate

Value1 = StdError(Close, Length);

SDEV = Value1;

end;

{++++++++End New Code++++++}

 

UpperBand = LRV + NumDevsUp * SDev;

LowerBand = LRV + NumDevsDn * SDev;

UpperBand_1 = LRV_1 + NumDevsUp * SDev;

LowerBand_1 = LRV_1 + NumDevsDn * SDev;

 

TL_LRV = TL_New( FirstDate, FirstTime, LRV_1, date, time, LRV );

TL_UB = TL_New( FirstDate, FirstTime, UpperBand_1, date, time, UpperBand );

TL_LB = TL_New( FirstDate, FirstTime, LowerBand_1, date, time, LowerBand );

 

Flag = 2;

end;

 

if Flag = 1 or Flag = 2 then

begin

TL_SetColor( TL_LRV, LRColor );

If STD1_SEE2 = 1 then begin

TL_SetColor( TL_UB, STDDevColor );

TL_SetColor( TL_LB, STDDevColor );

end;

If STD1_SEE2 = 2 then begin

TL_SetColor( TL_UB, SEEColor );

TL_SetColor( TL_LB, SEEColor );

end;

 

TL_SetSize(TL_LRV, size);

TL_SetSize(TL_UB, size);

TL_SetSize(TL_LB, size);

 

TL_SetExtLeft( TL_LRV, ExtLeft );

TL_SetExtLeft( TL_UB, ExtLeft );

TL_SetExtLeft( TL_LB, ExtLeft );

 

 

TL_SetExtRight( TL_LRV, ExtRight );

TL_SetExtRight( TL_UB, ExtRight );

TL_SetExtRight( TL_LB, ExtRight );

end;

 

end

else

if Flag = 1 then

begin

LRV = LinearRegValue( Close, Length, 0 );

LRV_1 = LinearRegValue( Close, Length, Length - 1 );

 

{++++++++New Code to Choose between plotting Std Dev or Std Error++++++}

If STD1_SEE2 = 1 then

SDev = StandardDev( Close, Length, 1 );

If STD1_SEE2 = 2 then begin //use Standard Error of Estimate

Value1 = StdError(Close, Length);

SDEV = Value1;

end;

{++++++++End New Code++++++}

 

UpperBand = LRV + NumDevsUp * SDev;

LowerBand = LRV + NumDevsDn * SDev;

UpperBand_1 = LRV_1 + NumDevsUp * SDev;

LowerBand_1 = LRV_1 + NumDevsDn * SDev;

 

TL_SetBegin( TL_LRV, FirstDate, FirstTime, LRV_1 );

TL_SetBegin( TL_UB, FirstDate, FirstTime, UpperBand_1 );

TL_SetBegin( TL_LB, FirstDate, FirstTime, LowerBand_1 );

 

TL_SetEnd( TL_LRV, date, time, LRV );

TL_SetEnd( TL_UB, date, time, UpperBand );

TL_SetEnd( TL_LB, date, time, LowerBand );

end;

 

{ // Code modified from TradeStation indicator of LinearRegLine

by

Greg Ballard, 04/09/2003 // }

 

 

This indicator was sent to me from Pat B. from TTM

 

LRC

 

I'd attach some screen shots of how I use the LRC, but I have no clue what I'm doing.

LRC_01.thumb.jpg.fe600d59484b9c6a9be54ea4459066b9.jpg

LRC_02.thumb.jpg.1fdf27cb724afb0c6499efc41871f378.jpg

Share this post


Link to post
Share on other sites

I would like a way to use the linear regression lines like they are in eSignal, with an open source code or jump box so you can adjust the standard deviation, but coded for Tradestation. It's been proven that a linear regression/standard deviation of plus and minus 2 usually contains about 90% of the range of a stock, and a LR/SD +-3 contains approx. 98% of the range, so I'd like the code please for Tradestation 8.3 for those linear regression channels, but where it's comparable to eSigs and objective and draws the lines over the whole chart monthly, weekly etc., not like Tradestations that is subjective to where you have to put it in like Fib channels and twist it to make it fit, and can start out (on TS charts) from a place that is incorrect. If someone has some TS codes for objective lines for a whole chart for LR/SD +-2 and +-3, that would be great, and I would really appreciate it, and if it could be open source so it could be changed for LR/SD lines for charts for whatever you want, +-1, 1.5, 2.5, etc, some stocks deviate more or less than others, and you can find the outer reaches to which a stock has always been contained in(tempted to get eSig just for that and cleaner charts/trendlines), and would help to see why a stock stops in it's tracks to the bottom or top, even when it seems like it has broken out, or down.

 

Curtis

Share this post


Link to post
Share on other sites
Guest forsearch
I would like a way to use the linear regression lines like they are in eSignal, with an open source code or jump box so you can adjust the standard deviation, but coded for Tradestation. It's been proven that a linear regression/standard deviation of plus and minus 2 usually contains about 90% of the range of a stock, and a LR/SD +-3 contains approx. 98% of the range, so I'd like the code please for Tradestation 8.3 for those linear regression channels, but where it's comparable to eSigs and objective and draws the lines over the whole chart monthly, weekly etc., not like Tradestations that is subjective to where you have to put it in like Fib channels and twist it to make it fit, and can start out (on TS charts) from a place that is incorrect. If someone has some TS codes for objective lines for a whole chart for LR/SD +-2 and +-3, that would be great, and I would really appreciate it, and if it could be open source so it could be changed for LR/SD lines for charts for whatever you want, +-1, 1.5, 2.5, etc, some stocks deviate more or less than others, and you can find the outer reaches to which a stock has always been contained in(tempted to get eSig just for that and cleaner charts/trendlines), and would help to see why a stock stops in it's tracks to the bottom or top, even when it seems like it has broken out, or down.

 

Curtis

 

OK. We'll get right on that for ya, mate. :rofl:

 

BTW, have you tried looking over at the TS forum? You might find your answer there as well....:crap:

Share this post


Link to post
Share on other sites

Thanks for replying, sorry it took a little while to get back to you, I work nights and trade during the day. Guess what I'm looking for is a standard deviation channel like on this page:

http://ta.mql4.com/linestudies/standard_deviation_channel, based on a linear regression line, not an indicator or oscillator, but an overlay like Bollinger Bands or moving averages. The one at TS is hard to use and when I stretch regression channels around a linear regression line, no matter how skinny or wide I make the channel, it always says 2 SD (Open).

 

Investor/RT has another page which demonstrates what I'm looking for here:

http://www.linnsoft.com/tour/techind/linReg.htm, and I can put them in individually in TS if that's what it takes one by one, that's how I had to change parameters on slow shotastics and RSI to 5, 7, and 21, had to copy the original page and just change the numbers for different RSI screens.

 

Inv.R/T also has a follow-up page which shows linear regression forecast/bands similar to Bollinger bands for the E-mini; I don't do futures, just stocks & options, but this looks promising. The E-mini example of the linear reg. forecast/bands is at http://www.linnsoft.com/tour/techind/linRegForecast.htm, which shows this example: http://www.linnsoft.com/tour/techind/images/lrfKessler.jpg.

 

There is an Amibroker page with good ideas for a formula:http://www.amibroker.com/library/detail.php?id=438&hilite=IIF,

just need one for TS, and like I mentioned, I could change the individual #s and set up different Easy Language Documentsto be used like Bol. Bands if need be for each one like LR/SD 1, 1.5, 2.5, 3, 3.5, just would like a code for a linear regression with 2 standard deviations plotted off of it, just need a low number period to work with because I'll mostly be looking at it weekly and monthly more than that.

 

Esig has a page with people discussing formulas for plotting it, but they have and easy way with jumpboxes to adjust LR and SD and standard error to whatever you want, and the moving linear regression is not necessary, just would like cleaner pre-plotted LR/SD that I can change to gauge more about stocks and the market. Thanks for your help in advance, have to go to work right after the market closes like Tue. again today.

 

Curtis

Share this post


Link to post
Share on other sites

I would like a code for a chart overlay of standard deviation channels built on a base of a linear regression trend like Bollinger bands, with 2 standard deviations above and below the LR line. When it is attempted on TS, it's hard to use, unlike eSig and a few other platforms I've used before, which make it easy with jumpboxes where you can change the SD to 1, 2, 3, 5, 1.5,etc., and eSig has standard error. On TS, I can plot an objective LR line on daily, weekly, and monthly charts, the longer time frame seems more reliable, and when I try to use the regression channels with it, no matter how very skinny or extremely wide I make the channels, it always says 2 SD (Open), and I know that's not right. Metastock, Amibroker, Investor R/T, Esig has the best one, but they all have easy ways to plot the LR/SD +-2, 1, 3 overlays on charts, or whatever you want, but TS doesn't. Can you make a formula for a concrete overlay LR/SD channel of +-2 above and below a LR line so I can use it for D, W, and most important to me monthly charts, and show me where to change to couple-5 #s in the equation so I can make several screens of a few different numbers, sure there is no way to make a jumpbox like in other platforms. This is what I hope it will look like:

 

http://www.onlinetradingconcepts.com/TechnicalAnalysis/LinRegChannel.html

 

Except with the SD of 2 instead of 1.....Thanks in advance and I'll check back in another day or so, have to work nights again tomorrow, and am glued to the marker during the weekdays.

 

Curtis

Share this post


Link to post
Share on other sites

Thanks for posting that wsam29. That code does work, but I tried to change it to +3 & -3 standard deviation and just changed the #s on lines 8 and 9 that say NumDevsUp and NumDevsDn. Is that right or do I need to change other numbers in the code? Also the channel only works at the very right side of the charts, is there a way to get it to go all the way across the chart, mainly use it on monthly and weekly charts. Thanks for any help.

 

Curtis

Share this post


Link to post
Share on other sites

Hi Guys,

 

I am not very good at all with paisting indicators in multicharts, can someone please tell me how to copy and past that code into multicharts or maybe post the indicator.

Many thanks,

email

Share this post


Link to post
Share on other sites
Hi Guys,

I am not very good at all with paisting indicators in multicharts, can someone please tell me how to copy and past that code into multicharts or maybe post the indicator.

Many thanks,

email

 

 

Open PowerEditor,

 

select File > New

 

enter indicator name,

 

paste in code.

 

click Compile

Share this post


Link to post
Share on other sites

dear

I am not very good at all with paisting indicators in multicharts, could someone please just post the indicator.( EazyLanguageDocumenFile)

 

thank you very much

Share this post


Link to post
Share on other sites

dear traders

I am very bad at all with paisting indicators in multicharts, could someone please just post the indicator.( EazyLanguageDocumen File)

 

thank you very much

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Topics

  • Posts

    • CVNA Carvana stock, nice top of range breakout at https://stockconsultant.com/?CVNA
    • GDRX GoodRx stock, good day, watch for a bottom range breakout at https://stockconsultant.com/?GDRX
    • Date: 14th February 2025.   Can The NASDAQ Maintain Momentum at Key Resistance Level?     The price of the NASDAQ throughout the week rose more than 3.00% to bring the price back up to the instrument’s resistance level. However, while taking into consideration higher inflation, tariffs and the resistance level, could the index maintain momentum?   US Inflation Rises For a 4th Consecutive Month The US Consumer Price Index, or inflation, rose for a 4th consecutive month taking the rate even further away from the Federal Reserve’s target. Analysts were expecting the US inflation rate to remain unchanged at 2.9%. However, consumer inflation rose to 3.00%, the highest since July 2024, while Producer inflation rose to 3.5%. Higher inflation traditionally triggers lower sentiment towards the stock market as investors' risk appetite falls and they prefer the US Dollar. However, on this occasion bullish volatility rose. For this reason, some traders may be considering if the price is overbought in the short term.   Addressing these statistics, US Federal Reserve Chair Jerome Powell acknowledged that the Fed has yet to achieve its goal of curbing inflation, adding further hawkish signals regarding the monetary policy. Other members of the FOMC also share this view. Today, Raphael Bostic, President of the Federal Reserve Bank of Atlanta, stated that the Fed is unlikely to implement interest rate cuts in the near future. This is due to ongoing economic uncertainty following the introduction of trade tariffs on imported goods and other policies from the Republican-led White House.   Most of the Federal Open Market Committee emphasizes additional time is needed to fully assess the situation. According to the Chicago Exchange FedWatch Tool, interest rate cuts may not start until September 2025.   What’s Driving The NASDAQ Higher? Earnings data this week has continued to support the NASDAQ. Early this morning Airbnb made public their quarterly earnings report whereby they beat both earnings per share and revenue expectations. The Earnings Per Share read 25% higher than expectations and Revenue was more than 2% higher. As a result, the stock rose more than 14%. Another company this week that made public positive earnings data is Cisco which rose by more than 2% on Thursday. Another positive factor continues to be the positive employment data. Even though the positive employment data can push back interest rate cuts, the stability in the short term continues to serve the interests of higher consumer demand. The US Unemployment Rate fell to 4.00% the lowest in 8 months. Lastly, investors are also increasing their exposure to the index due to sellers not being able to maintain control or momentum. Some economists also increase their confidence in economic growth if Trump can obtain a positive outcome from the Ukraine-Russia negotiations.   However, during Friday’s pre-US session trading, 80% of the most influential stocks are witnessing a decline. The NASDAQ itself is trading more or less unchanged. Therefore, the question again arises as to whether the NASDAQ can maintain momentum above this area.   NASDAQ - News and Technical analysis In terms of technical analysis, the NASDAQ is largely witnessing mainly bullish indications on the 2-hour chart. However, the main concern for traders is the resistance level at $21,960. On the 5-minute timeframe, the price is mainly experiencing bearish signals as the price moves below the 200-period simple moving average.   The VIX, which is largely used as a risk indicator, is currently trading 0.75% higher which indicates a lower risk appetite. In addition to this, bond yields trade 6 points higher. If both the VIX and Bond yields rise further, further pressure may be witnessed for index traders.   Always trade with strict risk management. Your capital is the single most important aspect of your trading business.   Please note that times displayed based on local time zone and are from time of writing this report.   Click HERE to access the full HFM Economic calendar.   Want to learn to trade and analyse the markets? Join our webinars and get analysis and trading ideas combined with better understanding of how markets work. Click HERE to register for FREE!   Click HERE to READ more Market news.   Michalis Efthymiou HFMarkets   Disclaimer: This material is provided as a general marketing communication for information purposes only and does not constitute an independent investment research. Nothing in this communication contains, or should be considered as containing, an investment advice or an investment recommendation or a solicitation for the purpose of buying or selling of any financial instrument. All information provided is gathered from reputable sources and any information containing an indication of past performance is not a guarantee or reliable indicator of future performance. Users acknowledge that any investment in Leveraged Products is characterized by a certain degree of uncertainty and that any investment of this nature involves a high level of risk for which the users are solely responsible and liable. We assume no liability for any loss arising from any investment made based on the information provided in this communication. This communication must not be reproduced or further distributed without our prior written permission.
    • LUNR Intuitive Machines stock watch, attempting to move higher off 18.64 support, target 26 area at https://stockconsultant.com/?LUNR
    • CNXC Concentrix stock watch, pullback to 47.16 triple support area with bullish indicators at https://stockconsultant.com/?CNXC
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.