20 February 2011

Zig Zag Indicator with Valid Entry and Exit Points

The Zig Zag indicator identifies pivot points but looks into the future - (beyond the right edge of the chart) to do this. This indicator plots a dot at the pivot point and an arrow at the bar when the pivot becomes known. The price bars are colored red for a pivot downtrend, green for a pivot uptrend, and blue at the known pivot point. Three addional horizontal lines are plotted and tied to the selected bar - the current close and +/- x% from the current close. The x% is the same % used in the Zig Zag function.

Formula:
//z_ZigZagValid
// ******** CHARTING
PercentChange = 6;
mystartbar = SelectedValue(BarIndex()); // FOR GRAPHING

mystartbardate = LastValue(ValueWhen(mystartbar == BarIndex(), DateNum(),1));

InitialValue = LastValue(ValueWhen(mystartbardate == DateNum(), C , 1 ) ) ;
Temp1 = IIf(BarIndex() >= mystartbar, InitialValue, Null) ;
Plot(Temp1, " ", colorBlack,styleLine);
Plot((1+(LastValue(PercentChange)/100))*(Temp1), " ", colorGreen, styleLine) ;
Plot((1-(LastValue(PercentChange)/100))*(Temp1), " ", colorRed, styleLine) ;

ZZ = Zig(C,LastValue(PercentChange)) ;
PivotLow = Ref(IIf(Ref(ROC(ZZ,1),-1) < 0 AND ROC(ZZ,1) > 0, 1, Null),1);
PivotHigh = Ref(IIf(Ref(ROC(ZZ,1),-1) > 0 AND ROC(ZZ,1) < 0, 1, Null),1); PlotShapes( shapeCircle*PivotLow, colorGreen,0, L, -20) ; PlotShapes( shapeCircle*PivotHigh,colorRed,0,H, 20) ; Buy_Valid = IIf(C>(1+(LastValue(PercentChange)/100))*(ValueWhen(PivotLow, C,
1))
AND ROC(ZZ,1) > 0,1,0);
Sell_Valid = IIf(C<(1-(LastValue(PercentChange)/100))*(ValueWhen(PivotHigh, C, 1)) AND ROC(ZZ,1) < 0,1,0); Buy_Valid = ExRem(Buy_Valid,Sell_Valid); Sell_Valid = ExRem(Sell_Valid,Buy_Valid); PlotShapes( shapeUpArrow*Buy_Valid, colorGreen,0, L, -20); PlotShapes( shapeDownArrow*Sell_Valid, colorRed,0,H, -20) ; BarColors = IIf(BarsSince(Buy_Valid) < BarsSince(Sell_Valid) AND BarsSince(Buy_Valid)!=0, colorGreen, IIf(BarsSince(Sell_Valid) < BarsSince(Buy_Valid) AND BarsSince(Sell_Valid)!=0, colorRed, colorBlue)); Plot(C, " ", BarColors, styleBar ) ; Plot(ZZ," ", colorLightGrey,styleLine|styleThick); Plot(ZZ," ", BarColors,styleDots|styleNoLine); Title = Name() + " " + Date() + WriteIf(PivotLow, " Up Pivot ","")+WriteIf(PivotHigh," Down Pivot ","")+ WriteIf(Buy_Valid, " Buy Point ", "") + WriteIf(Sell_Valid, " Sell Point ", "") ; listing 2 _SECTION_BEGIN("Price"); SetChartOptions(0,chartShowArrows|chartShowDates); _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) )); Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) ) { ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ))); } _SECTION_END(); _SECTION_BEGIN("ZIG"); P = ParamField( "Price field" ); change = Param("% change",5,0.1,25,0.1); z = Zig(P, change); Plot( z, _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); myBuy = IIf(z > Ref(z, -1), 1, 0);
mySell = IIf(z < Ref(z, -1), 1, 0);
Buy = Cover = ExRem(myBuy, mySell);
Sell = Short = ExRem(mySell, mybuy);
Filter = Buy OR Sell;
AddColumn(Buy, "Buy", 1.0);
AddColumn(Sell, "Sell", 1.0);
_SECTION_END();

Welcome to My Domain: ZigZag Retracements.

Welcome to My Domain: ZigZag Retracements.

ZigZag Retracements.

