I have provided a formula below that uses PlotText. Look in Paramaters and you will see Text H Shift. Play with it and you will see how to implement changing x axis position of the text.
David K. --- In [email protected], "r_terbush" <ra...@...> wrote: > > I am trying to plot some values for pivot lines on the left side of > the chart instead of plotting them in the y-axis price area. > > I am coming to conclusion that I need to use PlotText() to do this. > Can someone help me with how to determine the x-axis value for the > leftmost visible bar on the chart? > > Thanks > _SECTION_BEGIN("Chart Settings"); SetChartOptions(0,chartShowArrows|chartShowDates); SetChartBkColor(ParamColor("Outer panel",colorBlack)); SetChartBkGradientFill( ParamColor("Inner panel upper",colorDarkGrey), ParamColor("Inner panel lower",colorBlack)); numbars = LastValue(Cum(Status("barvisible"))); dec = (Param("Decimals",2,0,7,1)/10)+1; bi=BarIndex(); sbi = BarIndex(); Plot(C,"",IIf(C>O,27, IIf(C<O,32,colorGrey50)),64); _SECTION_BEGIN("Fib Levels"); pct = Param( "Pivot %",1.0,0.10,60,0.10); fibi = ParamToggle("Plot IR Fibs","Off|On",0); hLb=Param("High Look Back",1,1,30,1); lLb=Param("Low Look Back",1,1,30,1); irtxt = ParamToggle("IR Text Labels","Off|On",0); fts = Param ("Text H Shift", -36.1,-50,50,0.10); ///////////////////// pk=PeakBars(H,pct)==0; tr=TroughBars(L,pct)==0; zHi=Zig(H,pct); zLo=Zig(L,pct); HLAvg=(zHi+zLo)/2; zp=IIf(pk,zHi,IIf(tr,zLo,IIf(HLAvg>Ref(HLAvg,-1),H,L))); za=Zig(zp,pct); pR=Ref(za,-1)<za AND za>Ref(za,1); pS=Ref(za,-1)>za AND za<Ref(za,1); Plot(za,"",11,1|styleNoLabel); PlotShapes(shapeDownArrow*pR,colorBrightGreen,0,H,-18); PlotShapes(shapeUpArrow*pS,colorYellow,0,L,-18); //////////////////////////////////////////////// _SECTION_BEGIN("Fibs"); xr0=SelectedValue(ValueWhen(pR,sbi,hLb)); yr0=SelectedValue(ValueWhen(pR,zp,hLb)); xs0=SelectedValue(ValueWhen(pS,sbi,lLb)); ys0=SelectedValue(ValueWhen(pS,zp,lLb)); x1=BarCount-1; deltaP=abs(yr0-ys0); sup=xs0>xr0; res=xr0>xs0; respct = IIf(xr0>xs0,0,100); suppct = IIf(xs0>xr0,0,100); resLp=LineArray(xr0,yr0,x1,yr0,0); supLp = LineArray(xs0,ys0,x1,ys0,0); //////////////////// function fibr(fibv) { delta=abs(yr0-ys0); retval=delta*fibv; fibval=IIf(res,yr0-retval,IIf(sup,ys0+retval,Null)); return fibval; } ////////////////Fib Retracements///////////////// f236=fibr(0.236);f382=fibr(0.382);f500=fibr(0.500); f618=fibr(0.618);f786=fibr(0.786);f127=fibr(1.272); f162=fibr(1.620);f200=fibr(2.000);f262=fibr(2.620); f314=fibr(3.141);f424=fibr(4.240); //////////////////////// function ifib(ifib) { x0= IIf(res,xr0,xs0); x1=BarCount-1; ifibline=LineArray(x0,ifib,x1,ifib); return ifibline; } if(fibi==1) { istyle=styleDashed|styleNoLabel|styleNoRescale; Plot(resLp,"",32,8); Plot(supLp,"",55,8); Plot(ifib(f236),"",40,istyle); Plot(ifib(f382),"",36,istyle); Plot(ifib(f500),"", 6,istyle); Plot(ifib(f618),"",43,istyle); Plot(ifib(f786),"",42,istyle); Plot(ifib(f127),"",10,istyle); Plot(ifib(f162),"",34,istyle); Plot(ifib(f200),"",55,istyle); Plot(ifib(f262),"",51,istyle); Plot(ifib(f424),"",32,istyle); } if(irtxt==1) { VizBars = Status("LastVisibleBar")-Status("FirstVisibleBar"); Bars = (round(Vizbars/fts)); mxpos = SelectedValue(BarIndex())-(Bars); //////////////////// PlotText(StrFormat("%.2f %.0f % ",resLp,respct)+"%",mxpos,yr0,32); PlotText(StrFormat("%.2f %.0f % ",supLp,suppct)+"%",mxpos,ys0,55); PlotText("" + NumToStr(f236,dec)+ " 23%",mxpos,f236,40,1); PlotText("" + NumToStr(f382,dec)+ " 38%",mxpos,f382,36,1); PlotText("" + NumToStr(f500,dec)+ " 50%",mxpos,f500,11,1); PlotText("" + NumToStr(f618,dec)+ " 62%",mxpos,f618,43,1); PlotText("" + NumToStr(f786,dec)+ " 78%",mxpos,f786,42,1); PlotText("" + NumToStr(f127,dec)+ " 127%",mxpos,f127,10,1); PlotText("" + NumToStr(f162,dec)+ " 162%",mxpos,f162,34,1); PlotText("" + NumToStr(f200,dec)+ " 200%",mxpos,f200,55,1); PlotText("" + NumToStr(f262,dec)+ " 262%",mxpos,f262,51,1); PlotText("" + NumToStr(f424,dec)+ " 424%",mxpos,f424,32,1); } Title = EncodeColor(55)+ Title = Name() + " " + EncodeColor(55) + Date() + " " + EncodeColor(3) + "{{INTERVAL}} " + EncodeColor(55)+ " Open = "+ EncodeColor(10)+ NumToStr (O,dec) + EncodeColor(55)+ " High = "+ EncodeColor(43) + NumToStr (H,dec) + EncodeColor(55)+ " Low = "+ EncodeColor(32)+ NumToStr (L,dec) + EncodeColor(55)+ " Close = "+ EncodeColor(42)+ NumToStr (C,dec) + EncodeColor(55)+ " BI = "+ EncodeColor(42)+ NumToStr (bi,1.0) + EncodeColor(55)+ " Volume = "+ EncodeColor(55)+ NumToStr (V,1.0) +"\n"+"\n"+ EncodeColor(55)+ " Sup = "+ EncodeColor(55)+ NumToStr (ys0,dec) +"\n"+ EncodeColor(40)+ " 23%= "+ EncodeColor(40)+ NumToStr (f236,dec) +"\n"+ EncodeColor(36)+ " 38%= "+ EncodeColor(36)+ NumToStr (f382,dec) +"\n"+ EncodeColor(55)+ " 50% = "+ EncodeColor(55) + NumToStr (f500,dec) +"\n"+ EncodeColor(43)+ " 62% = "+ EncodeColor(43)+ NumToStr (f618,dec) +"\n"+ EncodeColor(42)+ " 78% = "+ EncodeColor(42)+ NumToStr (f786,dec) +"\n"+ EncodeColor(55)+ " Res = "+ EncodeColor(55)+ NumToStr (yr0,dec) +"\n"+ EncodeColor(10)+ "127% = "+ EncodeColor(10)+ NumToStr (f127,dec) +"\n"+ EncodeColor(34)+ "162% = "+ EncodeColor(34)+ NumToStr (f162,dec) +"\n"+ EncodeColor(55)+ "200% = "+ EncodeColor(55) + NumToStr (f200,dec) +"\n"+ EncodeColor(25)+ "262% = "+ EncodeColor(25)+ NumToStr (f262,dec) +"\n"+ EncodeColor(32)+ "424% = "+ EncodeColor(32)+ NumToStr (f424,dec); GraphXSpace=12;
