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 November 2024.   BTC flirts with $100K, Stocks higher, Eurozone PMI signals recession risk.   Asia & European Sessions:   Geopolitical risks are back in the spotlight on fears of escalation in the Ukraine-Russia after Russia reportedly used a new ICBM to retaliate against Ukraine’s use of US and UK made missiles to attack inside Russia. The markets continue to assess the election results as President-elect Trump fills in his cabinet choices, with the key Treasury Secretary spot still open. The Fed’s rate path continues to be debated with a -25 bp December cut seen as 50-50. Earnings season is coming to an end after mixed reports, though AI remains a major driver. Profit taking and rebalancing into year-end are adding to gyrations too. Wall Street rallied, led by the Dow’s 1.06% broadbased pop. The S&P500 advanced 0.53% and the NASDAQ inched up 0.03%. Asian stocks rose after  Nvidia’s rally. Nikkei added 1% to 38,415.32 after the Tokyo inflation data slowed to 2.3% in October from 2.5% in the prior month, reaching its lowest level since January. The rally was also supported by chip-related stocks tracked Nvidia. Overnight-indexed swaps indicate that it’s certain the Reserve Bank of New Zealand will cut its policy rate by 50 basis points on Nov. 27, with a 22% chance of a 75 basis points reduction. European stocks futures climbed even though German Q3 GDP growth revised down to 0.1% q/q from the 0.2% q/q reported initially. Cryptocurrency market has gained approximately $1 trillion since Trump’s victory in the Nov. 5 election. Recent announcement for the SEC boosted cryptos. Chair Gary Gensler will step down on January 20, the day Trump is set to be inaugurated. Gensler has pushed for more protections for crypto investors. MicroStrategy Inc.’s plans to accelerate purchases of the token, and the debut of options on US Bitcoin ETFs also support this rally. Trump’s transition team has begun discussions on the possibility of creating a new White House position focused on digital asset policy.     Financial Markets Performance: The US Dollar recovered overnight and closed at 107.00. Bitcoin currently at 99,300,  flirting with a run toward the 100,000 level. The EURUSD drifts below 1.05, the GBPUSD dips to June’s bottom at 1.2570, while USDJPY rebounded to 154.94. The AUDNZD spiked to 2-year highs amid speculation the RBNZ will cut the official cash rate by more than 50 bps next week. Oil surged 2.12% to $70.46. Gold spiked to 2,697 after escalation alerts between Russia and Ukraine. Heightened geopolitical tensions drove investors toward safe-haven assets. Gold has surged by 30% this year. Haven demand balanced out the pressure from a strong USD following mixed US labor data. Silver rose 0.9% to 31.38, while palladium increased by 0.9% to 1,040.85 per ounce. Platinum remained unchanged. 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. 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.
    • A few trending stocks at support BAM MNKD RBBN at https://stockconsultant.com/?MNKD
    • BMBL Bumble stock watch, pull back to 7.94 support area with high trade quality at https://stockconsultant.com/?BMBL
    • LUMN Lumen Technologies stock watch, pull back to 7.43 support area with bullish indicators at https://stockconsultant.com/?LUMN
×
×
  • Create New...

Important Information

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