- ago
I always check daily, weekly and monthly to find out the robustness of the strategy.

But from weekly to monthly is a big step in fact. Weekly is past quickly, monthly is long waiting. Why not bi-weekly?

From a programmer's view, this seems not super complicated to add.
But can be wrong :-)



4
706
Solved
15 Replies

Reply

Bookmark

Sort
- ago
#1
Why not 3-day or 3-weekly? I think this is non-standard, less popular and an added confusion (not including potential bugs).
0
- ago
#2
It is some kind of optimization for a setup to see when the rotation is best done.

The indicator goes from low values to higher values within a week for example.
But maybe it is better to give the stock a bit more time.

A full month later, can be a long period when swingtrading. That's why i tought about bi-weekly.

Not sure if this is not popular.
If it's available, it will be used.
Just an out-of-the-box idea.
0
Cone8
 ( 27.64% )
- ago
#3
It's not possible to create options for all tools to test every out-of-the-box idea that everyone has. However, you can do that by digging in with C# Code. Here's a Rotation Strategy that let's you pick the signal days of the week. (I just realized that I fell into an English trap and interpreted "bi-weekly" as "twice per week, instead of every 2 weeks.)

It automatically adjusts the position size for the backtest, but make sure to bump up Margin or set the basis price to the open of the next bar so that you don't miss trades due to gap openings. Let us know how it works out!

p.s.
This strategy uses RSI as the indicator. As always with these coded Rotation strategies, you can easily change the indicator by just modifying this statement in Initialize: _rsi = RSI.Series(bars.Close, Parameters[1].AsInt);

CODE:
using WealthLab.Backtest; using System; using System.Text; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; using System.Linq; namespace WealthScript2 {    public class PickYourDaysRotation : UserStrategyBase    {             public PickYourDaysRotation()       {          AddParameter("n Positions", ParameterType.Int32, 5, 2, 8, 1);          AddParameter("Indicator Period", ParameterType.Int32, 10, 2, 20, 2);                       Parameter p = AddParameter("Mon", ParameterType.Int32, 0, 0, 1, 1);          p.Hint = "Signal on Mondays";          p = AddParameter("Tues", ParameterType.Int32, 0, 0, 1, 1);          p.Hint = "Signal on Tuesdays";          p = AddParameter("Wednes", ParameterType.Int32, 1, 0, 1, 1);          p.Hint = "Signal on Wednesdays";                   p = AddParameter("Thur", ParameterType.Int32, 0, 0, 1, 1);          p.Hint = "Signal on Thursdays";          p = AddParameter("Fri", ParameterType.Int32, 1, 0, 1, 1);          p.Hint = "Signal on Fridays";       }       public override void Initialize(BarHistory bars)       {                   _Npositions = Parameters[0].AsInt;          StartIndex = Parameters[1].AsInt * 3;          for (int n = 2; n <= 6; n++)          {             DayOfWeek dow = (DayOfWeek)(n - 1);             if (Parameters[n].AsInt == 1)                _dow.Add(dow);          }                    _rsi = RSI.Series(bars.Close, Parameters[1].AsInt);          bars.Cache["rsi"] = _rsi;       } public override void BacktestBegin() { _dow = new List<DayOfWeek>(); } public override void PreExecute(DateTime dt, List<BarHistory> participants)       {          if (!_dow.Contains(dt.DayOfWeek))             return;                    foreach (BarHistory bh in participants)          {             TimeSeries ind = (TimeSeries)bh.Cache["rsi"];             int idx = GetCurrentIndex(bh);             bh.UserData = ind[idx];          }                 //sort the candidates by value (lowest to highest)          participants.Sort((a, b) => a.UserDataAsDouble.CompareTo(b.UserDataAsDouble));          //keep the top n candidates (lowest rsi)          _candidates.Clear();          for (int n = 0; n < _Npositions; n++)             _candidates.Add(participants[n]);                    foreach (Position pos in OpenPositionsAllSymbols)          {             if (!_candidates.Contains(pos.Bars))                ClosePosition(pos, OrderType.Market);          }          foreach (BarHistory bh in _candidates)          {             if (!HasOpenPosition(bh, PositionType.Long))             {                Transaction t = PlaceTrade(bh, TransactionType.Buy, OrderType.Market);                t.Quantity = Math.Truncate(CurrentEquity / _Npositions / bh.Close[GetCurrentIndex(bh)]);             }          }       }                    public override void Execute(BarHistory bars, int idx)       { }       int _Npositions = 5;       RSI _rsi;       static List<DayOfWeek> _dow;       static List<BarHistory> _candidates = new List<BarHistory>();       static List<string> _openSymbols = new List<string>();    } }
0
Best Answer
- ago
#4
@cone, thanks for the script. I tested it.
The APR can change upto 2 percent depending on the day the rebalance is done.

But you were correct: the goal is not twice per week but really twice per month.

Changing the RSI into another indicator didn't work, even with some help of chat gpt.
Have to start c# from 0, not easy.

Albeit, it was interesting to try but my mean goal is still to test daily, weekly over bi-weekly into monthly while trying rotation strategy.

But I understand that you cannot execute every request. But hope you will the votings to see if other people find this interesting.

@eugene: the edge of trading is probably in the non-standard :-)
0
Glitch8
 ( 12.33% )
- ago
#5
I don't see why we can't add a bi-weekly option. I guess the second rebalance would be in the first trading date which is the 15th or later?
0
- ago
#6
Indeed, for this month it would be on monday the 13th and next month the 17th.

Which can be more tricky to program than just every monday and every first of the month, I can imagine.
0
Cone8
 ( 27.64% )
- ago
#7
QUOTE:
I guess the second rebalance would be in the first trading date which is the 15th or later?
I was thinking even/odd week numbers, to perform a rotation at the end of every other week in order to align more with the regular Weekly rebalance. Of course the 1 and 15 option would be good too... let's get all of the out-of-the-box options in there! 😂
0
Cone8
 ( 27.64% )
- ago
#8
Seems that there's a lot of interest in running rotation on intraday scales, now that it's possible to trade it with the Strategy Monitor.

Add these rebalance frequencies to the list:
- Hourly
- 30 minutes
- 15 minutes
- do we need to go further?
0
- ago
#9
Rotating every hour? Amazing. :-)
I didn't know this was making any sense.

If someone wants to share an example..
0
Glitch8
 ( 12.33% )
- ago
#10
Personally I'd get dizzy!
0
- ago
#11
I wish there was a DOWNVOTE button 👎 to demotivate feature requests not "making any sense". 🤷‍♂️
0
Cone8
 ( 27.64% )
- ago
#12
I'd agree that rotation every 30 minutes or less is probably a bad idea, but you don't know that until you test it.
Of course, someone motivated to do that can test it now with a C# Coded rotation strategy.

What's not making sense? Be specific.
0
- ago
#13
If we're collecting ideas for this feature request, I’d propose making the ability to select which day of the week it rebalances or have an option that it rebalances every n days.,
0
Cone8
 ( 27.64% )
- ago
#14
You can't have a n-day rebalance because there's no starting reference... can you think of one that would be consistent?
0
- ago
#15
There is (almost) no bad idea. It can make sense. If a rotation strategy is working on daily, weekly or monthly scale, it can work on hourly data also.

But the first thing I think of are the fees, the profits will be quite low.
There are zero-cost brokers but I heard you have a bad spread.

How many WL-users are trading with a zero-cost broker and are going to use a rotation strategy with a time frame less than a week or day?

But if it's just some extra line of codes, why not. I will try it some day.
0

Reply

Bookmark

Sort