Linear regression - filtering of unnecessary alerts

I use linear regression to create shorts or longs that are as accurate as possible. Unfortunately, I can't filter out unnecessary intermediate signals. Unnecessary alerts are present, especially with longer trends. Is there a way to improve my script to filter out these alerts. I've also tried countless indicators like RSI, and others. The problem here is that the indicator signals in one section unfortunately do not match in the other. Therefore, a solution with direct filtering on the candles would be the better solution for me. Thank you for an interesting idea.

Here my code:

// Linear regression Candels signal_length_o = input.int(title="Signal Smoothing", minval = 1, maxval = 200, defval = 7, group="Humble LinReg Candles") sma_signal_o = input.bool(title="Simple MA (Signal Line)", defval=true, group="Humble LinReg Candles") lin_reg = input.bool(title="Lin Reg", defval=true, group="Humble LinReg Candles") linreg_length = input.int(title="Linear Regression Length", minval = 1, maxval = 200, defval = 5, group="Humble LinReg Candles") bopen = lin_reg ? ta.linreg(open, linreg_length, 0) : open bhigh = lin_reg ? ta.linreg(high, linreg_length, 0) : high blow = lin_reg ? ta.linreg(low, linreg_length, 0) : low bclose = lin_reg ? ta.linreg(close, linreg_length, 0) : close r = bopen < bclose signal_o = sma_signal_o ? ta.sma(bclose, signal_length_o) : ta.ema(bclose, signal_length_o) plotcandle(r ? bopen : na, r ? bhigh : na, r ? blow: na, r ? bclose : na, title="LinReg Candles", color=color.green, wickcolor=color.green, bordercolor=color.green, editable= true) plotcandle(r ? na : bopen, r ? na : bhigh, r ? na : blow, r ? na : bclose, title="LinReg Candles", color=color.red, wickcolor=color.red, bordercolor=color.red, editable= true) plot(signal_o, color=color.white) plotchar( signal_o[3] > signal_o[2] and // 3. Kerze > 2. Kerze signal_o[2] > signal_o[1] and // 2. Kerze > 1. Kerze signal_o[1] >= signal_o[0] and // 1. Signal >= Signal bopen < signal_o and // Open < Signal bopen[1] > bclose[1] and // Kerze rot[1] bopen[0] < bclose[0] and // Kerze grün[0] not ta.cross(open[1], signal_o) and not ta.cross(low[1], signal_o) and not ta.cross(open, signal_o) and not ta.cross(low, signal_o) , "Buy", "O", location.bottom, color.lime, size = size.tiny) plotchar( signal_o[3] < signal_o[2] and // 3. Kerze < 2. Kerze signal_o[2] < signal_o[1] and // 2. Kerze < 1. Kerze signal_o[1] <= signal_o[0] and // 1. Signal <= Signal bopen > signal_o and // Open > Signal bopen[1] < bclose[1] and // Kerze grün[1] bopen[0] > bclose[0] and // Kerze rot[0] not ta.cross(close[1], signal_o) and not ta.cross(high[1], signal_o) and not ta.cross(open, signal_o) and not ta.cross(high, signal_o) , "Sell", "O", location.top, color.red, size = size.tiny) 

See Chart

0

1 Answer

You should try with greater value like this one (100):

enter image description here

This will give you less entry points.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like