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 [...]
[...]
for ( int bar = Bars .FirstActualBar; bar < Bars .Count; bar++)
{
foreach (Position p in sr. Positions )
{
if (( p.EntryDate == Bars . Date [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, [...]
[...] dmo[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 [...]
[...] ( 50 ); bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
if ( p.PositionType == PositionType.Long )
{
var twoLowerLows = CumDown.Series( Low , 1)[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 [...]
[...] rsiPeriod * 3; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
if (p.MFEAsOfBarPercent(bar) >= _profitPct.Value)
SellAtMarket (bar + 1, p, "Profit" );
else
if ( this .TomorrowIsLastTradingDayOfWeek(bar))
SellAtClose (bar + 1, p, "Friday" );
}
else
{
if ( this .DateOfNextTradingDay(bar).DayOfWeek < Date [bar].DayOfWeek)
{
double pri = chase * RSI.Series( [...]
[...] 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 [...]
[...] .Count; bar++)
{
if ( Date [bar]. Date > Date [bar-1]. Date )
cnt++;
Position p = LastPosition ;
if ( IsLastPositionActive )
{
double amount = p.MFEAsOfBar(bar) /
[...] SetBackgroundColor ( bar, Color.FromArgb( 30, Color.Green ) ); 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] < ema[bar] && PZO[bar] < 0 ) ||
(pd[bar] <= -1.0 && PZO[bar] < 40.0) )
SellAtMarket ( bar+1, p, "trend sell" );
}
[...]
[...] int bar = 40; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
SetContext ( "KO" , true );
if ( p.PositionType == PositionType.Long )
SellAtStop ( bar+1, p, Lowest.Series( Low ,20 )[bar] );
else
CoverAtStop ( bar+1, p, Highest.Series( High ,20 )[bar] );
RestoreContext ();
}
else
{
SetContext ( "KO" , true );
Position p = BuyAtStop ( [...]
[...]
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] < lo ? Low [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
[...] SetBackgroundColor ( bar, Color.FromArgb( 30, Color.Green ) ); 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] < ema[bar] && VZO[bar] < 0 ) ||
(pd[bar] <= -1.0 && VZO[bar] < 40.0) )
SellAtMarket ( bar+1, p, "trend sell" );
}
[...]
[...] bar = 1; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
double ProfitTgt = 0, StopPrice = 0;
if ( p.PositionType == PositionType.Long ) {
ProfitTgt = p.EntryPrice * (1 + target / 100.0d);
StopPrice = p.EntryPrice * (1 - stop / 100.0d);
}
else {
ProfitTgt = p.EntryPrice * (1 - target / 100.0d);
StopPrice = p.EntryPrice [...]
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 [...]
[...] int bar = 1; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ; // loop backwards from current bar to last position's bar of entry
for ( int Bar = bar; Bar >= p.EntryBar; Bar-- )
{
// when day changes, increment counter
if ( Bars .IntradayBarNumber( Bar ) == 0 )
{
cnt++;
break ;
}
}
// when counter reaches 3, sell
if ( cnt >= 3 )
ExitAtMarket ( bar+1, LastPosition );
}
else [...]
[...] 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 [...]
[...] 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 [...]
[...] bar++)
{
if ( IsLastPositionActive )
{
// 20% stop and 15% Profit Target
Position p = LastPosition ;
if (p.PositionType == PositionType.Long)
{
if ( ! SellAtStop (bar [...]
[...] 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 + 1, p, [...]
[...] 100 );
bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
double Stop =
p.PositionType == PositionType.Long ? p.EntryPrice [...]
[...] (bar + 1);
else if (sell)
ShortAtMarket (bar + 1);
}
else
{
Position p = LastPosition ;
if ( bar - p.EntryBar < 1 )
continue ;
else if (p.PositionType == PositionType.Long)
{
if (sell)
{
ExitAtMarket (bar + 1, p, "Reverse" );
ShortAtMarket (bar + 1);
}
else if ( Close [bar] < ema[bar] )
{
if ( LRSNL[bar] < LRSNLSELL.Value )
ExitAtMarket (bar + 1,
HV — 1.0%
[...] ShortAtMarket ( bar+1 ); else
BuyAtMarket ( bar+1 );
}
else
{
Position p = LastPosition ;
stop = (p.PositionType == PositionType.Long) ? p.EntryPrice [...]
[...] 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 bar = 20; bar < Bars .Count; bar++)
{
if (! IsLastPositionActive )
{
if ( new_high_s[bar] >= 100.0 )
[...]
[...] 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] < 0 && ms[bar] < 0);
p = ps[bar] >= 0 ? 1 : ps[bar] < 0 ? -1 : 0;
m = ms[bar] >= 0 ? 1 : ms[bar] < 0 ? -1 : 0;
return ( ps[bar] > 0 && ms[bar] < 0 ) ? Side.Buy :
( ps[bar] < 0 && ms[bar] > 0 ) ? Side.Sell : Side.NA;
} void Colorize( int bar, Side side )
{
SetBackgroundColor [...]
[...] 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, [...]
[...] 0.9);
xu2 = CrossUnder (bar, PS, 0.2);
if ( IsLastPositionActive )
{
Position p = LastPosition ;
if ( p.PositionType == PositionType.Long )
{
stop = p.EntryPrice * paramSLLong.Value;
profit = p.EntryPrice [...]
[...] ,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 < 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, adx, adxTrend) [...]
[...] )
ShortAtMarket ( bar + 1 );
}
// Subsequent trades
else
{
Position p = LastPosition ;
if ( p.PositionType == PositionType.Long )
{
if ( maXu )
{
SellAtMarket ( bar + 1, p );
ShortAtMarket ( bar + 1 );
}
}
else if ( maXo )
{
CoverAtMarket ( bar + 1, p );
BuyAtMarket ( bar + 1 );
}
}
}
}
}
}
Another example
Our previous example featured CrossOvers/CrossUnders [...]
[...] 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 = CreatePane [...]
[...] // 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 <= 8)
{
BuyAtMarket [...]
[...] emm.FirstValidValue; bar < Bars .Count; bar++)
{
if ( IsLastPositionActive )
{
Position p = LastPosition ;
if ( CrossOver ( bar, emm, 19 ) ) TStopOn = true ; if ( p.MAEAsOfBarPercent( bar-1 ) < -8 )
CoverAtStop ( bar, p, p.EntryPrice*1.08, [...]