Short selling in trading, regime

in short selling for trading section:10, unit:9  which regime is used with below function as there many regime columns: such as regime_change & regime_breakout.

thank you.



ef signal_fcstmt(regime,st,mt):

    '''

    This function overimposes st/mt moving average cross condition on regime 

    it will have an active position only if regime and moving averages are aligned

    Long : st-mt > 0 & regime == 1

    Short: st-mt < 0 & regime == -1

    

    '''

    # Calculate the sign of the stmt delta

    stmt_sign = np.sign((st - mt).fillna(0))

    # Calculate entries/exits based on regime and stmt delta

    active = np.where( np.sign( regime* stmt_sign) == 1,1,np.nan)

    signal = regime * active

    return signal

Hi Mohammad,



The function does not calculate the regime itself, it merely uses the regime data whatever is passed to it as a parameter.



The usage of this function can be seen later in cell 14 where 

signal_fcstmt(regime=data['r_regime_floorceiling'], st=r_st_ma, mt=r_mt_ma)

is called which indicates that the relative series is used with the floor/ceiling method of calculating the regime.



Hope this helps!

Let me know if you have any further questions.

Thx Gaurav, 

yes its clear now.