Default: "sma" lazybear (value, optional): Use LazyBear's TradingView implementation. Default: True mamode (value, optional): Which MA to use. Default: True asint (value, optional): Use integers instead of bool. Default: 0 Kwargs: tr (value, optional): Use True Range for Keltner Channels. Default: "sma" offset (int): How many periods to offset the result. Default: 6 mamode (str): Only "ema" or "sma". Default: 12 mom_smooth (int): Smoothing Period of Momentum. Default: 1.5 mom_length (int): Momentum Period. Default: 20 kc_scalar (float): Keltner Channel scalar. Default: 2 kc_length (int): Keltner Channel period. Default: 20 bb_std (float): Bollinger Bands Std. category = "momentum" # Detailed Squeeze Series if detailed : pos_squeeze = squeeze neg_squeeze = squeeze [ squeeze KC_LOW) and (BB_HIGH KC_HIGH) NO_SQZ = !SQZ_ON and !SQZ_OFF Args: high (pd.Series): Series of 'high's low (pd.Series): Series of 'low's close (pd.Series): Series of 'close's bb_length (int): Bollinger Bands period. fillna ( method = kwargs, inplace = True ) # Name and Categorize it _props = "" if use_tr else "hlr" _props += f "_ df = DataFrame ( data ) df. fillna ( method = kwargs, inplace = True ) no_squeeze. fillna ( method = kwargs, inplace = True ) squeeze_off. fillna ( method = kwargs, inplace = True ) squeeze_on. fillna ( kwargs, inplace = True ) if "fill_method" in kwargs : squeeze. fillna ( kwargs, inplace = True ) no_squeeze. fillna ( kwargs, inplace = True ) squeeze_off. fillna ( kwargs, inplace = True ) squeeze_on. shift ( offset ) # Handle fills if "fillna" in kwargs : squeeze. shift ( offset ) no_squeeze = no_squeeze. shift ( offset ) squeeze_off = squeeze_off. shift ( offset ) squeeze_on = squeeze_on. u ) no_squeeze = ~ squeeze_on & ~ squeeze_off # Offset if offset != 0 : squeeze = squeeze. lower () = "ema" : squeeze = ema ( momo, length = mom_smooth ) else : # "sma" squeeze = sma ( momo, length = mom_smooth ) # Classify Squeezes squeeze_on = ( bbd. b squeeze = linreg ( close - avg_, length = kc_length ) else : momo = mom ( close, length = mom_length ) if mamode. columns = simplify_columns ( kch ) if lazybear : highest_high = high. columns ] # Calculate Result bbd = bbands ( close, length = bb_length, std = bb_std, mamode = mamode ) kch = kc ( high, low, close, length = kc_length, scalar = kc_scalar, mamode = mamode, tr = use_tr ) # Simplify KC and BBAND column names for dynamic access bbd. pop ( "lazybear", False ) mamode = mamode if isinstance ( mamode, str ) else "sma" def simplify_columns ( df, n = 3 ): df. pop ( "detailed", False ) lazybear = kwargs. pop ( "asint", True ) detailed = kwargs. setdefault ( "tr", True ) asint = kwargs. Def squeeze ( high, low, close, bb_length = None, bb_std = None, kc_length = None, kc_scalar = None, mom_length = None, mom_smooth = None, use_tr = None, mamode = None, offset = None, ** kwargs ): """Indicator: Squeeze Momentum (SQZ)""" # Validate arguments bb_length = int ( bb_length ) if bb_length and bb_length > 0 else 20 bb_std = float ( bb_std ) if bb_std and bb_std > 0 else 2.0 kc_length = int ( kc_length ) if kc_length and kc_length > 0 else 20 kc_scalar = float ( kc_scalar ) if kc_scalar and kc_scalar > 0 else 1.5 mom_length = int ( mom_length ) if mom_length and mom_length > 0 else 12 mom_smooth = int ( mom_smooth ) if mom_smooth and mom_smooth > 0 else 6 _length = max ( bb_length, kc_length, mom_length, mom_smooth ) high = verify_series ( high, _length ) low = verify_series ( low, _length ) close = verify_series ( close, _length ) offset = get_offset ( offset ) if high is None or low is None or close is None : return use_tr = kwargs.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |