// Downloaded From https://www.WiseStockTrader.com /******************************************************* Candlestick Commentary Load this file into the Commentary Option of the Analysis tab. Green arrows indicate bullish candles. Red arrows indicate bearish candles. Scroll down the commentary for comments. This is a work in progress. Thanks to all on this forum whose code I may have incorporated into this file. Comments are from Steve Nison "Japanese Candlestick Charting Techniques" and the LitWick web site. **********************************************************/ /*Body Colors*/ whiteBody=C>=O; blackBody=O>C; /*Body Size*/ smallBodyMaximum=0.0025;//less than 0.25% LargeBodyMinimum=0.01;//greater than 1.0% smallBody=(O>=C*(1-smallBodyMaximum) AND whiteBody) OR (C>=O*(1-smallBodyMaximum) AND blackBody); largeBody=(C>=O*(1+largeBodyMinimum) AND whiteBody) OR C<=O*(1-largeBodyMinimum) AND blackBody; mediumBody=NOT LargeBody AND NOT smallBody; identicalBodies=abs(abs(Ref(O,-1)-Ref(C,-1))-abs(O-C)) < abs(O-C)*smallBodyMaximum; realBodySize=abs(O-C); /*Shadows*/ smallUpperShadow=(whiteBody AND H<=C*(1+smallBodyMaximum)) OR (blackBody AND H<=O*(1+smallBodyMaximum)); smallLowerShadow=(whiteBody AND L>=O*(1-smallBodyMaximum)) OR (blackBody AND L>=C*(1-smallBodyMaximum)); largeUpperShadow=(whiteBody AND H>=C*(1+largeBodyMinimum)) OR (blackBody AND H>=O*(1+largeBodyMinimum)); largeLowerShadow=(whiteBody AND L<=O*(1-largeBodyMinimum)) OR (blackBody AND L<=C*(1-largeBodyMinimum)); /*Gaps*/ upGap= IIf(Ref(blackBody,-1)AND whiteBody AND O>Ref(O,-1),1, IIf(Ref(blackbody,-1) AND blackBody AND C>Ref(O,-1),1, IIf(Ref(whiteBody,-1) AND whiteBody AND O>Ref(C,-1),1, IIf(Ref(whiteBody,-1) AND blackBody AND C>Ref(C,-1),1,0)))); downGap=IIf(Ref(blackBody,-1)AND whiteBody AND C2*realBodySize) OR (whiteBody AND abs(H-C)>2*realBodySize)); Hammer = (((H-L)>3*(O-C)) AND ((C-L)/(0.001+H-L)>0.6) AND ((O-L)/(0.001+H-L)>0.6)); InvertedHammer = (((H-L)>3*(O-C)) AND ((H-C)/(0.001+H-L)>0.6) AND ((H-O)/(0.001+H-L)>0.6)); //Hammer=smallUpperShadow AND NOT doji AND // ((blackBody AND abs(C-L)>2*realBodySize) OR // (whiteBody AND abs(L-O)>2*realBodySize)); tweezerTop=abs(H-Ref(H,-1))<=H*0.0025; tweezerBottom=abs(L-Ref(L,-1))<=L*0.0025; engulfing= IIf(blackBody AND Ref(blackbody,-1) AND CRef(O,-1),1, IIf(blackBody AND Ref(whiteBody,-1) AND O>Ref(C,-1) AND CRef(C,-1) AND ORef(O,-1)AND ORef(L,-1),1, IIf(blackBody AND Ref(whiteBody,-1) AND C>Ref(L,-1) AND ORef(L,-1),1, IIf(whiteBody AND Ref(blackBody,-1) AND O>Ref(L,-1) AND CRef(C,-1),1, IIf(blackBody AND Ref(whiteBody,-1) AND C>Ref(O,-1) AND ORef(O,-1),1, IIf(whiteBody AND Ref(blackBody,-1) AND O>Ref(C,-1) AND C Ref( High , -1 ) OR Ref(x1, -2) AND Close > Ref( High , -2 )OR Ref(x1, -3) AND Close > Ref( High , -3 ); GetreadyBuy1=((NOT Ref(GetreadyBuy,-1)) AND (NOT Ref(GetreadyBuy,-2))); GetreadyBuy3=GetreadyBuy1 AND GetReadyBuy; Buy=Ref(GetreadyBuy, -1) AND C>Ref(L,-1); Buy1=(NOT Ref(Buy,-1)); Buy3=Buy1 AND Buy; BuyStop=Ref(GetreadyBuy,-1) AND (Ref(L,-1)); x2=InvertedHammerSpecial; GetreadySell=Ref(x2, -1) AND Close < Ref( Low , -1 ) OR Ref(x2, -2) AND Close < Ref( Low , -2 )OR Ref(x2, -3) AND Close < Ref( Low , -3 ); GetreadySell1=((NOT Ref(GetreadySell,-1)) AND (NOT Ref(GetreadySell,-2))); GetreadySell3=GetreadySell1 AND GetReadySell; Short=Ref(GetreadySell, -1) AND CRef(L,-2); Sell1=((NOT Ref(Sell,-1)) AND (NOT Ref(Sell,-2))); Sell2=Sell1 AND Sell; Cover1=((NOT Ref(Cover,-1)) AND (NOT Ref(Cover,-2))); Cover2=Cover1 AND Cover; _SECTION_BEGIN("Title"); if( Status("action") == actionIndicator ) ( Title = EncodeColor(colorYellow)+ "Winston system - 1-hammer, 2-getready, up/down arrow=Enter position, Orange colour short and white colour long, white dot trailing profit exit long and orange dot trailing profit exit short, triangles are pivot markers" + " - " + Name() + " - " + EncodeColor(colorYellow)+ Interval(2) + EncodeColor(colorWhite) + " - " + Date() +" - "+"\n" +EncodeColor(colorYellow) + "Vol= "+ WriteVal(V)+"\n"+ EncodeColor(colorYellow)+ WriteIf(x1, "1-Hammer Special"+C+" ","")+ WriteIf(GetreadyBuy3, "2-Get Ready to Buy"+C+" ","")+ WriteIf(Buy3, "BUY AT "+C+" ","")+ WriteIf(BuyStop, "BUYSTOP AT"+Ref(L,-2)+" ","")+ WriteIf(Sell2, "Exit Buy at "+C+" ","")+ WriteIf(x2, "1-Inverted Hammer Special"+C+" ","")+ WriteIf(GetreadySell3, "2-Get Ready to Short"+C+" ","")+ WriteIf(Short3, " SHORT AT "+C+" ","")+ WriteIf(ShortStop, "SHORTSTOP AT "+Ref(H,-2)+" ","")+ WriteIf(Cover2, "Exit short at "+C+" ","")); Plot(C,"Close",colorWhite,64); PlotShapes(x1*shapeDigit1,colorWhite,0,L); PlotShapes(GetreadyBuy3*shapeDigit2,colorWhite,0,L); PlotShapes(Buy3*shapeUpArrow,colorWhite,0,L,Offset=-45); PlotShapes(Sell2*shapeSmallCircle,colorWhite,0,H,Offset=45); PlotShapes(x2*shapeDigit1,colorOrange,0,H,Offset=25); PlotShapes(GetreadySell3*shapeDigit2,colorOrange,0,H,Offset=25); PlotShapes(Short3*shapeDownArrow,colorOrange,0,H,Offset=-45); PlotShapes(Cover2*shapeSmallCircle,colorOrange,0,L,Offset=-45); AlertIf( Ref(GetreadyBuy3, -1), "SOUND C:\\Windows\\Media\\Ringin.wav", "Get Ready To Buy", 2 ); AlertIf( Ref(Buy3, -1), "SOUND C:\\Windows\\Media\\Ringin.wav", "Buy Now", 2 ); AlertIf( Ref(GetreadySell3, -1), "SOUND C:\\Windows\\Media\\Ringin.wav", "Get Ready To Short", 2 ); AlertIf( Ref(Short3, -1), "SOUND C:\\Windows\\Media\\Ringin.wav", "Short Now", 2 ); RSIperiod = 14; // Param("RSI p",3,14,30,1); Percent = 5; // Param("ZIG %",8,9,15,1); EMAperiod = 9; //Param("EMA p",4,5,10,1); HHVperiod = 8; //Param("HHV p",3,5,10,1); NumLine = 2; //Param("Num Lines",3,1,20,1); Base = DEMA(RSI(RSIperiod),EMAperiod); for( i = 1; i <= numline; i++ ) { ResBase = LastValue(Peak(Base,Percent,i)); SupBase = LastValue(Trough(Base,Percent,i)); Plot(ValueWhen( ResBase==Base, HHV(H,HHVperiod) ), "Resist Level", colorDarkRed, styleLine); Plot(ValueWhen( supbase==Base, LLV(L,HHVperiod) ), "Support Level", colorDarkGreen, styleLine); } //Code to automatically identify pivots //********************************** */ // -- what will be our lookback range for the hh and ll? farback=Param("How Far back to go",100,50,5000,10); nBars = Param("Number of bars", 12, 5, 40); // -- Create 0-initialized arrays the size of barcount aHPivs = H - H; aLPivs = L - L; // -- More for future use, not necessary for basic plotting aHPivHighs = H - H; aLPivLows = L - L; aHPivIdxs = H - H; aLPivIdxs = L - L; nHPivs = 0; nLPivs = 0; lastHPIdx = 0; lastLPIdx = 0; lastHPH = 0; lastLPL = 0; curPivBarIdx = 0; // -- looking back from the current bar, how many bars // back were the hhv and llv values of the previous // n bars, etc.? aHHVBars = HHVBars(H, nBars); aLLVBars = LLVBars(L, nBars); aHHV = HHV(H, nBars); aLLV = LLV(L, nBars); // -- Would like to set this up so pivots are calculated back from // last visible bar to make it easy to "go back" and see the pivots // this code would find. However, the first instance of // _Trace output will show a value of 0 aVisBars = Status("barvisible"); nLastVisBar = LastValue(Highest(IIf(aVisBars, BarIndex(), 0))); _TRACE("Last visible bar: " + nLastVisBar); // -- Initialize value of curTrend curBar = (BarCount-1); curTrend = ""; if (aLLVBars[curBar] < aHHVBars[curBar]) { curTrend = "D"; } else { curTrend = "U"; } // -- Loop through bars. Search for // entirely array-based approach // in future version for (i=0; i lastHPIdx) { // -- Bar and price info for candidate pivot candIdx = curBar - aHHVBars[curBar]; candPrc = aHHV[curBar]; if ( lastHPH < candPrc AND candIdx > lastLPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aHPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j candPrc AND candIdx > lastHPIdx AND candIdx < curBar) { // -- OK, we'll add this as a pivot... aLPivs[candIdx] = 1; // ...and then rearrange elements in the // pivot information arrays for (j=0; j