Wednesday, December 26, 2007

code for support resistance in Trade station

please refer


http://www.breakoutfutures.com/Newsletters/Newsletter0303.htm
====================================================================
I also created an indicator based on the SupRes2 function to plot the support and resistance levels. The code for the indicator is shown below.



{
Indicator: SupRes Indicator-2
Plot the support and resistance given by the SupRes2 function.



Michael R. Bryant Breakout Futures
www.BreakoutFutures.com
Copyright 2003 Breakout Futures

Feb 24, 2003
}

Inputs: NBars (30), { # bars to lookback in search }
PriceRnge (3), { # points to examine above/below close }
PFilter (1.0), { points this close to line }
MinPoints (4); { need at least this many points in fit }



Var: SupPrice (C), { located support price }
ResPrice (C); { located resistance price }



{ Call SupRes function to find nearest support/resistance }
Value1 = SupRes2(NBars, PriceRnge, PFilter, MinPoints, SupPrice, ResPrice);

Plot1(SupPrice, "Support");
Plot2(ResPrice, "Resistance");



In Fig. 3, I show how the indicator works for the same price chart shown in Fig. 1. I used the following input parameter values: 30, 2.25, 0.75, 4. The support prices are in green and the resistance levels in red.

During downtrending markets, the support levels tend to stay close to the price bar lows because none of the nearby price bars have prices lower than the most recent bar's low.

Similarly, in uptrending markets, the resistance levels stay near the highs.
The SupRes2 function could be employed in a trading system in a number of different ways, such as
(1) to identify the trend based on whether support and resistance levels are rising or falling, and
(2) to trigger entries and/or exits at the identified support and resistance levels.

courtesy
Michael R. Bryant
Breakout Futures
www.BreakoutFutures.com

No comments: