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.
[...] 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] > Close [bar] & Open [...]
[...]
public TASC201610Katsanos()
{
paramStrategy2Run = CreateParameter( "ADX/R2/VHF/ER/All" ,4,0,4,1);
}
protected override void Execute()
{
var whichStrategyToRun = paramStrategy2Run.ValueInt;
HideVolume ();
switch (whichStrategyToRun)
{
case 0: SystemADX.Run( this ); break ;
case 1: SystemR2.Run( this ); break ;
case 2: SystemVHF.Run( this ); break ;
case 3: SystemER.Run( this ); break ;
case 4: SystemADX.Run( this ); SystemR2.Run( this ); SystemVHF.Run( [...]
[...] synch). Close ; //sec6 // initialize the initial values to account that yba data 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, [...]
[...] 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; [...]
[...] 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; [...]
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 [...]
[...] 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 - 1] && Low [bar] < Low [bar - 1] && Close [bar] < Low [bar [...]
[...] 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 crosses above the centerline Trades from the short side are deliberately not taken as their performance seems poor. Figure 1. Bullish divergence between the MFO and price formed in June 2015 triggered a long trade in KO (Coca Cola). After updating the TASCIndicators library to v2015.09 or later, the MoneyFlowOscillator indicator can be found under the TASC [...]
[...] 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 [...]
[...] solid, 2 );
DrawHorzLine (adxPane,thresholdForTrend,Color.Blue,LineStyle.Dashed,1); for ( int bar = GetTradingLoopStartBar (period); bar < Bars .Count; bar++)
{
if (! IsLastPositionActive )
{
/* 1st peak: both price and indicator */
if ( peak == false )
{
if ( ( High [bar-1] == Highest.Series( High , high )[bar-1] )
& ( srsi[bar-1] == Highest.Series( srsi, high [...]
[...] 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 [...]
[...] indicatorLowest = Lowest.Series( WM, low );
Lowest hLow = Lowest.Series( Low , low );
for ( int bar = GetTradingLoopStartBar (130); bar < Bars .Count; bar++)
{
if (! IsLastPositionActive )
{
/* 1st peak: both price and indicator */
if ( peak == false )
{
if ( ( High [bar-1] == Highest.Series( High , high )[bar-1] )
& ( WM[bar-1] == Highest.Series( WM, high )[
[...] 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, bar, n);
double per = period;
return 100 * ( y1 / y2 - 1d [...]
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: [...]
[...] 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... [...]
[...] 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] [...]
[...] );
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 == [...]
[...] 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, [...]
[...] sliders to adjust the Period and atrFactor Strategy Parameters to eyeball an optimization, or using WLP 5.4 you can now run full Exhaustive and Monte Carlo optimizations. A portfolio 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 [...]
[...] Close ;
var bbCAD = 1 + (( Close - SMA.Series( Close ,days) + 2*StdDev.Series( Close ,days,s)) / (4*StdDev.Series( Close ,days,s)+0.0001));
var bbOil = 1 + ((oil - SMA.Series(oil,days) + 2*StdDev.Series(oil,days,s)) / (4*StdDev.Series(oil,days,s)+0.0001));
var divergence = (bbOil-bbCAD)/bbCAD*100; divergence.Description = "Divergence" ;
var hhvDiv = Highest.Series(divergence,3);
var llvDiv = Lowest.Series(divergence,3);
var llv = Lowest.Series( Low ,15);
var hhv = Highest.Series( High ,15);
var roc = ROC.Series( [...]
[...] enters long trades when the cycle turns up within the threshold zone and exits on a closing profit of 4% or after 5 bars. The time-based exit was chosen purposely to be a ¼ cycle to exit before the next turn down. The Strategy produced a slightly-positive win rate and raw profit factor for the last 6 years of trading on the Dow 30 and Nasdaq 100 index components.
Figure 1. Representative trades from the sample Strategy. WealthScript Code (C#)
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using [...]
[...] Color.FromArgb(50,Color.Blue);
LineStyle ls = LineStyle.Solid;
PlotSeries ( PricePane ,sma,Color.Red,ls,1);
for ( int bar = Math.Max(riseBars, GetTradingLoopStartBar (paramSMA.ValueInt)); bar < Bars .Count; bar++)
{
// "White space": percentage of bars above 50-day SMA
for ( int i = bar - riseBars; i <= bar; i++)
{
ba = ( Low [i] > sma[i]) ? ba += 1 : 0;
whiteSpace[bar] = ba / ( double )riseBars;
}
[...]
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, [...]
[...] low;
R5 = ( high / low ) * close;
R4 = close + Range * 1.1 / 2;
R3 = close + Range * 1.1 / 4;
R2 = close + Range * 1.1 / 6;
R1 = close + Range * 1.1 / 12;
S1 = close - Range * 1.1 / 12;
S2 = close - Range * 1.1 / 6;
S3 = close - Range * 1.1 / 4;
S4 = close - Range * 1.1 / 2;
S5 = close - (R5 - close);
}
public void Clear()
{
R1 = 0; R2 = 0; R3 = 0; R4 = 0; R5 = 0;
S1 = 0; S2 = 0; S3 = 0; S4 = 0; S5 = 0;
}
}
public class CamarillaPointsStrategy : WealthScript
{
enum Entry { Inside, [...]
[...] 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 rules Fixed bars: exit at open next bar [...]
[...] protected override void Execute()
{
#region DataSeries
ADX adx4 = ADX.Series( Bars ,4);
ADX adx5 = ADX.Series( Bars ,5);
ADX adx6 = ADX.Series( Bars ,6);
DIPlus dip5 = DIPlus.Series( Bars ,5);
DIPlus dip8 = DIPlus.Series( Bars ,8);
DIPlus dip14 = DIPlus.Series( Bars ,14);
DIMinus dim5 = DIMinus.Series( Bars ,5);
DIMinus dim8 = DIMinus.Series( Bars ,8);
DIMinus dim14 = DIMinus.Series( Bars ,14);
LineStyle ls = LineStyle.Solid;
#endregion #region Plotting
ChartPane adxPane = CreatePane (35, true , true );
[...]
[...] new DataSeries( Bars , "HA-Low" ), haClose = new DataSeries( Bars , "HA-Close" );
for ( int bar = 1; bar < Bars .Count; bar++)
{
Renko rko = renko.Columns[bar];
// Create Renko-based OHLC and Heikin Ashi for averaging
if ( rko.Col > -1 )
{
if ( rko.Col > renko.Columns[bar-1].Col )
{
Renko prev = renko.Columns[bar-1]; double open = rko.DirectionUp ? rko. Low [...]
[...] 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] )
if ( BuyAtMarket (
[...] 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, ls, 1);
PlotSeries ( sPane, [...]