- ago
I'm stumbling across a little problem.
I am trying to use something like the indicator "% of Stocks above the 50 sma" on Nasdaq 100. However, the line is a long term rising line instead of a line that moves between 0%-100%.
What's going wrong here?

CODE:
private IndicatorBase ind1; public override void Initialize(BarHistory bars) { ind1 = new CompIndPctExtreme(bars,"NASDAQ 100",2010,new SMA(bars.Close,50),"Above",90.00); PlotIndicator(ind1, WLColor.FromArgb(255,0,128,0), PlotStyle.Line, false, "% of stocks above 50 sma"); }
0
292
Solved
2 Replies

Reply

Bookmark

Sort
Cone8
 ( 25.44% )
- ago
#1
When I create that indicator, it does go between 0 and 100, but it's actually the % of instruments whose 50 sma is above the value you selected.

The indicator that you're really looking for is CompAboveBelow - Close above the SMA(50) -



CODE:
using WealthLab.IndexLab; using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript2 { 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) {          ind1 = new CompAboveBelow(bars,"NASDAQ 100",2000,new TimeSeriesIndicatorWrapper(bars.Close),new SMA(bars.Close,50),"Above");          PlotIndicator(ind1, WLColor.FromArgb(255,140,140,140), PlotStyle.Line); } //execute the strategy rules here, this is executed once for each bar in the backtest history public override void Execute(BarHistory bars, int idx) { if (!HasOpenPosition(bars, PositionType.Long)) { //code your buy conditions here } else { //code your sell conditions here } } //declare private variables below       private IndicatorBase ind1; } }
1
- ago
#2
Cone is right, just wanted to add that CompAboveBelow is a later addition (IL B2).
0
Best Answer

Reply

Bookmark

Sort