Formula:
_SECTION_BEGIN("ZigZag Retracement");
function GetXSupport(Lo, Percentage, Back)
{
return ((BarCount - 1) - LastValue(TroughBars(Lo, Percentage,Back)));
}
function GetYSupport(Lo, Percentage, Back)
{
return (LastValue(Trough(Lo, Percentage, back)));
}

function GetXResistance(Hi, Percentage, Back)
{
return ((BarCount - 1) -LastValue(PeakBars(Hi, Percentage, Back)));
}
function GetYResistance(Hi, Percentage, Back)
{
return (LastValue(Peak(Hi, Percentage, Back)));
}

//////////////////////////////////////////////////////////////////
Per = Param("Period", .618, .1, 20, .001);
Period = Param("Look back", 10, 1, BarCount-1);
ShowRet = ParamToggle("Show Retracement values", "No|Yes",1);
Price = ParamList("Price to follow:", "Close|High|Low", 1);
if(Price=="Close") ZigP = Zig(C, per);
else if(Price=="High") ZigP = Zig(H, per);
else ZigP = Zig(L, per);

//////////////////////////////////////////////////////////////////
Plot(C, "", IIf(O>=C, colorDarkRed, colorDarkGreen), ParamStyle("Price
Style",styleBar,maskPrice));
Plot(ZigP, "Zig", colorGold, styleThick);
//////////////////////////////////////////////////////////////////

xs1 = GetXSupport(ZigP, .01, 1);
xr1 = GetXResistance(ZigP, .01, 1);
ys1 = GetYSupport(ZigP, .01, 1);
yr1 = GetYResistance(ZigP, .01, 1);

if(xs1 < xr1) { x = LineArray(xs1, ys1, BarCount - 1, LastValue(ZigP)); Down = (yr1 - LastValue(ZigP)) / (yr1 - ys1); DnBars = BarCount - 1 - xr1; Plot(x, "", colorRed, styleDots); PlotText(StrFormat("%.3f (%.0f)", Down, DnBars), (xs1 + BarCount -1)/2, (ys1+LastValue(ZigP))/2, colorWhite); } else { x = LineArray(xr1, yr1, BarCount - 1, LastValue(ZigP)); Up = (LastValue(ZigP) - ys1) / (yr1 - ys1); UpBars = BarCount - 1 - xs1; Plot(x, "", colorRed, styleDots); PlotText(StrFormat("%.3f (%.0f)", Up, UpBars), (xr1 + BarCount -1)/2, (yr1+LastValue(ZigP))/2, colorWhite); } Plot( 1, "", IIf( xs1 > xr1, colorGreen,
colorRed),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
if(ShowRet)
for(i=2; i<=Period+1; i++)
{
xs0 = GetXSupport(ZigP, .01, i);
xs1 = GetXSupport(ZigP, .01, i-1);
ys0 = GetYSupport(ZigP, .01, i);
ys1 = GetYSupport(ZigP, .01, i-1);

xr0 = GetXResistance(ZigP, .01, i);
xr1 = GetXResistance(ZigP, .01, i-1);
yr0 = GetYResistance(ZigP, .01, i);
yr1 = GetYResistance(ZigP, .01, i-1);

xs = LineArray(xs0, ys0, xs1, ys1, 0);
Plot(xs, "", colorLightBlue, styleLine);
xr = LineArray(xr0, yr0, xr1, yr1, 0);
Plot(xr, "", colorLightBlue, styleLine);
if(xs1 < xr1)
{
Up = (yr1 - ys1) / (yr0 - ys1);
Down = (yr0 - ys1) / (yr0 - ys0);
UpBars = xr1 - xs1;
DnBars = xs1 - xr0;
}
else
{
Up = (yr1 - ys0) / (yr0 - ys0);
Down = (yr1 - ys1) / (yr1 - ys0);
UpBars = xr1 - xs0;
DnBars = xs1 - xr1;
}
PlotText(StrFormat("%.3f (%.0f)", Up, UpBars), (xr1 + xr0)/2, (yr1+yr0)/2,
colorWhite);
PlotText(StrFormat("%.3f (%.0f)", Down, DnBars), (xs1 + xs0)/2, (ys1+ys0)/2,
colorWhite);
//Plot(LineArray(xs0, ys0, BarCount-1, ys0), "", colorGreen, styleDashed);
//Plot(LineArray(xr0, yr0, BarCount-1, yr0), "", colorRed, styleDashed);

}

str = StrFormat(" (Bars to END=%.0f)\n", BarCount - 1 - BarIndex());
Title =FullName()+" ("+Name()+") - "+Date()+" - Open: "+O+", Hi: "+H+", Lo:
"+L+", Close: "+C+StrFormat(" (%.2f %.2f%%)", C-Ref(C, -1),
SelectedValue(ROC(C, 1)))+str;
WriteIf(1, "\nNote Fibonacci numbers:\nPrimary numbers: 0.618, 0.786, 1.27 and
1.618","");
WriteIf(1, "Secondary numbers: 0.382, 0.50, 1.00, 2.00, 2.24, 2.618 and
3.14","");


_SECTION_END();


ZigZag
Introduction

The ZigZag feature on SharpCharts is not an indicator per se, but rather a means to filter out smaller price movements. A ZigZag set at 10% would ignore all price movements less than 10%. Only price movements greater than 10% would be shown. Filtering out smaller movements gives chartists the ability to see the forest instead of just trees. It is important to remember that the ZigZag feature has no predictive power because it draws lines base on hindsight. Any predictive power will come from applications such as Elliott Wave, price pattern analysis or indicators. Chartists can also use the ZigZag with retracements feature to identify Fibonacci retracements and projections.
Calculation

The ZigZag is based on the chart "type". Line and dot charts, which are based on the close, will show the ZigZag based on closing prices. High-Low-Close bars (HLC), Open-High-Low-Close (OHLC) bars and candlesticks, which show the period's high-low range, will show the ZigZag based on this high-low range. A ZigZag based on the high-low range is more likely to change course than a ZigZag based on the close because the high-low range will be much larger and produce bigger swings.

The parameters box allows chartists to set the sensitivity of the ZigZag feature. A ZigZag with 5 in the parameter box will filter out all movements less than 5%. A ZigZag(10) will filter out movements less than 10%. If a stock traded from a reaction low of 100 to a high of 109 (+9%), there would not be a line because the move was less than 10%. If the stock advanced from a low of 100 to a high of 110 (+10%), there would be a line from 100 to 110. If the stock continued on to 112, this line would extend to 112 (100 to 112). The ZigZag would not reverse until the stock declined 10% or more from its high. From a high of 112, a stock would have to decline 11.2 points (or to a low of 100.8) to warrant another line. The chart below shows a QQQQ line chart with a 7% ZigZag. The early June bounce was ignored because it was less than 7% (black arrow). The two pullbacks in July were ignored because they were much less than 7% (red arrows).



Be careful with the last ZigZag line. Astute chartists will notice that the last ZigZag line is up, even though QQQQ advanced just 4.13% (43.36 to 45.15). This is just a temporary line because QQQQ has yet to reach the 7% change threshold. A move to 46.40 is needed for a gain of 7%, which would then warrant a permanent ZigZag line. Should QQQQ fail to reach the 7% threshold on this bounce and then decline below 43, this temporary line would disappear and the prior ZigZag line would continue from the early August high.


Elliott Wave Counts

The ZigZag feature can be used to filter out small moves and make Elliott Wave counts more straight-forward. The chart below shows the S&P 500 ETF with a 6% ZigZag to filter moves less than 6%. After a little trial and error, 6% was deemed the threshold of importance. An advance or decline greater than 6% was deemed significant enough to warrant a wave for an Elliott count. Keep in mind that this is just an example. The threshold and the wave count are subjective and dependent on individual preferences. Based on the 6% ZigZag, a complete cycle was identified from March 2009 until July 2010. A complete cycle consists of 8 waves, 5 up and 3 down.


Retracements and Projections

Sharpcharts users can choose between the normal "ZigZag" and "ZigZag (Retrace.)". As shown in the examples above, the normal ZigZag shows lines that move at least a specific percentage. The ZigZag (Retrace.) connects the reaction highs and lows with labels that measure the prior move. The numbers on the dotted lines reflect the difference between the current Zigzag line and the ZigZag line immediately before it. For example, the chart below shows Altera (ALTR) with the 15% ZigZag (Retrace.) feature. Three ZigZag lines have been labeled (1, 2 and 3). The dotted line connecting the low of Line 1 with the low of Line 2 shows a box with 0.638. This means Line 2 is .638 (63.8%) of Line 1. A number below 1 means the line is shorter than the prior line. The dotted line connecting the high of Line 2 with the high of Line 3 shows a box with 1.646. This means Line 3 is 1.646 (164.6%) of Line 2. A number above 1 means the line is longer than the prior line.



As you may have guessed, seeing these lines as a percentage of the prior lines makes it possible to assess Fibonacci retracements Fibonacci projections. The August decline (Line 2) retraced around 61.8% of the June-July advance (Line 1). This is a classic Fibonacci retracement. The advance from early September to early November was 1.646 times the August decline. In this sense, the ZigZag (Retrace.) can be used to project the length of an advance. Again, 1.646 is close to the Fibonacci 1.618, which is the Golden Ratio used in many projection estimates. See our ChartSchool article for more on Fibonacci retracements.
Conclusions

The ZigZag and ZigZag (Retrace.) filter price action and do not have any predictive power. The ZigZag lines simply react when prices move a certain percentage. Chartists can apply an array of technical analysis tools to the ZigZag. Chartists can perform basic trend analysis by comparing reaction highs and lows. Chartists can also overlay the ZigZag feature to look for price patterns that might not be as visible on a normal bar or line chart. The ZigZag has a way of highlighting the important movements and ignoring the noise. When using the ZigZag feature, don't forget to measure the last line to determine if it is temporary or permanent. The last ZigZag line is temporary if the current price change is less than the ZigZag parameter. The last line is permanent when the price change is greater than or equal to the ZigZag parameter.
SharpCharts

The ZigZag and ZigZag (Retrace.) can be found in SharpCharts as a price overlay in the Chart Attributes section or as an addition to an indicator. Upon selecting the Zigzag feature from the drop down box, the parameters window will appear empty. Five (5%) is the default parameter, but this can change depending on a security's price characteristics. Some securities produce too few Zigzag lines at 5% so the default is set lower (e.g. 3.75%). Some securities produce too many zigzag lines at 5% so the default is set higher (e.g. 6.25%). The Zigzag parameter can be seen in the upper left corner of the chart. Once the Zigzag feature is applied, chartists can adjust the parameter to suit their charting needs. A lower number will make the feature more sensitive, while a higher number will make it less sensitive. Click here for a live chart with the Zigzag (Retrace.) feature.






Further Study

Book: Fibonacci Ratios With Pattern Recognition - Larry Pesavento. This book details high probability patterns based on Fibonacci price retracements and projections. These setups are designed to provide good risk-reward setups for traders and investors.

Book: Elliott Wave Principle - Robert Prechter. This highly acclaimed handbook of Elliott Wave Theory is regarded as the definitive work in this area. Prechter covers Fibonacci numbers and ratios, wave analysis, time sequences and cycle analysis.

Twiggs Money Flow

Twiggs Money Flow is a derivation of Chaikin Money Flow indicator, which is in turn derived from the Accumulation Distribution line. However, Twiggs Money Flow makes two basic improvements to the Chaikin Money Flow formula:

To solve the problem with gaps, Twiggs Money Flow uses true range, rather than daily Highs minus Lows.
And, rather than a simple-moving-average-type formula, Twiggs Money Flow applies exponential smoothing, using the method employed by Welles Wilder for many of his indicators.
To know more, please go to:
http://www.incrediblecharts.com/technical/twiggs_money_flow.htm
(See also hyperlink above in "Origin" field)
Formula:
_SECTION_BEGIN("Twiggs Money Flow");
/*
Twiggs Money Flow is a derivation of Chaikin Money Flow indicator, which is in
turn derived from the Accumulation Distribution line.
However, Twiggs Money Flow makes two basic improvements to the Chaikin Money
Flow formula:
1-To solve the problem with gaps, Twiggs Money Flow uses true range, rather
than daily Highs minus Lows.
2-And, rather than a simple-moving-average-type formula, Twiggs Money Flow
applies exponential smoothing, using the method employed by Welles Wilder for
many of his indicators.
*/

periods = Param( "Periods", 21, 5, 200, 1 );
TRH=Max(Ref(C,-1),H);
TRL=Min(Ref(C,-1),L);
TR=TRH-TRL;
ADV=V*((C-TRL)-(TRH-C))/ IIf(TR==0,9999999,TR);
WV=V+(Ref(V,-1)*0);
SmV= Wilders(WV,periods);
SmA= Wilders(ADV,periods);

TMF= IIf(SmV==0,0,SmA/SmV);
Plot( TMF, _DEFAULT_NAME(), ParamColor("color", colorCycle ),
ParamStyle("Style") );
_SECTION_END();

To add color filled into add this code at the bottom before the _SECTION_END ();

=-=-=-=-=-=-=-=-=-=-

Plot( TMF, _DEFAULT_NAME(), ParamColor("color", colorCycle ), ParamStyle("Style") ); //Chris
m = IIf(SmV==0,0,SmA/SmV); //Chris
PlotOHLC( m,m,0,m, _DEFAULT_NAME(), IIf( m > 0, colorGreen, colorRed ), styleCloud); //Chris

=-=-=-=-=-=-=-=-=-=-=-

http://www.amibroker.com/guide/afl/afl_view.php?id=122

09 February 2011

TOP 8 TIPS FOR TRADERS/TRADING

"Everybody wants to be rich", and you can become rich if you follow these share trading tips. But, if you don't follow these share trading tips, you'll probably end up broke. Also, If you ever lose money on a trade, make sure you understand why. Re-read these share trading tips and figure out how many of these share trading tips were ignored.

1.) Have a Definite Plan and Stick with It - You must take time after each trading day to analyze the action of the market, consider the technical and fundamentals, then plan what you will do the next trading day - buy, sell, or hold. Before the opening of the market each day, you must recheck your analysis from the previous day. Since, something new could have occurred over night.

2.) Do not Trade Impulsively - The biggest weakness of every trader is giving in to impulse trading. Impulse trading is basically gambling and can cause you to lose the largest amount of money by invoking your emotions of fear, greed and inability to recognize you made a bad trade. Successful traders know they will make bad trades from time to time. But they never hold on stubbornly to a losing position. They try to keep their losses small.

3.) Look for Special Situations - Avoid low volume trading shares. Why waste your time and tie up your funds with inactive shares? Instead, look for shares that offer you an opportunity to gain at least 30% or more in only a few weeks. Usually, this means you must turn your attention away from certain shares you personally like and trade in shares that looks ready to move in a definite direction.

4.) Learn How to Sell Short - To make the most money from share trading you must be ready and willing to sell shares "short". Short selling is the selling of shares that the seller doesn't own. More specifically, a short sale is the sale of a security that isn't owned by the seller, but that is promised to be delivered. In fact, you can make more money faster selling short than you can by going long.

