[MT4指标]求大侠帮写指标
1//@version=1
2// this code uses the Linear Regression Bull and Bear Power indicator created by RicardoSantos
3// and adds a signal line
4// Use : if signal line is changes color, you have your signal, green = buy, red = sell
5// Advice : best used with a zero lag indicator like ZeroLagEMA_LB from LazyBear
6// if price is above ZLEMA and signal = green => buy, price below ZLEMA and signal = red => sell
7study(title='[RS][NM]Improved Linear Regression Bull and Bear Power v01', shorttitle='BBP_NM', overlay=false)
8window = input(title='Lookback Window:', type=integer, defval=10)
9
10f_exp_lr(_height, _length)=>
11 _ret = _height + (_height/_length)
12
13h_value = highest(close, window)
14l_value = lowest(close, window)
15
16h_bar = n-highestbars(close, window)
17l_bar = n-lowestbars(close, window)
18
19bear = 0-f_exp_lr(h_value-close, n-h_bar)
20bull = 0+f_exp_lr(close-l_value, n-l_bar)
21direction = bull*2 + bear*2
22
2plot(title='Bear', series=bear, style=columns, color=maroon, transp=90)
24plot(title='Bull', series=bull, style=columns, color=green, transp=90)
25plot(title='Direction', series=direction, style=line, linewidth=3, color= direction > 0 ? green : red)