Zig Zag Camarilla Final -21.07.2013

Embed Size (px)

DESCRIPTION

Zig Zag Camarilla Final -21.07.2013

Citation preview

_SECTION_BEGIN("talking system"); //------------------------------------------------------------------------------////This indicator displays how far the closing price is above or below a 20//period moving average in % terms. It is displayed as a histogram and the//bars are green if the closing price is above the MA and red if the closing//price is below the MA.////T may be changed to alter the MA period. ie Change T=20 to T=200 for the//200 period MA./////*talking system*/////T=20; /*Time Period for MA*/////KMA=((C-MA(C,T))/MA(C,T))*100;////GRAPH0=KMA;////GRAPH0STYLE=2+4;////GRAPH0BARCOLOR=iif(KMA>0,5,4);////graphxspace=5;//////Mark Grid lines:////Level 0////Limits////Show dates////Percent////Middle////------------------------------------------------------------------------------/*talking system*/T=20; /*Time Period for MA*/KMA=((C-MA(C,T))/MA(C,T))*100; Graph0=KMA;Graph0Style=2+4;Graph0BarColor=IIf(KMA>0,5,4);GraphXSpace=5;_SECTION_END();_SECTION_BEGIN("Price");SetChartOptions(0,chartShowArrows|chartShowDates);_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) )); Plot( C, "Close", ParamColor("Color", colorBlue ),styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); _SECTION_END();_SECTION_BEGIN("Draw Camarilla Levels");SetChartOptions(0,chartShowArrows|chartShowDates);showcamarella=ParamList("Show Camarella Lines","YES|NO");showcandlechart=ParamList("Show Candle chart","YES|NO");showwhat=IIf(ParamList("Todays or Tomorrows Levels","Today|Tomorrow")=="Tomorrow",1,-1);if (showcandlechart=="YES"){Plot( C, "Close", ParamColor("Color", colorWhite ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); }EMA10=EMA(C,10);EMA3=EMA(C,3);XH = TimeFrameGetPrice( "H", inDaily,showwhat);XL = TimeFrameGetPrice( "L", inDaily,showwhat);XC = TimeFrameGetPrice( "C", inDaily, showwhat );r2=(((xh-xl)*1.1)/2)+xc;r1=(((xh-xl)*1.1)/4)+xc;s1=(xc-((xh-xl)*1.1)/4);s2=(xc-((xh-xl)*1.1)/2);n3=1;tgt1=(1+.005*n3)*r2;tgt2=(1+.01*n3)*r2;tgt3=s2/(1+.005*n3);tgt4=s2/(1+.01*n3);if (showcamarella=="YES"){Plot(r1,"R1",colorGreen,styleLine|styleNoTitle);Plot(r2,"R2",colorGreen,styleLine|styleNoTitle);Plot(s1,"S1",colorRed,styleLine|styleNoTitle);Plot(s2,"S2",colorRed,styleLine|styleNoTitle);Plot(tgt1,"tgt1",colorYellow,styleLine|styleNoTitle);Plot(tgt2,"tgt2",colorYellow,styleLine|styleNoTitle);Plot(tgt3,"tgt3",colorYellow,styleLine|styleNoTitle);Plot(tgt4,"tgt4",colorYellow,styleLine|styleNoTitle);Plot(s1+(0.85*(r1-s1)),"int long target 2",colorBlue,styleLine|styleNoTitle);Plot(s1+(0.65*(r1-s1)),"int long target 1",colorBlue,styleLine|styleNoTitle);Plot(s1+(0.35*(r1-s1)),"int short target 1",colorPink,styleLine|styleNoTitle);Plot(s1+(0.15*(r1-s1)),"int short target 2",colorPink,styleLine|styleNoTitle);Buy=Cross(C,s1) OR Cross(C,r1) OR Cross(C,r2);Sell=Cross(r1,C) OR Cross(s1,C) OR Cross(s2,C);//parametersgapavg=Param("Gap between Averages",8,0,20,.1);gapcam=Param("Gap between Cam lines and fast avg",3.8,0,20,.1);SP=Param("Stop Profit",23,0,25,.1);Camlevel=IIf(abs(EMA3-r1)EMA3[i])) AND Camlevel[i]-EMA3[i]>gapcam AND O[i]>C[i]){if (lastbuy==1)profit[i]=profit[i]+Cvp[i]-priceatbuy;if (Lastsell==1)profit[i]=profit[i]+priceatsell-Cvp[i];Lastbuy=Lastsell=lastexitbuy=lastexitsell=0;Sellsignal=0;Sell[i]=1;Lastsell=1;priceatsell=Cvp[i];slow[i]=L[i];shigh[i]=H[i];Curri=i;}if ((Lastbuy==1 OR (lastexitbuy==1 AND cvp[i]-priceatexitbuy>4)) AND shigh[i]-Cvp[i]>sp AND !Sell[i] AND i>Curri){profit[i]=profit[i]+Cvp[i]-priceatbuy;exitbuy[i]=1;Lastexitbuy=1;Lastbuy=0;slow[i]=L[i];shigh[i]=H[i];priceatexitbuy=Cvp[i];Curri=i;}if ((Lastsell==1 OR (Lastexitsell==1 AND priceatexitsell-Cvp[i]>4)) AND Cvp[i]-slow[i]>sp AND !Buy[i] AND i>Curri){profit[i]=profit[i]+priceatsell-Cvp[i];exitsell[i]=1;Lastexitsell=1;Lastsell=0;slow[i]=L[i];shigh[i]=H[i];priceatexitsell=Cvp[i];Curri=i;}if (i>Curri AND Lastexitsell==1 AND priceatexitsell-Cvp[i]>4){Sellsignal=1;Lastexitsell=0;}if (i>Curri AND Lastexitbuy==1 AND Cvp[i]-priceatexitbuy>4){buySignal=1;Lastexitbuy=0;}if (Buy[i] OR Sell[i] OR exitbuy[i] OR exitsell[i]){PlotText(WriteVal(Profit[i],1.0),i,H[i]+15,colorGreen);}}shape = Buy * shapeUpArrow + Sell * shapeDownArrow;PlotShapes( shape, IIf( Buy, colorLime, colorRed ), 0, IIf( Buy, Low, High));shape2 = exitsell *shapeHollowUpArrow + exitbuy *shapeHollowDownArrow;PlotShapes( shape2, IIf( exitsell, colorWhite, colorWhite ), 0, IIf( exitsell, Low, High));}function GetSecondNum(){Time= Now( 4 );Seconds= int( Time % 100 );Minutes= int( Time / 100 % 100 );Hours= int( Time / 10000 % 100 );SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds );return SecondNum;} RequestTimedRefresh( 1 );TimeFrame = Interval();SecNumber = GetSecondNum();Newperiod = SecNumber % TimeFrame == 0;SecsLeft= SecNumber - int( SecNumber / TimeFrame ) * TimeFrame;SecsToGo= TimeFrame - SecsLeft;// Background colorSetChartBkColor(ParamColor("Panel color ",colorBlack)); Title = Date()+""+ Interval(format=2)+""+Name()+" O "+WriteVal(O,1.2)+" H "+WriteVal(H,1.2)+"L "+WriteVal(L,1.2)+" C "+WriteVal(C,1.2)+" Cam level " + WriteVal(Camlevel,1.2)+" Fast avg "+WriteVal(EMA3,1.2)+" CurrHigh "+WriteVal(shigh,1.2)+" Currlow "+WriteVal(slow,1.2)+" Avg Price "+WriteVal(Cvp,1.2)+" "+ EncodeColor(colorYellow)+ " Bar secs remaining "+WriteVal(secstogo,1.0);_SECTION_BEGIN("Magnified Price");FS=Param("Font Size",30,11,100,1);GfxSelectFont("Times New Roman", FS, 700, True );GfxSetBkMode( colorWhite ); GfxSetTextColor( ParamColor("Color",colorYellow) );Hor=Param("Horizontal Position",550,1,1200,1);Ver=Param("Vertical Position",1,1,830,1);GfxTextOut(""+C, Hor , Ver );YC=TimeFrameGetPrice("C",inDaily,-1);DD=Prec(C-YC,2);xx=Prec((DD/YC)*100,2);GfxSelectFont("Times New Roman", 11, 700, True );GfxSetBkMode( colorWhite ); GfxSetTextColor(ParamColor("Color",colorYellow) );GfxTextOut(""+DD+"("+xx+"%)", Hor , Ver+45 ); _SECTION_END();//Topping Bar//Range = H - L ;//TPB = Volume > MA(Volume,9) AND Close < Low + Range/2 AND Range MyCL AND V/1000> MyVK AND C*V/100000 > MyTL AND TLM > 0.333 * MyTL ; // commonfast = 2/(2+1);slow = 2/(30+1);//BUY partdirb=abs(Close-Ref(Close,-bs));volb=Sum(abs(Close-Ref(Close,-1)),bs);ERb=dirb/volb;scb =( ERb*(fast-slow)+slow)^2; xb = AMA( C, scb ); flb=bf*StDev(xb-Ref(xb,-1),20);j=xb-Ref(xb,-3);//SELL partdirs=abs(Close-Ref(Close,-ss));vols=Sum(abs(Close-Ref(Close,-1)),ss);ERs=dirs/vols;scs =( ERs*(fast-slow)+slow)^2; xs = AMA( C, scs ); fls=sf*StDev(xs-Ref(xs,-1),20);k=Ref(Xs,-3)-Xs;Buy=Cross(j,flb) ;Sell=Cross(k,fls);mycolor=IIf(C>xb,colorLime,colorRed);Buy = ExRem(Buy,Sell);Sell = ExRem(Sell,Buy);shape = Buy * shapeUpArrow +Sell * shapeDownArrow ;AlertIf( Buy, "SOUND C:\\Windows\\Media\\Chord.wav", "Audio alert", 2 );AlertIf( Sell, "SOUND C:\\Windows\\Media\\Ding.wav", "Audio alert", 2 ); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-30);PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-20);PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);_SECTION_END();_SECTION_BEGIN("TREND");SetBarsRequired(100000,0);GraphXSpace = 15;ea = EMA (C,10);eb = EMA (C,20);SetBarFillColor( IIf( ea > eb, colorGreen, colorRed ) ); Buy = ea > eb AND TimeNum() > 092000 AND TimeNum() < 150000;Sell = eb > ea OR TimeNum() > 150000;Short = 0;Cover = 0;Buy = ExRem(Buy,Sell);Sell = ExRem(Sell,Buy);Short = ExRem(Short,Cover);Cover = ExRem(Cover,Short);SetTradeDelays(1,1,1,1);Factor=Param("Factor",4,1,10,1);Pd=Param("ATR Periods",10,1,100,1);Up=(H+L)/2+(Factor*ATR(Pd));Dn=(H+L)/2-(Factor*ATR(Pd));iATR=ATR(Pd);TrendUp=TrendDown=Null;trend[0]=1;changeOfTrend=0;flag=flagh=0;for (i = 1; i Up[i-1]) { trend[i]=1; if (trend[i-1] == -1) changeOfTrend = 1; }else if (Close[i]0 && trend[i-1]0 && Dn[i]1;i--){if(Buy[i] == 1){entry = C[i];sig = "BUY";sl = TrendSL[i];tar1 = entry + (entry * .0050);tar2 = entry + (entry * .0092);tar3 = entry + (entry * .0179); bars = i;i = 0;}if(Sell[i] == 1){sig = "SELL";entry = C[i];sl = TrendSL[i];tar1 = entry - (entry * .0050);tar2 = entry - (entry * .0112);tar3 = entry - (entry * .0212); bars = i;i = 0;}}Offset = 20;Clr = IIf(sig == "BUY", colorLime, colorRed);ssl = IIf(bars == BarCount-1, TrendSL[BarCount-1], Ref(TrendSL, -1));sl = ssl[BarCount-1]; for (i=bars; i