- ago
Hello everybody!

I am looking for ideas / inspiration to create a profitable auto-trading strategy to short stocks.

Do you have any to share?
0
1,012
Solved
13 Replies

Reply

Bookmark

Sort
- ago
#1
First a general observation: The dip-buyer/mean reversion type of systems work much better on the long side then the short side.

My favorite explanation: Panic/angst is much stronger than greed thus producing more exaggeration...

Second: There are these public Laurens Bensdorp strategies, some of them are working short strategies. Take a look at " Short Mean Reversion High Six-Day Surge"
1
Glitch8
 ( 12.53% )
- ago
#2
Ironically reversing the One Percent a Week to short SQQQ instead of going long TQQQ works great!
1
- ago
#3
SQQQ is an "inverse" ETF.

So (theoretically) any long strategy which works on QQQ should work if "inverted" as a short strategy on SQQQ exactly the same...

Usually we are looking for short strategies to "hedge" against risks if the markets go down. In such a situation a short strategy has a higher probability to make some money.

A short strategy for any inverse ETF does not hedge but increases the risk, because the ETF goes up in a crisis and the short strategy will lose money.
2
Best Answer
Glitch8
 ( 12.53% )
- ago
#4
I know, that's why I said "ironically."

Apparently, it performs better than the TQQQ long version.
1
Cone8
 ( 6.17% )
- ago
#5
QUOTE:
So (theoretically) any long strategy which works on QQQ should work if "inverted" as a short strategy on SQQQ exactly the same...
theoretically is the key word.

Example, last week SQQQ got out at break even, whereas TQQQ just missed that exit point and took a significant loss.
1
- ago
#6
This one tests out pretty good. Entry logic: sell short limit at one standard deviation (90 period) above the prior close / open on the entry date needs to be below 20ema (avoids event gaps). Exit logic: inverted knife juggler (2 day time stop / 5% target). Used SP500 WL in back test.

WARNING! - peeking code, see ensuing discussion.
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using finantic.Indicators; using WealthLab.Fundamental; namespace WealthScript9 { public class MyStrategy : UserStrategyBase { //create indicators and other objects here, this is executed prior to the main trading loop public override void Initialize(BarHistory bars) {          source = bars.Close;          stanDev = new StandardDeviation(source, 90);          multSource = source + stanDev;          _MA = new EMA(source, 20);          // plots          PlotIndicator(stanDev);          PlotIndicator(_MA, WLColor.Red, paneTag: "Price");                    foreach (IndicatorBase ib in _startIndexList)             if (ib.FirstValidIndex > StartIndex)                StartIndex = ib.FirstValidIndex;         StartIndex = 20; }       //execute the strategy rules here, this is executed once for each bar in the backtest history       public override void Execute(BarHistory bars, int idx)       {          int index = idx;          Position foundPosition0 = FindOpenPosition(0);          bool condition0;          if (foundPosition0 == null)          {             condition0 = false;             {                condition0 = true;             }             if (condition0 & idx > 90 & source[idx+1] < _MA[idx] )             {                val = multSource[idx];                _transaction = PlaceTrade(bars, TransactionType.Short, OrderType.Limit, val, 0, "sell sdev");             }          }          else          {             condition0 = false;             {                condition0 = true;             }             if (condition0)             {                Backtester.CancelationCode = 109;                if (idx - foundPosition0.EntryBar + 1 >= 2)                {          ClosePosition(foundPosition0, OrderType.Market, 0, "Cover after 2 bars");                }             }             condition0 = false;             {                condition0 = true;             }             if (condition0)             {                Backtester.CancelationCode = 109;                value = ((5.00 / 100.0) - 1.0)*-1;                ClosePosition(foundPosition0, OrderType.Limit,   foundPosition0.EntryPrice * value, "Cover at 5% profit target");             }          }       }              public override void NewWFOInterval(BarHistory bars)       {          source = bars.Close;       }              //declare private variables below       private StandardDeviation stanDev;       TimeSeries source, multSource;       IndicatorBase _MA;       private Double val, value;       private Transaction _transaction;           private List<IndicatorBase> _startIndexList = new List<IndicatorBase>(); } }




1
Glitch8
 ( 12.53% )
- ago
#7
This line looks like it's peeking into the future:

if (condition0 & idx > 90 & source[idx+1] < _MA[idx] )
1
- ago
#8
indeed, but could not figure a better way to reference the current bar's open. Should not effect real time results as the open would be observed before entry. Also this doesn't generate signals in meta strategies I'm assuming do to the statement in question. Any reasonable fix?
1
Glitch8
 ( 12.53% )
- ago
#9
The problem is though that you assign bars.Close to source, not bars.Open, if it was bars.Open then yes it wouldn't be peeking.

source = bars.Close;
1
- ago
#10
Lol, thought it was pretty good. But your definitely correct source is set to close not the open. Changing source to the open creates nothing special. Sorry guys.
1
Glitch8
 ( 12.53% )
- ago
#11
It's happened to all of us at one time or another! :D
1
Cone8
 ( 6.17% )
- ago
#12
In any case, if you're using the Open like that, it would be better adapt the program to ExecuteSessionOpen() and leave the Execute() method empty.

Generally, you only need to move the code to the ExecuteSessionOpen() and substitute sessionOpenPrice anywhere you use bars.Open[idx + 1].

For an example, upgrade to WL8 Build 43 and see One Percent a Week v3 in Sample Strategies.
1
- ago
#13
Awesome, thanks!
1

Reply

Bookmark

Sort