Log in to see Cloud of Tags

Wealth-Lab Wiki

CrossUnderBar

RSS

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( xub[bar] == bar ) SetBarColor( bar, Color.Blue ); if (IsLastPositionActive) { SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )[bar] ); } else { if( ( Close[bar] < bbU[bar] ) & ( xub[bar] > 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 ); } } }

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.