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

    • Date: 22nd October 2024. Stocks’ rally ran out of steam? Asia & European Sessions:   A number of factors weighed on Treasuries and EGBs, but the underlying element was inflation anxiety. Several factors, including concerns over bond supply and stronger US economic data, are contributing to the bond selloff. The resilience of the US economy, diminishing expectations for Fed rate cuts, the bounce in Oil prices, the acceleration in rate cut prospects from the BoC, BoE, and ECB, fears of fiscal largess, and the massive stimulus from China all added to the likelihood price pressures could remain sticky. Wall Street was mixed in relatively quiet action. Additionally, traders are betting on the risk of a Republican win in the US election, which could lead to looser fiscal policy and increased tariffs under Donald Trump, potentially worsening the federal deficit and stoking inflation. Asian equities declined for a 2nd consecutive day, along with bonds, as traders reassessed cooling expectations for Federal Reserve rate cuts this year. This followed a decline in US equities after a strong run-up to all-time highs. Australian and New Zealand bonds also fell. Investors in Japan pulled back ahead of the upcoming general election on Sunday, with stocks, bonds, and the Yen all declining simultaneously amid polls suggesting the ruling coalition could lose its majority. The Nikkei dropped 1.4%, reaching its lowest level since early October. Gold rose to $2,733.41 in Asia, following Monday’s record high of $2,740.59. Gold has surged nearly 30% this year, hitting successive all-time highs, with momentum accelerating as the Fed pivoted to cutting rates. Hedge funds have been increasing net-long positions in gold, and ETF inflows have also contributed to the rally. Traders are also adjusting portfolios ahead of the US election on Nov. 5, with gold seen as a safe bet during times of geopolitical and economic uncertainty. Financial Markets Performance:   The USDIndex hit a multi-month high, largely on the less dovish view on Fed policy and reached 104.00, the first time at that level since late July. The USDJPY rallied to 151 for the first time since July. Oil prices increased 1.9% to $70.54 per barrel. Gold relinquished another new high at $2740.59 before closing down -0.02% at $2720.85 per ounce. 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 on how markets work. Click HERE to register for FREE! Click HERE to READ more Market news. Andria Pichidi 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 FX and CFDs 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.
    • GTE Gran Tierra Energy stock watch, pullback to 6.3 support area with bullish indicators at https://stockconsultant.com/?GTE
    • AILE iLearningEngines stock, watch for a bottom breakout above 1.88 at https://stockconsultant.com/?AILE
    • SPOT Spotify stock, watch for a range breakout at https://stockconsultant.com/?SPOT
    • SN SharkNinja stock, watch for a flat top breakout above 111.04, target 122 area at https://stockconsultant.com/?SN
×
×
  • Create New...

Important Information

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