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.
[...] randomColor;
}
protected override void Execute()
{
if( Bars.HasNamedDataSeries )
{
ChartPane p = CreatePane( 100, true, true );
foreach( DataSeries ds in Bars.NamedSeries )
PlotSeries( p, ds, RandomColor(), LineStyle.Solid, 1 );
}
else
PrintDebug( Bars.Symbol + " does not contain named series" );
}
}
} CoT data by Quandl This example illustrates creation of a custom DataSeries from the COT Named Series data defined as Commercial Long - Commercial Short and then applying RSI indicator to the custom [...]
[...] portfolio equity curve produces valid values! */
for(int bar = Bars.FirstActualBar; bar bar ) & ( p.Bars.Symbol == Bars.Symbol ))
{
#region User-configurable: Interacting with Portfolio Equity /* Your equity interaction rule goes here: */
if( globalEquity bar > globalEquity bar-100 )
{
Position pos = u.entry( p, bar, p.EntrySignal, p.BasisPrice );
if( pos != null )
{
pos.Priority = p.Priority;
pos.EntrySignal [...]
[...] bar bar > 0 ? Color.DarkBlue : Color.Red );
if (IsLastPositionActive)
{
Position p = LastPosition;
if( paramExitType.ValueInt == 0 ) // Fixed bars
{
if ( bar+1 - p.EntryBar >= FixedBars )
ExitAtMarket( bar+1, p, "Timed" );
}
else
{ // Profitable/losing closes
if( p.PositionType == PositionType.Long )
{
if( Bars.Close bar > p.EntryPrice )
pBars++;
else
if( [...]
[...] 1;
int cnt = 0;
for (int bar = 1; bar bar .Date > Date bar-1 .Date )
cnt++;
Position p = LastPosition;
if (IsLastPositionActive)
{
double amount = p.MFEAsOfBar(bar) [...]
[...] second day loaded in the current chart.
Syntax
public static int DaysInPosition(this Position p, int bar) public int DaysInPosition(int bar)
Parameter Description bar Bar number p Position object DaysInPosition returns how many trading days have passed since establishing a position using intraday data. Example:
// Extension method syntax
Position p = LastPosition;
int days = p.DaysInPosition(bar); Description
Intraday support functions and methods created [...]
[...] are purchased */
for(int bar = rsiPeriod * 3; bar = _profitPct.Value)
SellAtMarket(bar + 1, p, "Profit");
else
if (this.TomorrowIsLastTradingDayOfWeek(bar))
SellAtClose(bar + 1, p, "Friday");
}
else
{
if (this.DateOfNextTradingDay(bar).DayOfWeek bar .DayOfWeek)
{
double pri = chase * RSI.Series(Close, rsiPeriod) bar ;
Position p = BuyAtMarket(bar + 1, pri.ToString("0.000"));
if (p != null)
p.Priority [...]
[...] Wealth-Lab 6 chart illustrating the detection of the flag pattern on a 5-minute chart chart of SPY (S&P 500 SPDR). With minimal tweaks to the system's parameters it can be applied to charts of different time frames (e.g. EOD): Figure 2. A failed flag on the Daily chart of AXP (American Express) in Wealth-Lab 6. There's room for improvement: consider adding a filter against erratic price movement, phase out the less probable trades against the medium-term (daily) trend, playing with the exits (to our taste, the initial stop at the flag bottom may result in premature [...]
[...]
double hi = High bar ;
double lo = Low bar ; if (patternBars > 1)
{
int p = patternBars - 1;
for (int n = bar - 1; n >= bar - p; n--)
{
hi = High n > hi ? High n : hi;
lo = Low n n : lo;
}
}
int b1 = bar - patternBars;
int b2 = Math.Min(bar + 1, Bars.Count - 1);
DrawPolygon(PricePane, color, color, LineStyle.Invisible, 1, true, b1, hi, b2, hi, b2, lo, b1, lo);
}
protected override void Execute()
{
Position p = null;
double [...]
HV — 1.7%
[...] )
ShortAtMarket( bar+1 ); else
BuyAtMarket( bar+1 );
}
else
{
Position p = LastPosition;
stop = (p.PositionType == PositionType.Long) ?
[...] (downTrend)
SetBackgroundColor(bar, Color.FromArgb(30, Color.Red));
if (IsLastPositionActive)
{
Position p = LastPosition;
if (!ExitAtStop(bar + 1, p, p.RiskStopLevel,
string.Format("SL {0}%", stopLoss)))
{
if (p.PositionType == PositionType.Long)
{
switch (p.EntrySignal)
{
case "Breakout":
if (downTrend)
SellAtMarket(bar [...]
[...] period, int momperiod,
DataSeries ps, DataSeries ms, out bool trendup, out bool trenddn, out int p, out int m )
{
trendup = (ps bar > 0 && ms bar > 0);
trenddn = (ps bar bar bar >= 0 ? 1 : ps bar bar >= 0 ? 1 : ms bar bar > 0 && ms bar bar bar > 0 ) ? Side.Sell : Side.NA;
} void Colorize( int bar, Side side )
{
SetBackgroundColor( bar, Color.FromArgb(30, side == Side.Buy ? Color.Green : Color.Red ) );
}
private StrategyParameter paramNumDiv;
private StrategyParameter paramLongOnly;
public TASC201406_Kaufman()
{
paramNumDiv [...]
[...] data. LimitPriorityLong Syntax public static double LimitPriorityLong(this WealthScript ws, double p, int bar) public double LimitPriorityLong(double p, int bar)
Parameter Description p Limit price bar Signal bar This function, created by Andrew Vishnyakov ( avishn ), helps to estimate which limit orders will realistically be hit first - without dropping to the intraday data level. According to its author, it gives quick and dirty approximation and is useful when scanning large data sets.
IntradayFillPriorityEstimate [...]
[...] Color.Silver;
VarianceRatio vr = VarianceRatio.Series(Bars, Close, 20, 400);
double sensitivity = 0.9;
ChartPane vr_p = CreatePane(30, true, false);
PlotSeries(vr_p, vr, Color.Blue, ls, 1 );
DrawHorzLine(vr_p, sensitivity, Color.Red, ls, 2 );
RSI rsi_s = RSI.Series(Close, 14);
ChartPane RSI_p [...]
[...] -1; // no future fundamental item
}
if (IsLastPositionActive)
{
Position p = LastPosition;
if (barsToNextEvent == 1) // Exit on day before ex-div
{
SellAtClose(bar, p, "Ex-div");
}
else
{
double Stop = p.EntryPrice * (1 - 15.00 / 100.0d);
SellAtStop(bar + 1, p, Stop, "Stop Loss");
}
}
else
{
if (barsToNextEvent > - 1 && barsToNextEvent Legacy syntax example:
using System;
using System.Collections.Generic;
using [...]
[...] price, string signalName)
public static bool SellAtStopLimit(this WealthScript ws, int bar, Position p, double price)
public static bool SellAtStopLimit(this WealthScript ws, int bar, Position p, double price, string signalName)
public static bool CoverAtStopLimit(this WealthScript ws, int bar, Position p, double price)
public static bool CoverAtStopLimit(this WealthScript ws, int bar, Position p, double price, string signalName) public Position BuyAtStopLimit(int bar, double price)
public [...]
[...] Color.Gray, WealthLab.LineStyle.Solid, 1 );
for(int bar = 100; bar = 0; pos--)
{
Position p = ActivePositions pos ;
if( p.PositionType == PositionType.Long )
{
if( !SellAtStop( bar+1, p, [...]
Syntax
public static double ChandelierStop(this Position p, Bars bars, int bar, int period, double coefficient ) public double ChandelierStop(Bars bars, int bar, Position p, int period, double coefficient )
Parameter Description p Position to apply Chandelier stop to period TR period for Chandelier stop calculation coefficient ATR factor for Chandelier stop calculation bars Bars object bar Bar number Description
The Chandelier Stop is a trailing stop that is based on the volatility [...]
[...] > 18 && Close bar bar ;
bool osc = adx bar if (IsLastPositionActive)
{
Position p = LastPosition;
if( p.PositionType == PositionType.Long ) {
if( p.EntrySignal.ToLower().Contains("uptrend") ) {
if( VZO bar > 60 && TurnDown( bar, VZO ) ||
( Close bar bar && VZO bar bar bar bar > 40.0 ) {
if( adx bar > 18 )
SellAtMarket( bar+1, p, "nontrend sell rule #1" );
}
else {
if( VZO bar bar bar > ema [...]
[...] LastPosition, "Last Bar" );
}
Or in a multiple open positions strategy that translates to:
for(int p = ActivePositions.Count - 1; p >= 0; p--)
{
Position pos = ActivePositions p ;
// exit on the last bar of the day
if( Bars.IsLastBarOfDay(bar) )
ExitAtClose( bar, pos, "Last Bar" );
}
However, sometimes it gets more tricky. Read on below:
Problem
I'm trying to code an intraday strategy that doesn't hold any positions overnight. In order to do this I need to keep the [...]
[...] bar > 0) ? Color.LightGreen : Color.Black );
if (IsLastPositionActive)
{
Position p = LastPosition;
if( Close bar bar )
{
double stopLoss = (1.0 - paramSL.Value / 100d);
double stop = p.EntryPrice * stopLoss;
double brkEven = p.EntryPrice * 1.01; if( CrossUnder( bar, tpEma, haEma ) )
//if( tpEma bar bar )
SellAtMarket( [...]
[...] > 18 && Close bar bar ;
bool osc = adx bar if (IsLastPositionActive)
{
Position p = LastPosition;
if( p.PositionType == PositionType.Long ) {
if( p.EntrySignal.ToLower().Contains("uptrend") ) {
if( PZO bar > 60 && TurnDown( bar, PZO ) ||
( Close bar bar && PZO bar bar bar bar > 40.0 ) {
if( adx bar > 18 )
SellAtMarket( bar+1, p, "nontrend sell rule #1" );
}
else {
if( PZO bar bar bar > ema [...]
[...] false; // here's your "global"
private bool SymbolIsActive(string sym)
{
foreach (Position p in ActivePositions)
if( sym == p.Bars.Symbol )
return true;
return false;
}
protected override void Execute()
{
for(int bar = 20; bar bar) continue;
SMA sma = SMA.Series( Close, 20 );
if( CrossOver( bar, Close, sma ) )
BuyAtMarket( bar+1, "SMA CrossOver" );
}
}
RestoreContext();
// Exit [...]
[...] );
}
holding++;
}
else if(holding >= holdingPeriod.ValueInt)
{
foreach(Position p in Positions)
{
if(p.Active)
{
SellAtMarket(bar [...]
[...] 50 ); bar bar - 1 >= 2;
var overbot = (sto bar >= 80) || (rsi bar >= 70);
double Stop = p.EntryPrice * (1 - paramSL.Value / 100d);
double Profit = p.EntryPrice * (1 + paramTP.Value / 100.0d);
if( twoLowerLows )
SellAtMarket( bar+1, p, "2 lows" );
else
if( overbot )
SellAtMarket( [...]
[...] WealthScript
{
protected override void Execute()
{
for(int bar = 40; bar bar );
else
CoverAtStop( bar+1, p, Highest.Series( High,20 ) bar );
RestoreContext();
}
else
{
SetContext( "KO", true );
Position p = BuyAtStop( bar+1, Highest.Series( High,40 ) bar );
if( p == null )
ShortAtStop( bar+1, Lowest.Series( Low,40 ) bar );
RestoreContext();
}
}
const string SymbolPair = "KO";
if( Bars.Symbol != SymbolPair )
{
ChartPane pane = CreatePane( 100, false, [...]
[...] );
NewMax new_low_s = NewMax.Series( Low,period );
// Graphics
HideVolume();
ChartPane newm_p = CreatePane( 50, false, true );
SetPaneMinMax(newm_p, -100, 100); PlotSeries( newm_p, new_high_s, Color.Green, ls, 1 ); // New High
PlotSeries( newm_p, new_low_s, Color.Red, ls, 1 ); // New Low
// Trading
for(int [...]
[...] Color.FromArgb(60,Color.Red) );
}
}
#endregion
if (IsLastPositionActive)
{
Position p = LastPosition;
if( lastBarToday )
ExitAtClose(bar, p, [...]
[...] * HH4 bar ; // should it be LL4 as in Buy?
if( IsLastPositionActive )
{
Position p = LastPosition;
if( p.PositionType == PositionType.Long )
{
if ( sht1 || sht2 || sht3 )
{
SellAtClose(bar, p, "R:" + sht1 + "," + sht2 + "," + sht3 );
ShortAtClose(bar, "reverse");
}
else if ( s1 || s2 || s3 )
SellAtClose(bar, p, "X:" + s1 + "," + s2 + "," + s3);
}
else if ( buy1 [...]
[...] ADX.Series(obj.Bars,periodADX);
var avgMAB = SMA.Series(c,mab);
var adxLow = Lowest.Series(adx,adxLag);
ChartPane p = obj.CreatePane(30,true,true);
obj.PlotSeries(p, adx, Color.Red, LineStyle.Solid, 2 );
for(int bar = obj.GetTradingLoopStartBar(1); bar bar bar > avgMAB bar )
obj.BuyAtMarket(bar+1,"Strong Trend"); if( adx bar > adxMult * adxLow bar && obj.CrossOver(bar, adx, crit) & c bar > avgMAB bar )
obj.BuyAtMarket(bar+1,"Trend"); if( obj.CrossOver(bar, adx, adxTrend) && adx bar bar bar )
obj.ShortAtMarket(bar+1,"Strong [...]
[...] author uses the CPMO to compare momentum of different indexes. For example, it's believed that the S&P 500 rises when consumer discretionary (IXY) outperforms consumer staples (IXR) and vice versa. As a reference we include a simplistic Strategy which produces buy signals when the PMO of IXY crosses above the PMO of IXR. The opposite event (a crossunder) generated a sell signal. Wealth-Lab users can find PMO in the Community Indicators library.
Figure 1. On the daily chart, consumer discretionary (IXY) and consumer staples (IXR) are plotted along with the S&P [...]