NewMax: Indicator Documentation
Syntax
DataSeries NewMax( DataSeries series, int period )
Parameter Description
series |
A price series |
period |
Lookback period for indicator calculation |
Description
NewMaxby DrKoch www.finantic.de 2004-06-22
This indicators finds new highs and new lows.
The value walks between -100 and +100.
If Price action reaches a new high relative to period Bars, the NewMax indicator is +100.
If Price action reaches a new low, the NewMax Indicator is -100.
Example
This example illustrates how to plot the NewMax indicator and trade using it, based on a WL4 chartscript by Dr.Koch called "NewMax Trader". It enters a new trade as soon as a new High or Low is found. It exits if the NewMax Indicator goes back from +100 / -100 to +95 / -95.
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 NewMaxStrategy : WealthScript
{
private StrategyParameter paramperiod;
private StrategyParameter paramexit_limit;
public NewMaxStrategy()
{
paramperiod = CreateParameter( "period", 24, 5, 50, 5 );
paramexit_limit = CreateParameter( "exit_limit", 95, 90, 100, 1 );
}
protected override void Execute()
{
LineStyle ls = LineStyle.Solid;
int period = paramperiod.ValueInt;
double exit_limit = paramexit_limit.Value;
// Indicators
NewMax new_high_s = NewMax.Series( High,period );
NewMax 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_sbar >= 100.0 )
ShortAtMarket( bar+1, "new high" );
if( new_low_sbar <= -100.0 )
BuyAtMarket( bar+1, "new low" );
}
else
{
Position p = LastPosition;
if( ( p.PositionType == PositionType.Long ) & ( new_high_sbar >= -exit_limit ) )
SellAtMarket( bar+1, p, "end of uptrend" );
if( ( p.PositionType == PositionType.Short ) & ( new_low_sbar <= exit_limit ) )
CoverAtMarket( bar+1, p, "end of downtrend" );
}
}
}
}
}