Louis Winthorp III

Automatic drawing Standard Deviation Channel

Category: Indicators By: Louis Winthorp III Created: February 22, 2019, 1:29 PM
February 22, 2019, 1:29 PM
Indicators
5 Comments
Automatic drawing Standard Deviation Channel

This indicator plots automatically a linear regression channel with 1 and 2 standard deviation lines of the last X periods.

//Stand Dev Channel - indicator purpose : to automatically adjust every new tradingday (new candle)
DefParam DrawOnLastBarOnly = true

LinRegres = LinearRegression[LinRegPeriod](close)
LinRegresSlope = LinearRegressionSlope[LinRegPeriod](close)
StDev = STD[LinRegPeriod](close)

y1 = LinRegres - ((LinRegPeriod-1)*LinRegresSlope)

//RegressionLine
DRAWSEGMENT(barindex-(LinRegPeriod-1),y1,barindex,LinRegres)coloured(255,0,0)
//Stdev+1
DRAWSEGMENT(barindex-(LinRegPeriod-1),y1+StDev,barindex,LinRegres+StDev)coloured(255,128,0)
//Stdev-1
DRAWSEGMENT(barindex-(LinRegPeriod-1),y1-StDev,barindex,LinRegres-StDev)coloured(255,128,0)
//Stdev+2
DRAWSEGMENT(barindex-(LinRegPeriod-1),y1+(2*StDev),barindex,LinRegres+(2*StDev))coloured(51,102,0)
//Stdev-2
DRAWSEGMENT(barindex-(LinRegPeriod-1),y1-(2*StDev),barindex,LinRegres-(2*StDev))coloured(51,102,0)

Return

Download
Filename: StandDevChannelprobuilder.itf
Downloads: 302
Louis Winthorp III
Louis Winthorp III Average
Operating in the shadows, I hack problems one by one. My bio is currently encrypted by a complex algorithm. Decryption underway...
Author’s Profile

Comments

Trimicha
5 years ago
#

Hi, when I copy the code, i get an error message that LinRegPeriod is not defined. Does anyone know how to solve that?

Zasinas2000
5 years ago
#

Hi allo I am not sure I am doing it correctly, but this adds to proreal as an indicator. How to ad it as a study, so it would draw lines on the chart?

Choliver
8 years ago
#

Bonjour et merci pour cet indicateur. Toutefois, il me semble qu'il est unidirectionnel. Par exemple ce matin 8 mars, sur un graphe CFD Dax en 5 min (10 unités), il devrait avoir changé d'orientation en passant d'une orientation haussière à une orientation baissière. Il est finalement resté en orientation haussière toute la matinée. Nicolas, pouvez vous me confirmer qu'il y a effectivement un souci please ? Merci

Louis Winthorp III
7 years ago
#

Hi Choliver, you are right, there is a problem with the drawing instruction when the slope is = 0 THEN y1 = LinRegres - ((LinRegPeriod-1)*LinRegresSlope) ELSE y1 = LinRegres - ((LinRegPeriod-1)*LinRegresSlope) ENDIF with : y1 = LinRegres - ((LinRegPeriod-1)*LinRegresSlope) I'll ask Nicolas to update the code.

Nicolas
7 years ago
#

File and code are updated.

ProRealCode ProRealCode
Loading...