5.) Never Sell A New High - If the market keeps making new highs, there are good reasons for it. It's smarter to be "long", bet on shares rising, and go with the up trend than try to go "short", betting on shares falling, and fight against the trend. There's no way of knowing how high the market may move against you. Wait a few days for a definite indication of a reversal in trend. It might be several days or weeks.

6.) Never Buy A New Low - If the market keeps making new lows, there are good reasons for it. It's smarter to be "short", bet on shares falling, and go with the down trend than try to go "long", betting on shares rising, and fight against the trend. There's no way of knowing how low the market may move against you. Wait a few days for a definite indication of a reversal in trend. It might be several days or weeks.

7.) Trade Only with Funds You can Afford to Lose - If you can't afford to lose whatever money you have, you will find it almost impossible to win. The reason is you won't be able to follow the tips given in this article. And, if you fail to follow these tips, you probably won't make any profits.

8.) Cut Your Losses and Let Your Profits Grow - This is the most important tip. It's also the hardest to follow. But you must embrace this tip or you'll never become rich from trading. Few traders have the discipline to take small losses. If you are one of the few who can do this, you have a very good chance of becoming an elite trader. When most traders make a trade, they believe they're correct. If the market moves against them, they stubbornly hold on. They hate to admit they're wrong. Even when their loss grows larger, they refuse to take that loss and get out. They hope the market will turn around soon and prove them correct or at least move back to reduce their losses. But, more times than not, the market does not return to that level. When you place your order to buy or sell "short", you'll usually know whether you are right or wrong before the week is over. If you are wrong and the trade you made shows a loss of 20% or more, you should get out before the close of the market that day. Taking such a loss takes a lot of courage.

Finally, make sure all of the Share Trading Tips are pointing in the same direction, up or down. If your financial mentor also agrees, then you have a good chance of making a successful trade.

My Blog List

Total Pageviews

Search This Blog

Followers