CrossUnderBar: Indicator Documentation
Syntax
DataSeries CrossUnderBar( DataSeries ds1, DataSeries ds2 );
Parameter Description
ds1 |
First data series |
ds2 |
Second data series |
Description
CrossUnderBar(DataSeries1, DataSeries2) returns the most recent bar where DataSeries1 crossed under DataSeries2. No check is made about a possible subsequent
CrossOver.
Example
This example illustrates how to plot and call the CrossUnderBar series. The entry is made when Close has crossed under the Upper Bollinger Band within last 3 bars, and it is currently under the same band:
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Indicators;
namespace WealthLab.Strategies
{
public class XUBStrategy : WealthScript
{
protected override void Execute()
{
BBandUpper bbU = BBandUpper.Series( Close, 20, 2 );
CrossUnderBar xub = CrossUnderBar.Series( Close, bbU );
SetBarColors( Color.Silver, Color.Silver );
for (int bar = xub.FirstValidValue; bar < Bars.Count; bar++)
{
if( xubbar == bar )
SetBarColor( bar, Color.Blue );
if (IsLastPositionActive)
{
SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )bar );
}
else
{
if( ( Closebar < bbUbar ) & ( xubbar > bar - 3 ) )
BuyAtMarket( bar+1 );
}
}
ChartPane xPane = CreatePane( 20, true, true );
PlotSeries( xPane, xub, Color.Blue, WealthLab.LineStyle.Dashed, 2 );
PlotSeries( PricePane, bbU, Color.Blue, WealthLab.LineStyle.Solid, 1 );
}
}
}