CrossUnderValueBar: Indicator Documentation
Syntax
DataSeries CrossUnderValueBar( DataSeries ds, double value );
Parameter Description
ds |
Data series |
value |
Some value |
Description
CrossUnderValueBar(DataSeries, double) returns the most recent bar where DataSeries crossed under Value. No check is made about a possible subsequent
CrossOver.
Example
This example illustrates how to plot and call the CrossUnderValueBar series. The entry is made when CCI(Bars, 14) has crossed under value 100 within last 3 bars, and it is still currently under value 100:
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 XUVBStrategy : WealthScript
{
protected override void Execute()
{
CCI cci = CCI.Series( Bars, 14 );
int val = 100;
CrossUnderValueBar xub = CrossUnderValueBar.Series( cci, val );
SetBarColors( Color.Silver, Color.Silver );
for (int bar = xub.FirstValidValue; bar < Bars.Count; bar++)
{
if( xubbar == bar )
SetBarColor( bar, Color.Red );
if (IsLastPositionActive)
{
SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )bar );
}
else
{
if( ( ccibar < val ) & ( xubbar > bar - 3 ) )
BuyAtMarket( bar+1 );
}
}
ChartPane xPane = CreatePane( 20, true, true );
ChartPane cciPane = CreatePane( 20, true, true );
PlotSeries( xPane, xub, Color.Blue, WealthLab.LineStyle.Dashed, 2 );
PlotSeries( cciPane, cci, Color.Blue, WealthLab.LineStyle.Solid, 1 );
DrawHorzLine( cciPane, val, Color.Black, WealthLab.LineStyle.Dashed, 1 );
}
}
}