I wrote a small strategy to find high beta stocks, but it doesn't seem to work in the screener based on the Beta indicator. However, signals are found based on Beta when backtesting. And, the APTR indicator works fine in the screener (and when backtesting). When backtesting, I used daily scale and WD NASDAQ 100 as the dataset.
The Beta indicator uses an external symbol, so perhaps this is not supported in the screener?
In the screener, I used both the NASDAQ 100 and Entire US Stock Market for the universe and nothing is found for Beta, but finds signals for APTR. Here's some test code. Be sure to comment the PlaceTrade line for APTR signals if you want to see nothing is found for Beta in the screener...
The Beta indicator uses an external symbol, so perhaps this is not supported in the screener?
In the screener, I used both the NASDAQ 100 and Entire US Stock Market for the universe and nothing is found for Beta, but finds signals for APTR. Here's some test code. Be sure to comment the PlaceTrade line for APTR signals if you want to see nothing is found for Beta in the screener...
CODE:
using WealthLab.Backtest; using WealthLab.Core; using WealthLab.Indicators; using WealthLab.TASC; namespace WealthLabStrategies.Screener { public class HighBetaScreener : UserStrategyBase { public HighBetaScreener() { ParamLowerBeta = AddParameter("Lower Beta", ParameterType.Double, 1.5, 1.0, 5.0, 0.1); ParamBetaDelta = AddParameter("Beta Delta", ParameterType.Double, 3.5, 1.0, 5.0, 0.1); } private Beta BetaValues { get; set; } private Parameter ParamBetaDelta { get; } private double BetaDelta { get; set; } private Parameter ParamLowerBeta { get; } private double LowerBeta { get; set; } private APTR Aptr { get; set; } public override void Initialize(BarHistory bars) { LowerBeta = ParamLowerBeta.AsDouble; BetaDelta = ParamBetaDelta.AsDouble; BetaValues = Beta.Series(bars, "QQQ", 20); Aptr = APTR.Series(bars, 20); PlotIndicator(BetaValues); PlotIndicator(Aptr); StartIndex = 20; } public override void Execute(BarHistory bars, int idx) { // we only want the last bar if (idx < bars.Count - 1) { return; } var position = FindOpenPosition(-1); if (position == null) { // The screener won't find anything based on beta. But, when this strategy is back-tested then the // back-tester finds signals using the same dataset (I used NASDAQ 100) if (BetaValues[idx] >= LowerBeta && BetaValues[idx] <= LowerBeta + BetaDelta) { PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, -1, "High Beta"); } else if (Aptr[idx] >= 2) // this works in both the screener and when running the strategy in back-tester { // comment the following if you want to test using only using Beta PlaceTrade(bars, TransactionType.Buy, OrderType.Market, 0, -1, "High APTR"); } } else { ClosePosition(position, OrderType.Market, 0, "Exit"); } } } }
Rename
Yes, it was the external symbol, please try it again now.
Works perfect! Screener results match back-testing. Thanks!
Your Response
Post
Edit Post
Login is required