Hi GAT,
How can one insert a rule into pysystemtrade that results in a long position if greater than e.g., 5 day simple moving average and short if below? This is of course not what I am directly trying to test, but I found it embarrassing that I cannot seem to code such a simple thing into pysystem trade.
I've tried:
def trend(price):
trend = pd.DataFrame(np.where(pd.rolling_mean(price,5)>0,1,-1),index=price.index,columns=price.columns)
return trend
How can one insert a rule into pysystemtrade that results in a long position if greater than e.g., 5 day simple moving average and short if below? This is of course not what I am directly trying to test, but I found it embarrassing that I cannot seem to code such a simple thing into pysystem trade.
I've tried:
def trend(price):
trend = pd.DataFrame(np.where(pd.rolling_mean(price,5)>0,1,-1),index=price.index,columns=price.columns)
return trend