Here you can search through the pages of this Namespace, their attachments and the files uploaded to the system.
Note: the results will only display the items you have permissions to read.
[...] position object that you want to split. WealthScript maintains a list of positions (actually, even 2 in WL6 - the usual list and a separated ActivePositions list which is self-descriptive), and whenever a new trade is completed a new position is added to this list. You access positions by "index number", which is the index into this list. The index starts at zero and ends at Positions.Count – 1 . The percentToRetain parameter controls how the position is split. After SplitPosition is called, a new position is added to the end of the position list. percentToRetain determines [...]
[...] namespace WealthLab.Strategies
{
public class CoronaCharts : WealthScript
{
public const double twoPi = 2 * Math.PI;
public const double fourPi = 4 * Math.PI;
public class ArrayHolder
{ // current, old, older
internal double I, I2, I3;
internal double Q, Q2, Q3;
internal double R, R2, R3;
internal double Im, Im2, Im3;
internal double A;
internal double dB, dB2;
}
// Keep cntMax fifo samples and find the Highest and Lowest lead for samples in the list
private void PhaseList(ref ArrayList fifo, int cntMax, double lead, out double H, [...]
[...] 1;
hDayClose = Synchronize( hDayClose ) >> 1;
hDayLow = Synchronize( hDayLow ) >> 1;
var hR1 = ( 2 * hPivot - hDayLow );
var hS1 = ( 2 * hPivot - hDayHigh );
var hR2 = ( hPivot - ( hS1 - hR1 ) );
var hS2 = ( hPivot - ( hR1 - hS1 ) );
var hR3 = 2 * hPivot + (hDayHigh - (hDayLow * 2));
var hS3 = 2 * hPivot - ((hDayHigh * 2) - hDayLow); var hRM1 = (hR1 - hPivot)/2 [...]
[...] CreateParameter("Exit after", 20, 1, 50, 1);
paramDailyLength1 = CreateParameter("Daily Length 1",12,2,300,20);
paramDailyLength2 = CreateParameter("Daily Length 2",26,2,300,20);
paramWeeklyLength1 = CreateParameter("Weekly Length 1",60,2,300,20);
paramWeeklyLength2 = CreateParameter("Weekly Length 2",130,2,300,20);
}
protected override void Execute()
{
if( Bars.Scale != BarScale.Daily )
{
DrawLabel(PricePane, [...]
[...] includes a "Skipped trade solution" that helps overcome it by adjusting the basis price. Workaround #2: For AtMarket orders, by overloading the market order with a limit order at the opening price, you can get all the trades if you run without commissions. With commissions, bump up Margin Factor a bit (e.g. 1.01) to ensure you get all the trades. Add this method to your Strategy class: /* Add this BuyAtMarket method and nothing else needs to be changed */
// It uses a limit order that executes at the opening price so that the basis price is the same as the execution [...]
[...] Bars.FindNamedSeries("Commercial Short");
DataSeries diff = cl - cs;
RSI rsiDiff = RSI.Series( diff, 2 );
rsiDiff.Description = "RSI on Difference between Commercial Long/Short";
if( cl != null && cs != null )
{
ChartPane p2 = CreatePane( 25, true, true );
ChartPane p1 = CreatePane( 25, true, true );
ChartPane p = CreatePane( 25, true, true ); PlotSeries( p, cl, Color.Green, LineStyle.Solid, 1 );
PlotSeries( p, cs, Color.Red, LineStyle.Solid, 1 );
PlotSeries( p1, diff, Color.Blue, LineStyle.Histogram, [...]
[...] "BandPassSeries(" + ds.Description + "," + period + "," + delta + ")");
double beta = Math.Cos(2 * Math.PI / period);
double gamma = 1/ Math.Cos(4 * Math.PI * delta / period);
double alpha = gamma - Math.Sqrt(gamma * gamma - 1d);
for (int bar = 2; bar bar = 0.5 * (1 - alpha) * (ds bar - ds bar - 2 )
+ beta * (1 + alpha) * res bar - 1 - alpha * res bar - 2 ;
}
return res;
}
protected override void Execute()
{
[...]
[...] the data, and how stable it is over time. Figure 1. Typical long entries following spike below -2 standard deviations on the Daily chart of AAPL (Apple). We created a bare-bones system to put to test the idea that a spike below -2 provides a long entry timing signal (we'll skip the opposite signal this time). Figure 1 illustrates some typical entries. Its only exit rule is to "Exit after fixed bars". Looking ahead, this parameter had the biggest impact on the system's net profit (as shown on Figure 2). Then [...]
[...] CreateParameter("SMA period", 50, 10, 200, 10);
paramMom = CreateParameter("Momentum period", 10, 2, 30, 2);
paramHi = CreateParameter("Highest period", 20, 10, 100, 10);
paramProximity = CreateParameter("Within SMA %", 2, 1, 5, 1);
paramPullback = CreateParameter("Pullback %", 2, 2, 18, 2);
paramRecovery = CreateParameter("Approaching %", 2, 2, 6, 2);
paramTimeout [...]
[...] signals to buy on the open in the Alerts view as on Figure 1:
Figure 1. A view of the Alerts tab with 2 signals with the highest reading of the RS5 oscillator. If you wish to visualize the oscillators, double click on any trading signal. Wealth-Lab will plot them on a chart like Figure 2 illustrates:
Figure 2. A sample plot of the RS4 and RS5 oscillators built using author’s default set of 11 index funds on the daily chart of QQQ. Index fund data provided by Tiingo. On a closing note, simply download public [...]
[...] _stoSmooth;
public PutCallRatioIndicator()
{
_rsiPeriod = CreateParameter("Fast RSI Period", 5, 2, 30, 1);
_wmaPeriod = CreateParameter("Fast WMA Period", 5, 2, 10, 1);
_devs = CreateParameter("SD Multiple", 1.3, 1, 2, 0.1);
_slowRainbowPeriod = CreateParameter("Slow Rbw Period", 4, 1, 10, 1);
_wmaSlow = CreateParameter("Slow Smooth Period", 2, 1, 10, 1);
_rsiPer = CreateParameter("Slow IF RSI Period", 8, 1, 20, 1);
_stoPer = CreateParameter("Stoch [...]
[...] entering in a trend continuation following a pullback after a breakout. This pattern (widely known as "1-2-3 pattern") could be programmed to apply to intraday or daily charts alike. Our rendition targets daily charts. Since the rules didn't put much emphasis on exits, leaving this to the trader, we added a simple profit target. Below you can find the complete trading system's rules: Entry:
Wait for a 5-day close-to-close uptrend. If the closing prices retrace 50% of the uptrend's distance (±1 percentage point) over the next 10 bars, a valid pullback has formed. Look [...]
FIR — 0.8%
[...] Parameter Description
source
Price series
weights
Weights as string e.g. "1,2,2,1"
weights
Alternatively, specify weights as double[] array
Warning!
Weights must not sum to zero (e.g. -1, -2, 2, 1 would result in error).
Description FIR stands for Finite Impulse Response Filter. This is a type of smoothing filter that assigns different weights to price data a number of bars in the past. Pass the Price Series you want to apply [...]
[...] commissions). More so, with significantly lower risk (maximum drawdown -13% vs. -59.3%) and market exposure (39.2% vs. 100%). Figure 2 highlights system’s weakness: it can lose to Buy&Hold in strong bull markets. On a closing note, make sure to load enough historical data to run this backtest. Indicators like EMA (used as the broad market direction condition) require a fair amount of seed data (here: three times the 100-bar EMA period) to stabilize their calculation before they can be used reliably in a trading system.
Code using System;
using [...]
[...] _arsiPeriod;
public ShortDivergence()
{
_arsiPeriod = CreateParameter("ARSI_Period", 10, 2, 200, 20);
_rsiPeriod = CreateParameter("RSI Period", 4, 2, 30, 1);
_emaPeriod = CreateParameter("EMA Period", 4, 2, 10, 1);
} public DataSeries SVEInvFisherRSI(int rsiPeriod, int emaPeriod)
{
DataSeries rbw = WMA.Series(Close, 2);
DataSeries sve = 5 * rbw;
for (int w = 4; w >= -4 ; w--)
{
rbw = WMA.Series(rbw, 2);
if [...]
[...] ZigZag(this, 8, true, PeakTroughMode.Percent);
zg.Draw(Color.Gray, Color.Gray, LineStyle.Solid, 2);
// ZigZag for a single series
ZigZag zz = new ZigZag(this, Close, 8, true, PeakTroughMode.Percent);
zz.Draw( Color.Blue, Color.Red, LineStyle.Solid, 2);
zz.PlotPeakTrough(Color.Blue, 3);
// Zigzags aren't just for the standard price series. You can apply them to any DataSeries like an indicator
DataSeries rsi = RSI.Series(Close, 14);
ChartPane rsiPane = CreatePane(50, true, true);
PlotSeries(rsiPane, [...]
[...] directly instead of using the DivergencePlotter routines. Note that divergence is detected for the 2 most-recent peaks in the ds1 (price) series. The logic is designed to find peaks/troughs in ds2 (oscillator) that are within proximity bars of the peaks/troughs of ds1 . For this reason, it may occur that the diverging lines are drawn through other oscillator peaks/troughs since these are ignored.
Interpretation The interpretation for positive/negative divergence is based on the article "Trading Divergences" by Sylvain Vervoot in the Feb 2008 issue of TASC magazine. [...]
[...] Community Indicators , from the Extensions section of our website and restart Wealth-Lab. Figure 2 . For DAX stocks, the optimum trade duration was between roughly 2 to 5 months as discovered in optimization. After making sure the libraries are up to date, the Volume Flow (VFI) indicator used in the article code will appear under the TASC Magazine Indicators group. It can be plotted on a chart and be used as an entry or exit condition in a Rule-based Strategy without having to program a line of code yourself. using System;
using System.Collections.Generic;
using [...]
[...] bar's low” ), a pivot high/low point is different from the more traditional one which is more like “1-2 consecutive lower lows followed by 1-2 consecutive higher lows”. Further, text and code is not in line with article's own Figure 2: the illustration leans towards the traditional definition. Compare that to a ZigZag swing chart on author's Figure 1. Yes, that's actually another, "undocumented" 5th way to build a swing chart based on absolute or relative (percentage) movements from an established top or bottom. [...]
[...] assembled in Wealth-Lab in a drag and drop fashion from the building blocks known as Rules. On Figure 2 we show a way to achieve better flexibility through “Multi Condition Group” feature. In essence it triggers the entry signal when the Engulfing and one of Bollinger Band conditions occurred not on the same day exactly but close enough to each other i.e. within a few days.
Figure 2. All conditions required to assemble the trading system are in place.
For those of you who like to have a more finer control we publish the translated code [...]
[...] both the entries and exits. An entry is triggered when price reaches the highest high of the previous 2 bars after an SMARSI(3) below 20, whereas the exit occurs at the close of the bar on which the low reaches the lowest low of the previous 2 bars. This trigger strategy often entered and exited a prospective trade 1 bar earlier than waiting for the indicator to cross the 20/80 levels in the opposite direction. To protect against unforeseen disasters, we implemented a 5% stop loss. While the Donchian channels weren’t used in the trading strategy, [...]
[...] paramSqueezeLookback; public SVESmoothedVolatilityBands()
{
paramBandAvg = CreateParameter("Band average", 20, 2, 100, 1);
paramMiddleLine = CreateParameter("Middle line period", 20, 2, 100, 1);
paramDevFact = CreateParameter("Deviation factor", 2.4, 0.2, 5.0, 0.2);
paramLowBAdj = CreateParameter("Low Band Adj.", 0.9, 0.1, 3.0, 0.1);
paramSqueezeLookback = CreateParameter("Squeeze lookback", 200, 5, 150, 1 );
}
protected override void Execute()
{
int [...]
[...] the "Download" button in Wealth-Lab's "Open Strategy" dialog. Figure 1. A Wealth-Lab Developer 6.2 chart showing the Price Zone Oscillator strategy in action applied to a Daily chart of Walt Disney Co. ( DIS ). Although the new complementary oscillator implementation is pretty straightforward, the accompanying system rules have to function in different market regimes and cover such events as positive and negative price/oscillator divergences. The complexity of their implementation is hidden in an additional library, "Community Components" , available for download [...]
[...] StrategyParameter paramPeriod;
public VZOStrategy()
{
paramPeriod = CreateParameter("VZO Period", 14, 2, 252, 2);
}
protected override void Execute()
{
int period = paramPeriod.ValueInt;
DataSeries R = new DataSeries( Bars, "R" );
DataSeries TV = EMA.Series( Volume, period, EMACalculation.Modern );
DataSeries VZO = new DataSeries( Bars, "VZO" );
ADX adx = ADX.Series( Bars,14 );
EMA ema = EMA.Series( Close, 60, EMACalculation.Modern );
for(int bar = period; bar bar = Math.Sign( Close bar - Close bar-1 ) * Volume [...]
[...] (see below) by simply clicking the "Download" button in Wealth-Lab's "Open Strategy" dialog (Figure 2). Figure 2. How to download trading strategies in Wealth-Lab 6.
WealthScript Code (C#)
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators; namespace WealthLab.Strategies
{
public class Star201301 : WealthScript
{
private StrategyParameter paramEntryType;
private StrategyParameter paramExitType;
private StrategyParameter paramFixedBars;
private [...]
[...] simulation ($5000 size, $8 1-way commissions) on the Dow 30 symbols over the last 6 years yielded the 2-Parameter optimization curve in Figure 1. Figure 1. While the optimization didn’t inspire confidence in the strategy’s stability over a wide range of parameters, ATR Factors around 2 helped improve the overall profit, while the Period did not affect the results significantly. WealthScript Code (C#)
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators; [...]
[...] + sinInDegrees - 1) / cosInDegrees;
double a1 = Math.Exp(-1.414 * Math.PI / 8.0);
double b1 = 2.0 * a1 * Math.Cos((1.414 * 180d / 8.0) * Deg2Rad);
double c2 = b1;
double c3 = -a1 * a1;
double c1 = 1 - c2 - c3; for (int bar = 2; bar bar = 0.5*(1 + alpha1)*(Close bar - Close bar-1 ) + alpha1*HP bar-1 ;
//Smooth with a SuperSmoother Filter
Filt bar = c1*(HP bar + HP bar-1 ) / 2 + c2*Filt bar-1 + c3*Filt bar-2 ;
}
DataSeries ">48"> ds = new DataSeries[48 [...]
[...] five technical, intermarket and fundamental conditions are in place, and then wait while a stock's 2-day RSI crosses above 5 from the oversold territory. As we found the proposed exit strategy triggering too many false signals, not allowing to uncover the system's potential, we replaced it with a simple trailing exit at a 20-day stop of the daily lows. Figure 1. A Wealth-Lab 6 chart showing the application of the fundamental & technical rules from Mr.Pendergast's article on the Daily chart of DD (Dupont). The upper pane shows the 2-day [...]
[...] paramWeeklyLength2;
public MyStrategy()
{
paramDailyLength1 = CreateParameter("Daily Length 1",12,2,300,20);
paramDailyLength2 = CreateParameter("Daily Length 2",26,2,300,20);
paramWeeklyLength1 = CreateParameter("Weekly Length 1",60,2,300,20);
paramWeeklyLength2 = CreateParameter("Weekly Length 2",130,2,300,20);
}
protected override void Execute()
{
var RDM = RelativeDailyPPO.Series(Close,paramDailyLength1.ValueInt,paramDailyLength2.ValueInt,
paramWeeklyLength1.ValueInt,paramWeeklyLength2.ValueInt);
var [...]
[...] does not reflect that move, creating a lower top, the strategy fades the move as illustrated on Figure 2 and exits after a specified number of bars. Figure 2 : Shorting a price top not confirmed by a MACD bearish divergence in SCG (Scana Corp.) in February 2015.
Strategy 1: using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators; namespace WealthLab.Strategies
{
public class TASCMay2016_Crossovers : WealthScript
{
private StrategyParameter paramUseWarnings; [...]