inputs: Price( Close), Length( 25), Displace( 0), upColour(cyan), downColour(magenta), unchangedColour(yellow), colourDeltaBar(1); variables: LinReg( 0 ) ; if Displace >= 0 or CurrentBar > AbsValue( Displace ) then begin LinReg = LinearRegValue( Price, Length, 0 ) ; Plot1[Displace]( LinReg, "LinReg" ) ; { Alert criteria } if Displace <= 0 then begin if Price > LinReg and LinReg > LinReg[1] and LinReg[1] <= LinReg[2] then Alert( "Indicator turning up" ) else if Price < LinReg and LinReg < LinReg[1] and LinReg[1] >= LinReg[2] then Alert( "Indicator turning down" ) ; end ; end ; { Color criteria } if LinReg > LinReg[1] then SetPlotColor[colourDeltaBar]( 1, upColour ) else if LinReg < LinReg[1] then SetPlotColor[colourDeltaBar]( 1, downColour ) else SetPlotColor[colourDeltaBar]( 1, unchangedColour );