Back to Community
Help about ETF moving average technic

Hi!

I try to implement a simple technic. I buy SPY tracker when my short average is above the long and when the long is above, I sell SPY and I buy SX (an inverse SPY tracker)... but my code don't work, I don't understand. If someone have an idea to help me.

Thank you

JC

Clone Algorithm
1
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 5635f0cfa10e8b4ef475afb3
There was a runtime error.
2 responses

Try this

Clone Algorithm
15
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 56370b22c6ca723593bf938c
There was a runtime error.

Thank you very much but there is always un problem because sometimes SPY is shorted at the beginning and all the backtest is false... I don't really understand how the method order works and how the portfolio method works in order to check if I already have an equity of SPY or SX.

thanks a lot for your help and sorry for my english

JC