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.
[...] "Reversal %" , 10.0, 1.0, 50.0, 1.0);
paramLookbackForStepPattern = CreateParameter( "Lookback" , 3, 1, 20, 1);
}
bool isInsideBody( int bar, double price ) {
return price <= Math.Max( Open [bar], Close [bar]) && price >= Math.Min( Open [bar], Close [bar]);
}
bool Upstep( int bar, int lookback ) {
bool result = false ;
bool way1 = ( Open [bar] [...]
[...] (30, true , true );
obj. PlotSeries (p, adx, Color.Red, LineStyle.Solid, 2 );
for ( int bar = obj. GetTradingLoopStartBar (1); bar < obj. Bars .Count; bar++)
{
if (obj. IsLastPositionActive )
{
if ( obj. CrossUnder (bar, c, avgMAB) || obj. CrossOver (bar, c, avgMAB) )
obj. ExitAtMarket ( bar+1, obj. LastPosition , "MA" );
}
else
{
if ( obj. CrossOver (bar, [...]
[...] starts at 4/23/2008
int stBar = DateTimeToBar ( new DateTime(2003, 4, 23), false );
for ( int bar = 0; bar < stBar; bar++)
yba[bar] = yba[stBar];
// Based calculations from raw data and then synchronize
DataSeries ybaSMA = Synchronize ( SMA.Series(yba, 40) );
DataSeries xauROC = Synchronize ( ROC.Series(xau, 1) );
DataSeries crbROC = Synchronize ( ROC.Series(crb, 1) );
DataSeries ejROC = Synchronize ( ROC.Series(ej, 2) );
ej = Synchronize [...]
Bars, Loops, and Bar + 1
Original article by Robert Sucher in the legacy Knowledge Base here .
Wealth-Lab Developer has features such as order slippage and variable commissions to bring trading simulation as close to reality as possible. Likewise, your task as a trading system designer is to express your system in C# code that validly recreates security orders as they would have been and will be executed in real life. Bar Definition
A bar is any interval of time that has an open, high, low, and closing [...]
[...] ADX.Series( Bars ,14 );
EMA ema = EMA.Series( Close , 60, EMACalculation.Modern );
for ( int bar = period; bar < Bars .Count; bar++) {
R[bar] = Math.Sign( Close [bar] - Close [bar-1] ) * Volume [bar];
}
DataSeries VP = EMA.Series( R, period, EMACalculation.Modern );
for ( int bar = period; bar < Bars .Count; [...]
[...] ADX.Series( Bars ,14 );
EMA ema = EMA.Series( Close , 60, EMACalculation.Modern );
for ( int bar = period; bar < Bars .Count; bar++) {
R[bar] = Math.Sign( Close [bar] - Close [bar-1] ) * Close [bar];
}
DataSeries VP = EMA.Series( R, period, EMACalculation.Modern );
for ( int bar = period; bar < Bars .Count; [...]
[...] changed from 12 to 51, and DataSeries initializations have been simplified. // WAS:
double Trend = ds[bar] - ds[cycPeriod];
// SHOULD BE (IS):
double Trend = ds[bar] - ds[bar - cycPeriod]; /* Strategy Code revised 20090611 */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators; namespace WealthLab.Strategies
{
public class CoronaCharts : WealthScript
{
public const double twoPi = 2 [...]
[...] is detected when the SRSI indicator fails to confirm a price extreme, that is, the highest high of 20 days for bearish divergence or the 20-day lowest low for bullish divergence. This technique improves divergence detection time, practically reducing delay to a minimum compared to finding retracements from recent peaks or troughs. System rules Once a bullish divergence is detected, enter long next bar at open if MFO is below its centerline Exit long next bar at open when MFO [...]
[...] to create a Pullback in an Uptrend entry. For instance, in an established uptrend, wait for a three bar pullback and
enter at stop $0.10 above prior bar high. However, the Rule Wizard doesn't seem to have "Buy at Stop" rule desired. Solution:
You can get pretty close by starting with these rules: BuyAtLimit ( High )
- Moving Average is trending up (Moving Average group)
- Price decreases a consecutive number of bars (Price (or Volume ) group) ..and add an exit (if you only want a screen, see Techniques > Creating a Screener in the [...]
[...] Execute()
{
var _pattern = paramPattern.ValueInt;
var _exitAfter = paramExitDays.ValueInt;
int atrPeriod = 20, maPeriod = 80;
double tick = Bars .SymbolInfo.Tick;
var atr = ATR.Series( Bars , atrPeriod);
var trendFilter = SMA.Series( Close , maPeriod);
for ( int bar = GetTradingLoopStartBar (Math.Max(atrPeriod,maPeriod)); bar < Bars .Count; bar++)
{
//key reversal
bool keyRevBear = High [bar] > High [bar [...]
[...] Oscillating between 0 and 100, it becomes overbought after reaching 80 and oversold after dropping below 20. Signals can also be generated by looking for centerline crossovers and divergences. The latter trait is what our example trading system will zero in on. There are several approaches that help identify divergences between price and oscillator. The one we're going to use is straightforward, detecting a divergence when the SRSI indicator fails to confirm a price extreme, that is, the highest high of 20 days for short trades or the 20-day [...]
[...] CreateParameter( "Highest high of" , 130, 60, 300, 10);
paramExitDays = 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()
{
[...]
[...] CreateParameter( "Snl EMA Period" , 15, 5, 25, 1);
MADXY = CreateParameter( "DX MA Period" , 50, 20, 100, 5);
chnlLength = CreateParameter( "Channel Period" , 4, 2, 20, 2);
} // ROC of LR Line divided by its period
private double LRLineROCdivPeriod( int bar, DataSeries ds, int period)
{
int n = bar - period + 1;
double y1 = LinearRegLine (ds, n, bar, bar);
double y2 = LinearRegLine (ds, n, [...]
[...] determine and compare time of day
public class MyStrategy : WealthScript
{
public int GetTime( int bar)
{
return Date [bar].Hour * 100 + Date [bar].Minute;
}
protected override void Execute()
{
// Specifically, I use a strategy that buys stocks only in the time period between 9:55 am and 13:00. for ( int bar = 1; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
// exit rule here... [...]
[...] );
PlotSeries ( PricePane , daily. Close , Color.Black, LineStyle.Dashed, 1 ); for ( int bar = 20; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
if ( Bars .IsLastBarOfDay( bar ) )
SellAtClose ( bar, LastPosition , "At Close" ); else
SellAtStop ( bar+1, LastPosition , Stop, "Stop" );
} else
{
//if (Date[bar].Hour [...]
Syntax
public static int GetTime( this WealthScript obj, int bar)
public static int GetTime( this Bars bars, int bar) // For use when using a non-synchronized Bars object public int GetTime( int bar)
public int GetTime(Bars bars, int bar) // For use when using a non-synchronized Bars object
Parameter Description bar Bar number bars Bars object GetTime returns 24-hour time as an integer. Example: [...]
[...] sto_m); sto_q = Synchronize ( sto_q); sto_y = Synchronize ( sto_y); //Determine the first valid bar
var start = Math.Max(sto_60.FirstValidValue,
Math.Max(sto_d.FirstValidValue,
Math.Max(sto_w.FirstValidValue,
Math.Max(sto_m.FirstValidValue,
Math.Max(sto_q.FirstValidValue, sto_y.FirstValidValue))))); ChartPane sPane = CreatePane ( 20, false , true );
PlotSeries ( sPane, sto_60, Color.Peru, ls, 1);
PlotSeries ( sPane, sto_d, Color.Chartreuse, ls, 1);
PlotSeries ( sPane, sto_w, Color.Gainsboro, [...]
[...] SMA.Series(Slow, 30); //V Slow MA: Blue int Tier1 = 0, Tier2 = 0, Tier3 = 0, Tier4 = 0; for ( int bar = GetTradingLoopStartBar (Math.Max(period * 3, 30)); bar < ds.Count; bar++)
{
Tier1 = (Fast[bar] >= Med[bar] && Med[bar] >= Slow[bar] && Slow[bar] >= Vslow[bar]) ? 10 : 0;
Tier2 = (Fast[bar] [...]
[...] intermarket Bollinger Bands (BB) divergence method are superimposed on the chart as colored triangles. The 20-day BB divergence is plotted on the top and crude oil (light sweet) futures in the middle window. A participating indicator, Correlation , is part of the Community Indicators library, driven by the Wealth-Lab user community. To run this Wealth-Lab 6 strategy code below, install the indicator library (or update to the actual version using Extension Manager ) from our website wealth-lab.com, Extensions section . After updating the library to v2015.07 or later, the Correlation [...]
[...] );
DataSeries trends = new DataSeries(b, "TrendsStop(" + period + "," + factor + ")" );
for ( int bar = 0; bar < period; bar++)
support[bar] = b. Low [bar];
for ( int bar = period; bar [...]
[...] above the 2nd one and the previous value was less than or equal to the target value at the previous bar. Motivated traders can compare approaches by commenting and uncommenting these lines:
if ( CrossUnder ( bar, tpEma, haEma ) )
//if( tpEma[bar] < haEma[bar] )
...
if ( CrossOver ( bar, tpEma, haEma ) )
//if( tpEma[bar] > haEma[bar] )
To run the sample Strategy in Wealth-Lab, [...]
[...] the average MTR by 3 standard deviations of MTR or greater. An entry is triggered when: Buy next bar at market if today's close price has declined. Short next bar at market if today's close price has increased. A position is exited with a simple trailing channel exit: Exit long when today's low price has broke below the 3-day lowest price. Cover short when today's high price has broke above the 3-day highest price. This system is merely a proof-of-concept. Among possible enhancements to this barebone system, the following can be [...]
[...] almost any entry style without adding prejudice. Entry rules Pullback entry: Buy at open next bar if the DMI Oscillator is above 0 and the DMI Stochastic crosses above 10. Short at open next bar if the DMI Oscillator is below 0 and the DMI Stochastic crosses below 90. Countertrend entry: Short at open next bar if the DMI Oscillator crosses under -20. Buy at open next bar if the DMI Oscillator crosses above 20.
Exit [...]
[...] strategy
public class Donor : WealthScript
{
protected override void Execute()
{
for ( int bar = 21; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
if ( Close [bar] < Close [bar-20] )
SellAtMarket ( bar+1, LastPosition );
}
else
{
if ( Close [bar] > Close [bar-20] [...]
[...] slider3;
public MyStrategy()
{
slider1 = CreateParameter( "Regression Period" ,50,2,300,20);
slider2 = CreateParameter( "Div.Mom. Period" ,50,2,300,20);
slider3 = CreateParameter( "ROC Period" ,3,2,300,20);
}
protected override void Execute()
{
var fxy = GetExternalSymbol ( "FXY" , true );
var spy = GetExternalSymbol ( "SPY" , true );
var rd = RegressionDivergence.Series( Bars ,fxy,spy,slider1.ValueInt,slider2.ValueInt,slider3.ValueInt);
int STD = 25, OB = 90, [...]
Syntax public static Position BuyAtStopLimit( this WealthScript ws, int bar, double price)
public static Position BuyAtStopLimit( this WealthScript ws, int bar, double price, string signalName)
public static Position ShortAtStopLimit( this WealthScript ws, int bar, double price)
public static Position ShortAtStopLimit( this WealthScript ws, int bar, double price, string signalName)
public static bool SellAtStopLimit( this WealthScript ws, int bar, [...]
[...] 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 = CreateParameter( "Expires after Y bars" , 20, 5, 40, 5);
paramVolConf = CreateParameter( "Volume confirmation?" , 0, 0, 1, 1);
paramMaxBuy = CreateParameter( "Max buy price" , 5, 1, 10, 1);
paramTrail [...]
[...] StrategyParameter _fraction;
public EmpiricalModeDecomp()
{
_period = CreateParameter( "Period" , 20, 5, 50, 1);
_delta = CreateParameter( "Delta" , 0.5, 0.05, 1, 0.05);
_fraction = CreateParameter( "Fraction" , 0.25, 0.1, 1, 0.05);
} public DataSeries BandPassSeries(DataSeries ds, int period, double delta)
{
DataSeries res = new DataSeries(ds, "BandPassSeries(" + ds.Description + "," + period + "," + delta + ")" );
double beta = Math.Cos(2 * Math.PI / period);
double gamma = 1/ Math.Cos(4 * Math.PI * delta / period);
[...]
[...] SetScaleDaily ();
Bars dailyBars = Bars ;
DataSeries CompBar = new DataSeries( Bars , "Compressed Bar Numbers" );
for ( int bar = 0; bar < Bars .Count; bar++)
CompBar[bar] = bar;
RestoreScale ();
dailyBars = Synchronize (dailyBars);
DataSeries GetDailyBar = Synchronize (CompBar); // Initialize an instance of the CamarillaPoint class
Camarilla c = new Camarilla();
double tick = Bars .SymbolInfo.Tick;
[...]
[...] for easy reference in users' Strategies. Here's the complete list of Strategy rules: Enter long next bar at open if following conditions are met:
Stock price greater than $1 50-day simple moving average of volume is greater than 100,000 Yesterday’s close was less than the day before Yesterday’s close was less than its open Today’s open is greater than yesterday’s close Today’s close is greater than yesterday’s open Today’s open is less than yesterday’s open As of yesterday’s close, price had been closing lower for three days Sell short next bar [...]