Setup operators: ==, >, >=, <, <=
.... } else { // Enable the stop order (trigger) with a setup if( Closebar > SMA.Series( Close, 50 )bar ) if( Volumebar >= SMA.Series( Volume, 20 )bar ) BuyAtStop( bar + 1, Closebar ); }
... } else { // Enable the stop order (trigger) with a setup if(( Closebar > SMA.Series( Close, 50 )bar ) && ( Volumebar > SMA( Volume, 20 )bar )) BuyAtStop( bar + 1, Closebar ); }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class SetupDemo : WealthScript { protected override void Execute() { // Example of a setup with a 3-bar timeout int SETUP_TIMEOUT = 3; int SetupBar = 0; bool SetupValid = false; double MyLimit = 0; SMA volSma = SMA.Series( Volume,10 ); PlotSeries( VolumePane, volSma, Color.Teal, LineStyle.Solid, 2 ); PlotStops(); for(int bar = 20; bar < Bars.Count; bar++) { if (IsLastPositionActive) { Position p = LastPosition; if( !SellAtStop( bar+1, p, p.EntryPrice * 0.95 ) ) SellAtLimit( bar+1, p, p.EntryPrice * 1.10 ); } else //if (!IsLastPositionActive) { // When a position is not active, test for the Setup if not already valid if( !SetupValid ) { if( Volumebar > 2 * volSmabar ) { SetupValid = true; SetupBar = bar; MyLimit = Closebar - 0.5 * ATR.Series( Bars, 5 )bar; } } if( SetupValid ) { // if the order is filled set SetupValid to false if( BuyAtLimit( bar + 1, MyLimit ) != null ) SetupValid = false; else // reset if Setup has timed out SetupValid = bar + 1 - SetupBar < SETUP_TIMEOUT; // Color the VolumePane to indicate that the setup was valid this bar SetPaneBackgroundColor( VolumePane, bar, Color.FromArgb( 30, Color.Green ) ); } } } } } }