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

    • UNFI United Natural Foods stock, strong close and breakout at https://stockconsultant.com/?UNFI
    • PTCT PTC Therapeutics stock, great rally off the 22.73 support area. from Stocks to Watch at https://stockconsultant.com/?PTCT
    • CORZ Core Scientific stock, strong trend, watch for a new high breakout at https://stockconsultant.com/?CORZ
    • Date: 21st November 2024. Gold Regains Momentum as NVIDIA Delivers a Revenue Surge! NVIDIA beat earnings expectations, and nearly doubled revenue on an annual basis. NVIDIA stocks dip slightly despite strong earnings and a strong forecast for the current quarter. Analysts expect market participants to purchase the dip. The Japanese Yen wins back some ground as Bank of Japan Governor indicates the regulator will be willing to hike to support the FX market. Gold, Silver and other Metals all rise due to predictions of high retail and institutional demand and geopolitical tensions remaining high. NASDAQ – NVIDIA Surpasses Earnings Expectations! The NASDAQ took a sudden dip on Wednesday measuring 1.50%, however, investors quickly took the opportunity to purchase at the lower price as most indicators fell to give an oversold indication. As a result, the NASDAQ ended the day only slightly lower than the open price, but downward momentum remains this morning. The downward momentum is partially due to geopolitical tensions which are on the rise. Yesterday, Ukraine fired UK-made missiles into Russia and fired US-made the day before. There are also reports and speculations that Russia has sent ICB Missiles into Ukraine for the first time. However, reports are not confirmed, and there are signs of certain stocks recovering. Currently, there is no economic data which is driving the lack of demand, therefore investors are mainly concentrating on NVIDIA earnings. NVIDIA beat earnings expectations by 8.50% and revenue by 5.90%. Investors were particularly impressed by the significantly higher revenue which has almost doubled annually. In addition to this, the forecast given for the current quarter came in relatively strong. Lastly, the CEO, Jenson Huang, said to Bloomberg that demand exceeds supply but the company is setting in place measures to boost supply in order to meet the high level of demand. Taking into consideration the strong earnings, positive tone and upbeat forecasts for the coming quarter, many may wonder, “why is the stock declining 2.50% during this morning’s Asian session?”. This is partially due to the lower risk appetite, but also due to certain forecast expectations for NVIDIA not being met. The average NVIDIA forecast expectations from Wall Street firms was $37.1 billion, which NVIDIA comfortably surpassed. However, certain firms had expectations as high as $41 billion. Based on these higher expectations, the company underachieved and could trigger a lack of demand from this sector of Wall Street. Though many analysts continue to expect shareholders to purchase the lower price as long as the stock market will remain favorable.   EURJPY – BOJ To Consider Hike! The EURJPY declines for a second consecutive day, particularly gaining bearish momentum after this morning’s Bank of Japan press conference. The main takeaway from the press conference was that the Governor told journalists that the BOJ was willing to hike interest rates in the upcoming months but decisions will be made meeting by meeting. The Bank of Japan’s decision to raise interest rates in July was influenced in part by the weak Yen, which had driven up import costs and inflation. At the Europlace Financial Forum in Tokyo, Governor Kazuo Ueda emphasized that exchange-rate fluctuations are a key consideration in shaping economic and inflation forecasts. He noted that the central bank carefully examines what is driving these currency changes when assessing their impact. The EURJPY now trades below the 75-Bar Exponential Moving Average and below the 50.00 on the RSI. In addition to this, the exchange rate continues to form lower swing lows while the Euro underperforms against most currencies. These indications point towards a potential downward price movement.   Gold – Geopolitical Tensions Send Gold on a Bullish Path! Gold has increased in value for a fourth consecutive day, driven largely by geopolitical tensions. Additionally, the absence of significant US economic news has left markets uncertain about the Federal Reserve’s next move. Gold is currently witnessing an active buy signal from most momentum-based indicators due to the strong bullish momentum. For example, traders are able to see the price trading above the Bollinger Band, within a bullish moving average crossover and significantly high on most oscilators. However, investors should note as the price increases, the asset can become overbought and this may trigger a retracement, a correction or sideways price movement. In terms of geopolitical tensions, hopes for a Middle East ceasefire are being tempered by Russia’s revision of its nuclear doctrine, which aims to strengthen its borders after the US-approved long-range strikes from Ukraine reached deep into Russian territory. Meanwhile, Donald Trump’s re-election has yet to significantly influence the conflict, though markets remain optimistic about potential positive developments following his January 20 inauguration. 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 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.  
    • AMD Advanced Micro Devices stock with local support and resistance at 131.19, 138.37, and 146.97 at https://stockconsultant.com/?AMD
×
×
  • Create New...

Important Information

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